mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build scripts: report problems with library licenses in a regular test
Previously it was checked when building IDEA Ultimate installers. Now it's simpler to assign investigation about these failures and we avoid unnecessary failures of 'Installers' builds.
This commit is contained in:
Generated
+1
@@ -216,6 +216,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/android/tools-base/pixelprobe/pixelprobe.iml" filepath="$PROJECT_DIR$/android/tools-base/pixelprobe/pixelprobe.iml" group="android/sdktools" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/platform-api/platform-api.iml" filepath="$PROJECT_DIR$/platform/platform-api/platform-api.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" filepath="$PROJECT_DIR$/platform/build-scripts/platform-build-scripts.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/build-scripts/testFramework/buildScripts-testFramework.iml" filepath="$PROJECT_DIR$/platform/build-scripts/testFramework/buildScripts-testFramework.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" filepath="$PROJECT_DIR$/platform/platform-impl/platform-impl.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/platform-main/platform-main.iml" filepath="$PROJECT_DIR$/platform/platform-main/platform-main.iml" group="platform" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/platform-resources/platform-resources.iml" filepath="$PROJECT_DIR$/platform/platform-resources/platform-resources.iml" group="platform" />
|
||||
|
||||
+1
-38
@@ -39,13 +39,9 @@ class LibraryLicensesListGenerator {
|
||||
this.licensesList = licensesList
|
||||
}
|
||||
|
||||
private String getLibraryName(JpsLibrary lib) {
|
||||
static String getLibraryName(JpsLibrary lib) {
|
||||
def name = lib.name
|
||||
if (name.startsWith("#")) {
|
||||
if (lib.getRoots(JpsOrderRootType.COMPILED).size() != 1) {
|
||||
def urls = lib.getRoots(JpsOrderRootType.COMPILED).collect { it.url }
|
||||
messages.warning("Non-single entry module library $name: $urls");
|
||||
}
|
||||
File file = lib.getFiles(JpsOrderRootType.COMPILED)[0]
|
||||
return file.name
|
||||
}
|
||||
@@ -107,38 +103,5 @@ class LibraryLicensesListGenerator {
|
||||
out.close()
|
||||
}
|
||||
}
|
||||
|
||||
void checkLibLicenses() {
|
||||
def libraries = new HashSet<JpsLibrary>()
|
||||
def lib2Module = new HashMap<JpsLibrary, JpsModule>();
|
||||
Set<String> nonPublicModules = ["buildScripts", "build", "buildSrc", "testGuiFramework"] as Set
|
||||
project.modules.findAll { !nonPublicModules.contains(it.name) && !it.name.contains("guitests") }.each { JpsModule module ->
|
||||
JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).getLibraries().each {
|
||||
lib2Module[it] = module
|
||||
libraries << it
|
||||
}
|
||||
}
|
||||
|
||||
def libWithLicenses = licensesList.collectMany { it.libraryNames } as Set<String>
|
||||
|
||||
List<String> withoutLicenses = []
|
||||
libraries.each { JpsLibrary lib ->
|
||||
def name = getLibraryName(lib)
|
||||
if (!libWithLicenses.contains(name)) {
|
||||
withoutLicenses << "$name (used in module ${lib2Module[lib].name})".toString()
|
||||
}
|
||||
}
|
||||
|
||||
if (!withoutLicenses.isEmpty()) {
|
||||
def errorMessage = []
|
||||
errorMessage << "Licenses aren't specified for ${withoutLicenses.size()} libraries:"
|
||||
withoutLicenses.sort(true, String.CASE_INSENSITIVE_ORDER)
|
||||
withoutLicenses.each { errorMessage << it }
|
||||
errorMessage << "If a library is packaged into IDEA installation information about its license must be added into one of *LibraryLicenses.groovy files"
|
||||
errorMessage << "If a library is used in tests only change its scope to 'Test'"
|
||||
errorMessage << "If a library is used for compilation only change its scope to 'Provided'"
|
||||
messages.error(errorMessage.join("\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="platform-build-scripts" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package org.jetbrains.intellij.build
|
||||
|
||||
import junit.framework.AssertionFailedError
|
||||
import org.jetbrains.intellij.build.impl.LibraryLicensesListGenerator
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||
import org.jetbrains.jps.model.library.JpsLibrary
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.junit.rules.ErrorCollector
|
||||
|
||||
class LibraryLicensesTester(private val project: JpsProject, private val licenses: List<LibraryLicense>) {
|
||||
fun reportMissingLicenses(collector: ErrorCollector) {
|
||||
val nonPublicModules = setOf("buildScripts", "build", "buildSrc", "testGuiFramework")
|
||||
val libraries = HashMap<JpsLibrary, JpsModule>()
|
||||
project.modules.filter { it.name !in nonPublicModules && !it.name.contains("guitests") }.forEach { module ->
|
||||
JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).libraries.forEach {
|
||||
libraries[it] = module
|
||||
}
|
||||
}
|
||||
|
||||
val librariesWithLicenses = licenses.flatMapTo(HashSet()) { it.libraryNames }
|
||||
libraries.entries.forEach {
|
||||
val libName = LibraryLicensesListGenerator.getLibraryName(it.key)
|
||||
if (libName !in librariesWithLicenses) {
|
||||
collector.addError(AssertionFailedError("""
|
||||
|License isn't specified for '$libName' library (used in module '${it.value.name}')
|
||||
|If a library is packaged into IDEA installation information about its license must be added into one of *LibraryLicenses.groovy files
|
||||
|If a library is used in tests only change its scope to 'Test'
|
||||
|If a library is used for compilation only change its scope to 'Provided'
|
||||
""".trimMargin()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user