build scripts: use patterns from 'excludeFromModule' as is and check that these patterns are valid (IDEA-166676)

This commit is contained in:
nik
2017-01-24 15:52:19 +03:00
parent 14c7bbd1f2
commit c6cf8e3411
4 changed files with 28 additions and 10 deletions
@@ -154,7 +154,7 @@ class CommunityRepositoryModules {
},
plugin("student-python") {
withResource("resources/courses", "lib/courses")
excludeFromModule("student-python", "courses")
excludeFromModule("student-python", "courses/**")
},
plugin("maven") {
withModule("maven-jps-plugin")
@@ -333,7 +333,7 @@ class CommunityRepositoryModules {
mainJarName = "Groovy.jar"
withModule("groovy-psi", mainJarName)
withModule("structuralsearch-groovy", mainJarName)
excludeFromModule("groovy-psi", "standardDsls")
excludeFromModule("groovy-psi", "standardDsls/**")
withModule("groovy-jps-plugin")
withModule("groovy_rt")
withModule("groovy-rt-constants")
@@ -76,7 +76,7 @@ class ProductModulesLayout {
MultiValuesMap<String, String> additionalPlatformJars = new MultiValuesMap<>(true)
/**
* Module name to entries which should be excluded from its output.
* Module name to list of Ant-like patterns describing entries which should be excluded from its output.
* <strong>This is a temporary property added to keep layout of some products. If some directory from a module shouldn't be included into the
* product JAR it's strongly recommended to move that directory outside of the module source roots.</strong>
*/
@@ -61,12 +61,13 @@ class BaseLayoutSpec {
}
/**
* Exclude the specified directory when {@code moduleName} is packed into JAR file.
* <strong>This is a temporary method added to keep layout of some old plugins. If some directory from a module shouldn't be included into the
* module JAR it's strongly recommended to move that directory outside of the module source roots.</strong>
* @param excludedDirectory path to the directory to be exclude relatively to the module output root
* Exclude the specified files when {@code moduleName} is packed into JAR file.
* <strong>This is a temporary method added to keep layout of some old plugins. If some files from a module shouldn't be included into the
* module JAR it's strongly recommended to move these files outside of the module source roots.</strong>
* @param excludedPattern Ant-like pattern describing files to be excluded (relatively to the module output root); e.g. {@code "foo/**"}
* to exclude 'foo' directory
*/
void excludeFromModule(String moduleName, String excludedDirectory) {
layout.moduleExcludes.put(moduleName, excludedDirectory)
void excludeFromModule(String moduleName, String excludedPattern) {
layout.moduleExcludes.put(moduleName, excludedPattern)
}
}
@@ -17,6 +17,7 @@ package org.jetbrains.intellij.build.impl
import com.intellij.openapi.util.MultiValuesMap
import com.intellij.openapi.util.io.FileUtil
import org.apache.tools.ant.types.FileSet
import org.jetbrains.intellij.build.BuildContext
import org.jetbrains.intellij.build.BuildOptions
import org.jetbrains.intellij.build.BuildTasks
@@ -301,6 +302,7 @@ class DistributionJARsBuilder {
def resourceExcluded = RESOURCES_EXCLUDED
def resourcesIncluded = RESOURCES_INCLUDED
def buildContext = buildContext
checkModuleExcludes(layout.moduleExcludes)
layoutBuilder.layout(targetDirectory) {
dir("lib") {
moduleJars.entrySet().each {
@@ -319,7 +321,7 @@ class DistributionJARsBuilder {
}
layout.moduleExcludes.get(moduleName)?.each {
//noinspection GrUnresolvedAccess
ant.exclude(name: "$it/**")
ant.exclude(name: it)
}
}
}
@@ -394,6 +396,21 @@ class DistributionJARsBuilder {
}
}
private void checkModuleExcludes(MultiValuesMap<String, String> moduleExcludes) {
moduleExcludes.entrySet().each { entry ->
String module = entry.key
entry.value.each { pattern ->
def fileSet = new FileSet()
fileSet.setProject(buildContext.ant.antProject)
fileSet.setDir(new File(buildContext.projectBuilder.getModuleOutput(buildContext.findRequiredModule(module), false)))
fileSet.createInclude().setName(pattern)
if (fileSet.size() == 0) {
buildContext.messages.error("Incorrect exludes for module '$module': nothing matches to $pattern in the module output")
}
}
}
}
static String basePath(BuildContext buildContext, String moduleName) {
JpsPathUtil.urlToPath(buildContext.findRequiredModule(moduleName).contentRootsList.urls.first())
}