Skip to content

Commit

Permalink
License-related cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yole committed Jul 14, 2017
1 parent 84a812d commit 448dba3
Show file tree
Hide file tree
Showing 15 changed files with 2,641 additions and 510 deletions.
50 changes: 50 additions & 0 deletions compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,26 @@ class CodeConformanceTest : TestCase() {
"out",
"dist",
"ideaSDK",
"ultimate/ideaSDK",
"libraries/tools/kotlin-gradle-plugin-core/gradle_api_jar/build/tmp",
"libraries/tools/kotlin-maven-plugin/target",
"compiler/testData/psi/kdoc",
"compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt",
"compiler/util/src/org/jetbrains/kotlin/config/MavenComparableVersion.java"
).map(::File)

private val COPYRIGHT_EXCLUDED_FILES_AND_DIRS = listOf(
"dependencies",
"out",
"dist",
"ideaSDK",
"ultimate/ideaSDK",
"compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt",
"idea/src/org/jetbrains/kotlin/idea/copyright",
"libraries/stdlib/common/build",
"libraries/stdlib/common/target",
"libraries/stdlib/js/build"
)
}

fun testParserCode() {
Expand Down Expand Up @@ -131,4 +145,40 @@ class CodeConformanceTest : TestCase() {
})
}
}

fun testThirdPartyCopyrights() {
val filesWithUnlistedCopyrights = mutableListOf<String>()
val root = File(".").absoluteFile
val knownThirdPartyCode = loadKnownThirdPartyCodeList()
for (sourceFile in FileUtil.findFilesByMask(SOURCES_FILE_PATTERN, root)) {
val relativePath = sourceFile.toRelativeString(root)
if (COPYRIGHT_EXCLUDED_FILES_AND_DIRS.any { relativePath.startsWith(it) } ||
knownThirdPartyCode.any { relativePath.startsWith(it)}) continue

sourceFile.useLines { lineSequence ->
for (line in lineSequence) {
if ("Copyright" in line && "JetBrains" !in line) {
filesWithUnlistedCopyrights.add("$relativePath: $line")
}
}
}
}
if (filesWithUnlistedCopyrights.isNotEmpty()) {
fail("The following files contain third-party copyrights and no license information. " +
"Please update license/README.md accordingly:\n${filesWithUnlistedCopyrights.joinToString("\n")}")
}
}

private fun loadKnownThirdPartyCodeList(): List<String> {
File("license/README.md").useLines { lineSequence ->
return lineSequence
.filter { it.startsWith(" - Path: ") }
.map { it.removePrefix(" - Path: ").trim().ensureFileOrEndsWithSlash() }
.toList()

}
}
}

private fun String.ensureFileOrEndsWithSlash() =
if (endsWith("/") || "." in substringAfterLast('/')) this else this + "/"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 KtBrains s.r.o.
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion license/NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
=========================================================================

Kotlin Compiler
Copyright 2010-2015 JetBrains s.r.o and respective authors and developers
Copyright 2010-2017 JetBrains s.r.o and respective authors and developers
137 changes: 137 additions & 0 deletions license/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
The Apache 2 license (given in full in LICENSE.txt) applies to all code in this repository which is copyright
by JetBrains. The following sections of the repository contain third-party code, to which different licenses
may apply:

## Kotlin Compiler

The following modules contain third-party code and are incorporated into the Kotlin compiler and/or
the Kotlin IntelliJ IDEA plugin:

- Path: compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MaxStackFrameSizeAndLocalsCalculator.java
- License: BSD (license/third_party/asm_license.txt)
- Origin: Derived from ASM: a very small and fast Java bytecode manipulation framework, Copyright (c) 2000-2011 INRIA, France Telecom

- Path: compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt
- License: BSD (license/third_party/asm_license.txt)
- Origin: Derived from ASM: a very small and fast Java bytecode manipulation framework, Copyright (c) 2000-2011 INRIA, France Telecom

- Path: core/reflection.jvm/src/kotlin.reflect/jvm/internal/pcollections
- License: MIT (license/third_party/pcollections_LICENSE.txt)
- Origin: Derived from PCollections, A Persistent Java Collections Library (https://pcollections.org/)

- Path: js/js.ast
- License: BSD (license/third_party/dart_LICENSE.txt)
- Origin: Originally part of the Dart compiler, (c) 2011 the Dart Project Authors,

- Path: js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionInlineMutator.kt
- License: BSD (license/third_party/dart_LICENSE.txt)
- Origin: Originally part of the Dart compiler, (c) 2011 the Dart Project Authors,

- Path: js/js.libraries/src/core/collections
- License: Apache 2 (license/third_party/gwt_license.txt)
- Origin: Derived from GWT, (C) 2007-08 Google Inc.

- Path: js/js.libraries/src/js/long.js
- License: Apache 2 (license/third_party/closure-compiler_LICENSE.txt)
- Origin: Google Closure Library, Copyright 2009 The Closure Library Authors

- Path: js/js.parser/src/com/google
- License: Netscape Public License 1.1 (license/third_party/rhino_LICENSE.txt)
- Origin: Originally part of GWT, (C) 2007-08 Google Inc., distributed under the Apache 2 license. The code
is derived from Rhino, (C) 1997-1999 Netscape Communications Corporation, distributed under the
Netscape Public License.

- Path: js/js.translator/qunit/qunit.js
- License: MIT (license/third_party/qunit_license.txt)
- Origin: QUnit, Copyright (c) 2012 John Resig, Jörn Zaefferer,

- Path: libraries/stdlib/src/kotlin/collections
- License: Apache 2 (license/third_party/gwt_license.txt)
- Origin: Derived from GWT, (C) 2007-08 Google Inc.

- Path: plugins/lint/android-annotations
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: plugins/lint/lint-api
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: plugins/lint/lint-checks
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: plugins/lint/lint-idea
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

## Kotlin Test Data

The following source code is used for testing the Kotlin compiler and/or plugin and is not incorporated into
any distributions of the compiler, libraries or plugin:

- Path: compiler/testData/foreignAnnotations/annotations/android
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: compiler/testData/foreignAnnotations/annotations/com/android
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: compiler/testData/foreignAnnotations/annotations/org/eclipse
- License: Eclipse Public License v1.0 (license/third_party/testdata/eclipse_license.txt)
- Origin: Eclipse JDT, Copyright (c) 2011, 2013 Stephan Herrmann and others.

- Path: compiler/testData/foreignAnnotations/annotations/edu/umd/cs/findbugs
- License: LGPL 2.1 (license/third_party/testdata/findbugs_license.txt)
- Origin: Bytecode Analysis Framework, Copyright (C) 2005 University of Maryland

- Path: compiler/testData/foreignAnnotationsJava8/annotations/org/eclipse
- License: Eclipse Public License v1.0 (license/third_party/testdata/eclipse_license.txt)
- Origin: Eclipse JDT, Copyright (c) 2011, 2013 Stephan Herrmann and others.

- Path: compiler/testData/foreignAnnotations/annotations/io/reactivex
- License: Apache 2 (license/third_party/testdata/rxjava_license.txt)
- Origin: RxJava, Copyright (c) 2016-present, RxJava Contributors

- Path: compiler/testData/foreignAnnotations/annotations/lombok
- License: MIT (license/third_party/testdata/lombok_license.txt)
- Origin: Project Lombok, Copyright (C) 2009-2013 The Project Lombok Authors

- Path: idea/idea-android/tests/org/jetbrains/kotlin/android/AndroidTestBase.java
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: idea/testData/android/lintQuickfix/requiresApi/RequiresApi.java
- License: Apache 2 (license/third_party/aosp_license.txt)
- Origin: Copyright (C) 2011-15 The Android Open Source Project

- Path: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/src/org/springframework/stereotype/Component.java
- License: Apache 2 (license/third_party/testdata/spring_license.txt)
- Origin: Spring Framework, Copyright 2002-2007 the original author or authors.

- Path: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidDaggerProject
- License: Apache 2 (license/third_party/testdata/dagger_license.txt)
- Origin: Dagger, Copyright (C) 2013 Square, Inc.

- Path: libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2
- License: Apache 2 (license/third_party/testdata/dagger_license.txt)
- Origin: Dagger, Copyright (C) 2013 Square, Inc.

- Path: libraries/tools/kotlin-maven-plugin-test/src/it/test-allopen-spring/src/main/java/org/springframework/stereotype/Component.java
- License: Apache 2 (license/third_party/testdata/spring_license.txt)
- Origin: Spring Framework, Copyright 2002-2007 the original author or authors.

## Example Code

The following code is provided as examples and is not incorporated into
any distributions of the compiler, libraries or plugin:

- Path: libraries/examples/browser-example/src/js/jquery.js
- License: MIT (license/third_party/jquery_license.txt)
- Origin: jQuery JavaScript Library v1.6.2, Copyright 2011, John Resig

- Path: libraries/examples/browser-example-with-library/src/js/jquery.js
- License: MIT (license/third_party/jquery_license.txt)
- Origin: jQuery JavaScript Library v1.6.2, Copyright 2011, John Resig

Loading

0 comments on commit 448dba3

Please sign in to comment.