mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed tests.
This commit is contained in:
Generated
+54
-57
@@ -1,57 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DependencyValidationManager">
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</component>
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="FacetAutodetectingManager">
|
||||
<autodetection-disabled>
|
||||
<facet-type id="Groovy">
|
||||
<modules>
|
||||
<module name="A">
|
||||
<files>
|
||||
<file url="file://$PROJECT_DIR$/A/src/test/a/SomeGroovyClass.groovy" />
|
||||
<file url="file://$PROJECT_DIR$/samples/A/src/test/a/SomeGroovyClass.groovy" />
|
||||
</files>
|
||||
</module>
|
||||
</modules>
|
||||
</facet-type>
|
||||
</autodetection-disabled>
|
||||
</component>
|
||||
<component name="IdProvider" IDEtalkID="56801B29E60003A3AED3E894FD8130D3" />
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
<option name="OPTION_HIERARCHY" value="true" />
|
||||
<option name="OPTION_NAVIGATOR" value="true" />
|
||||
<option name="OPTION_INDEX" value="true" />
|
||||
<option name="OPTION_SEPARATE_INDEX" value="true" />
|
||||
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
|
||||
<option name="OPTION_DEPRECATED_LIST" value="true" />
|
||||
<option name="OTHER_OPTIONS" value="" />
|
||||
<option name="HEAP_SIZE" />
|
||||
<option name="LOCALE" />
|
||||
<option name="OPEN_IN_BROWSER" value="true" />
|
||||
</component>
|
||||
<component name="ProjectDetails">
|
||||
<option name="projectName" value="jps" />
|
||||
</component>
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://default" />
|
||||
</component>
|
||||
<component name="ProjectResources">
|
||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="mySupportsUserInfoFilter" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="FacetAutodetectingManager">
|
||||
<autodetection-disabled>
|
||||
<facet-type id="Groovy">
|
||||
<modules>
|
||||
<module name="A">
|
||||
<files>
|
||||
<file url="file://$PROJECT_DIR$/A/src/test/a/SomeGroovyClass.groovy" />
|
||||
<file url="file://$PROJECT_DIR$/samples/A/src/test/a/SomeGroovyClass.groovy" />
|
||||
</files>
|
||||
</module>
|
||||
</modules>
|
||||
</facet-type>
|
||||
</autodetection-disabled>
|
||||
</component>
|
||||
<component name="IdProvider" IDEtalkID="56801B29E60003A3AED3E894FD8130D3" />
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
<option name="OPTION_HIERARCHY" value="true" />
|
||||
<option name="OPTION_NAVIGATOR" value="true" />
|
||||
<option name="OPTION_INDEX" value="true" />
|
||||
<option name="OPTION_SEPARATE_INDEX" value="true" />
|
||||
<option name="OPTION_DOCUMENT_TAG_USE" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
|
||||
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
|
||||
<option name="OPTION_DEPRECATED_LIST" value="true" />
|
||||
<option name="OTHER_OPTIONS" value="" />
|
||||
<option name="HEAP_SIZE" />
|
||||
<option name="LOCALE" />
|
||||
<option name="OPEN_IN_BROWSER" value="true" />
|
||||
</component>
|
||||
<component name="ProjectDetails">
|
||||
<option name="projectName" value="jps" />
|
||||
</component>
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://default" />
|
||||
</component>
|
||||
<component name="ProjectResources">
|
||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SvnBranchConfigurationManager">
|
||||
<option name="mySupportsUserInfoFilter" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
|
||||
+13
-13
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+21
-21
@@ -1,21 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="library" name="Javac2" level="project" />
|
||||
<orderEntry type="module" module-name="antlayout" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
|
||||
<orderEntry type="library" name="Gant" level="application" />
|
||||
<orderEntry type="library" name="asm" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="library" name="Javac2" level="project" />
|
||||
<orderEntry type="module" module-name="antlayout" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit" level="project" />
|
||||
<orderEntry type="library" name="Gant" level="application" />
|
||||
<orderEntry type="library" name="asm" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+15
-15
@@ -1,15 +1,15 @@
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="javaee" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="javaee" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+14
-14
@@ -1,14 +1,14 @@
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
<?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="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -739,17 +739,27 @@ public class ProjectWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private ProjectWrapper(final String prjDir, final String setupScript) {
|
||||
private ProjectWrapper(final GantBinding binding, final String prjDir, final String setupScript, final Map<String, String> pathVariables) {
|
||||
dependencyMapping = new Mappings(this);
|
||||
backendCallback = dependencyMapping.getCallback();
|
||||
affectedFiles = new HashSet<StringCache.S>();
|
||||
|
||||
myProject = new Project(new GantBinding());
|
||||
myRoot = getCanonicalPath(prjDir);
|
||||
myProject = new Project(binding == null ? new GantBinding() : binding);
|
||||
|
||||
final File prjFile = new File(prjDir);
|
||||
final boolean dirBased = !(prjFile.isFile() && prjDir.endsWith(".ipr"));
|
||||
|
||||
myRoot = dirBased ? getCanonicalPath(prjDir) : getCanonicalPath(prjFile.getPath());
|
||||
|
||||
final String loadPath = dirBased ? getAbsolutePath(myIDEADir) : prjDir;
|
||||
|
||||
myProjectSnapshot = myHomeDir + File.separator + myJPSDir + File.separator + myRoot.replace(File.separatorChar, myFileSeparatorReplacement);
|
||||
|
||||
IdeaProjectLoader.loadFromPath(myProject, getAbsolutePath(myIDEADir), setupScript);
|
||||
if (pathVariables == null) {
|
||||
IdeaProjectLoader.loadFromPath(myProject, loadPath, setupScript);
|
||||
} else {
|
||||
IdeaProjectLoader.loadFromPath(myProject, loadPath, pathVariables, setupScript);
|
||||
}
|
||||
|
||||
for (Module m : myProject.getModules().values()) {
|
||||
myModules.put(m.getName(), new ModuleWrapper(m));
|
||||
@@ -880,7 +890,11 @@ public class ProjectWrapper {
|
||||
}
|
||||
|
||||
public static ProjectWrapper load(final String path, final String setupScript) {
|
||||
return new ProjectWrapper(path, setupScript);
|
||||
return new ProjectWrapper(null, path, setupScript, null);
|
||||
}
|
||||
|
||||
public static ProjectWrapper load(final GantBinding binding, final String path, final String setupScript, final Map<String, String> pathVariables) {
|
||||
return new ProjectWrapper(binding, path, setupScript, pathVariables);
|
||||
}
|
||||
|
||||
public void report(final String module) {
|
||||
@@ -925,6 +939,18 @@ public class ProjectWrapper {
|
||||
makeModules(myProject.getModules().values(), defaultFlags);
|
||||
}
|
||||
|
||||
public void buildArtifacts() {
|
||||
myProject.buildArtifacts();
|
||||
}
|
||||
|
||||
public void deleteTempFiles() {
|
||||
myProject.deleteTempFiles();
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
class BusyBeaver {
|
||||
final ProjectBuilder builder;
|
||||
final Set<StringCache.S> compiledFiles = new HashSet<StringCache.S>();
|
||||
@@ -1126,7 +1152,7 @@ public class ProjectWrapper {
|
||||
final List<Module> dep = new ArrayList<Module>();
|
||||
|
||||
for (ClasspathItem cpi : module.getClasspath(kind)) {
|
||||
if (cpi instanceof Module) {
|
||||
if (cpi instanceof Module && !marked.contains(((Module) cpi).getName())) {
|
||||
DotPrinter.edge(((Module) cpi).getName(), mName);
|
||||
dep.add((Module) cpi);
|
||||
}
|
||||
|
||||
@@ -1,405 +1,403 @@
|
||||
package org.jetbrains.jps.builders
|
||||
|
||||
import com.intellij.ant.InstrumentationUtil
|
||||
import com.intellij.ant.InstrumentationUtil.FormInstrumenter
|
||||
import com.intellij.ant.PrefixedPath
|
||||
import org.apache.tools.ant.BuildListener
|
||||
import org.jetbrains.ether.ProjectWrapper
|
||||
import org.jetbrains.ether.dependencyView.AntListener
|
||||
import org.jetbrains.ether.dependencyView.StringCache
|
||||
import org.jetbrains.ether.dependencyView.StringCache.S
|
||||
import org.jetbrains.jps.builders.javacApi.Java16ApiCompilerRunner
|
||||
import org.jetbrains.jps.*
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
class JavacBuilder implements ModuleBuilder, ModuleCycleBuilder {
|
||||
|
||||
def preprocessModuleCycle(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
doBuildModule(moduleChunk, state)
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
doBuildModule(moduleChunk, state)
|
||||
}
|
||||
|
||||
def doBuildModule(ModuleChunk module, ModuleBuildState state) {
|
||||
if (state.sourceRoots.isEmpty()) return;
|
||||
|
||||
String sourceLevel = module["sourceLevel"]
|
||||
String targetLevel = module["targetLevel"]
|
||||
String customArgs = module["javac_args"]; // it seems javac_args property is not set, can we drop it?
|
||||
if (module.project.builder.useInProcessJavac) {
|
||||
String version = System.getProperty("java.version")
|
||||
if (true) {
|
||||
if (Java16ApiCompilerRunner.compile(module, state, sourceLevel, targetLevel, customArgs)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
module.project.info("In-process Javac won't be used for '${module.name}', because Java version ($version) doesn't match to source level ($sourceLevel)")
|
||||
}
|
||||
}
|
||||
|
||||
def params = [:]
|
||||
params.destdir = state.targetFolder
|
||||
if (sourceLevel != null) params.source = sourceLevel
|
||||
if (targetLevel != null) params.target = targetLevel
|
||||
|
||||
def javacOpts = module.project.props["compiler.javac.options"];
|
||||
def memHeapSize = javacOpts["MAXIMUM_HEAP_SIZE"] == null ? "512m" : javacOpts["MAXIMUM_HEAP_SIZE"] + "m";
|
||||
def boolean debugInfo = !"false".equals(javacOpts["DEBUGGING_INFO"]);
|
||||
def boolean nowarn = "true".equals(javacOpts["GENERATE_NO_WARNINGS"]);
|
||||
def boolean deprecation = !"false".equals(javacOpts["DEPRECATION"]);
|
||||
customArgs = javacOpts["ADDITIONAL_OPTIONS_STRING"];
|
||||
|
||||
params.fork = "true"
|
||||
params.memoryMaximumSize = memHeapSize;
|
||||
params.debug = String.valueOf(debugInfo);
|
||||
params.nowarn = String.valueOf(nowarn);
|
||||
params.deprecation = String.valueOf(deprecation);
|
||||
params.verbose = "true"
|
||||
|
||||
def javacExecutable = getJavacExecutable(module)
|
||||
if (javacExecutable != null) {
|
||||
params.executable = javacExecutable
|
||||
}
|
||||
|
||||
def ant = module.project.binding.ant
|
||||
|
||||
final BuildListener listener = new AntListener(state.targetFolder, state.sourceRoots, state.callback);
|
||||
|
||||
ant.project.addBuildListener(listener);
|
||||
|
||||
ant.javac(params) {
|
||||
if (customArgs) {
|
||||
compilerarg(line: customArgs)
|
||||
}
|
||||
|
||||
if (state.sourceFiles != null) {
|
||||
List patterns = []
|
||||
|
||||
state.sourceFiles.each {
|
||||
for (String root: state.sourceRoots) {
|
||||
if (it.startsWith(root) && it.endsWith(".java")) {
|
||||
patterns << it.substring(root.length() + 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
patterns.each {
|
||||
include(name: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
state.excludes.each { String root ->
|
||||
state.sourceRoots.each {String src ->
|
||||
if (root.startsWith("${src}/")) {
|
||||
exclude(name: "${root.substring(src.length() + 1)}/**")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ant.project.removeBuildListener(listener);
|
||||
|
||||
if (state.sourceFiles != null) {
|
||||
module.project.builder.listeners*.onJavaFilesCompiled(module, state.sourceFiles.size())
|
||||
}
|
||||
}
|
||||
|
||||
private String getJavacExecutable(ModuleChunk module) {
|
||||
def customJavac = module["javac"]
|
||||
def jdk = module.getSdk()
|
||||
if (customJavac != null) {
|
||||
return customJavac
|
||||
}
|
||||
else if (jdk instanceof JavaSdk) {
|
||||
return jdk.getJavacExecutable()
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class ResourceCopier implements ModuleBuilder {
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (state.iterated) return;
|
||||
|
||||
state.iterated = true
|
||||
|
||||
if (state.sourceRoots.isEmpty()) return;
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
state.sourceRoots.each {String root ->
|
||||
if (new File(root).exists()) {
|
||||
def target = state.targetFolder
|
||||
def prefix = moduleChunk.modules.collect { it.sourceRootPrefixes[root] }.find {it != null}
|
||||
if (prefix != null) {
|
||||
if (!(target.endsWith("/") || target.endsWith("\\"))) {
|
||||
target += "/"
|
||||
}
|
||||
target += prefix
|
||||
}
|
||||
|
||||
ant.copy(todir: target) {
|
||||
fileset(dir: root) {
|
||||
patternset(refid: moduleChunk["compiler.resources.id"])
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.warning("$root doesn't exist")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GroovycBuilder implements ModuleBuilder {
|
||||
def GroovycBuilder(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "groovyc", classname: "org.codehaus.groovy.ant.Groovyc")
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (!GroovyFileSearcher.containGroovyFiles(state.sourceRoots)) return
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
final String destDir = state.targetFolder
|
||||
|
||||
ant.touch(millis: 239) {
|
||||
fileset(dir: destDir) {
|
||||
include(name: "**/*.class")
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately we have to disable fork here because of a bug in Groovyc task: it creates too long command line if classpath is large
|
||||
ant.groovyc(destdir: destDir /*, fork: "true"*/) {
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
include(name: "**/*.groovy")
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
|
||||
pathelement(location: destDir) // Includes classes generated there by javac compiler
|
||||
}
|
||||
}
|
||||
|
||||
ant.touch() {
|
||||
fileset(dir: destDir) {
|
||||
include(name: "**/*.class")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GroovyStubGenerator implements ModuleBuilder {
|
||||
|
||||
def GroovyStubGenerator(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "generatestubs", classname: "org.codehaus.groovy.ant.GenerateStubsTask")
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (!GroovyFileSearcher.containGroovyFiles(state.sourceRoots)) return
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
String targetFolder = project.targetFolder
|
||||
File dir = new File(targetFolder != null ? targetFolder : ".", "___temp___")
|
||||
BuildUtil.deleteDir(project, dir.absolutePath)
|
||||
ant.mkdir(dir: dir)
|
||||
|
||||
def stubsRoot = dir.getAbsolutePath()
|
||||
ant.generatestubs(destdir: stubsRoot) {
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
include(name: "**/*.groovy")
|
||||
include(name: "**/*.java")
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.sourceRoots << stubsRoot
|
||||
state.tempRootsToDelete << stubsRoot
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class JetBrainsInstrumentations implements ModuleBuilder {
|
||||
class CustomFormInstrumenter extends
|
||||
FormInstrumenter {
|
||||
final List<String> formFiles;
|
||||
final ModuleBuildState state;
|
||||
|
||||
@Override
|
||||
void associate(final String formFile, final String classFile) {
|
||||
if (state.callback != null) {
|
||||
final String formRelPath = state.projectWrapper.getRelativePath(formFile);
|
||||
final String classRelPath = state.projectWrapper.getRelativePath(classFile);
|
||||
|
||||
state.callback.associateForm(StringCache.get(formRelPath), StringCache.get(classRelPath));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void log(String msg, int option) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
void fireError(String msg) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
CustomFormInstrumenter(final File destDir, final List<String> nestedFormPathList, final List<String> ff, final ModuleBuildState s) {
|
||||
super(destDir, nestedFormPathList);
|
||||
formFiles = ff;
|
||||
state = s;
|
||||
}
|
||||
}
|
||||
|
||||
def JetBrainsInstrumentations(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "jb_instrumentations", classname: "com.intellij.ant.InstrumentIdeaExtensions")
|
||||
}
|
||||
|
||||
def getPrefixedPath(org.jetbrains.jps.Project project, String root, ModuleChunk moduleChunk) {
|
||||
final path = new PrefixedPath(project.binding.ant.project, root)
|
||||
|
||||
moduleChunk.elements.each {module ->
|
||||
final String prefix = module.sourceRootPrefixes[root]
|
||||
if (prefix != null) {
|
||||
path.setPrefix(prefix)
|
||||
}
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (state.loader == null) {
|
||||
final StringBuffer cp = new StringBuffer()
|
||||
|
||||
cp.append(state.targetFolder)
|
||||
cp.append(File.pathSeparator)
|
||||
|
||||
state.classpath.each {
|
||||
cp.append(it)
|
||||
cp.append(File.pathSeparator)
|
||||
}
|
||||
|
||||
state.loader = InstrumentationUtil.createPseudoClassLoader(cp.toString())
|
||||
|
||||
final List<File> formFiles = new ArrayList<File>();
|
||||
final ProjectWrapper pw = state.projectWrapper;
|
||||
|
||||
if (pw != null) {
|
||||
for (Module m: moduleChunk.elements) {
|
||||
final Set<S> names = state.tests ? pw.getModule(m.getName()).getTests() : pw.getModule(m.getName()).getSources();
|
||||
for (S name: names) {
|
||||
if (name.value.endsWith(".form")) {
|
||||
formFiles.add(new File(pw.getAbsolutePath(name.value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<PrefixedPath> nestedFormDirs = new ArrayList<PrefixedPath>();
|
||||
|
||||
state.sourceRoots.each {
|
||||
nestedFormDirs << getPrefixedPath(project, it, moduleChunk)
|
||||
}
|
||||
|
||||
state.moduleDependenciesSourceRoots.each {
|
||||
nestedFormDirs << getPrefixedPath(project, it, moduleChunk)
|
||||
}
|
||||
|
||||
state.formInstrumenter = new CustomFormInstrumenter(new File(state.targetFolder), nestedFormDirs, formFiles, state);
|
||||
|
||||
if (!state.incremental) {
|
||||
for (File formFile: formFiles) {
|
||||
state.formInstrumenter.instrumentForm(formFile, state.loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.incremental) {
|
||||
for (String f: state.sourceFiles) {
|
||||
if (f.endsWith(".form")) {
|
||||
state.formInstrumenter.instrumentForm(new File(f), state.loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (project.getBuilder().useInProcessJavac)
|
||||
return;
|
||||
|
||||
if (!state.incremental) {
|
||||
new Object() {
|
||||
public void traverse(final File root) {
|
||||
final File[] files = root.listFiles();
|
||||
|
||||
for (File f: files) {
|
||||
final String name = f.getName();
|
||||
|
||||
if (name.endsWith(".class")) {
|
||||
InstrumentationUtil.instrumentNotNull(f, state.loader)
|
||||
}
|
||||
else if (f.isDirectory()) {
|
||||
traverse(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.traverse(new File(state.targetFolder))
|
||||
}
|
||||
else {
|
||||
final Collection<StringCache.S> classes = state.callback.getClassFiles()
|
||||
|
||||
classes.each {
|
||||
InstrumentationUtil.instrumentNotNull(new File(state.targetFolder + File.separator + it.value + ".class"), state.loader)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTasksBuilder implements ModuleBuilder {
|
||||
List<ModuleBuildTask> tasks = []
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
moduleChunk.modules.each {Module module ->
|
||||
tasks*.perform(module, state.targetFolder)
|
||||
}
|
||||
}
|
||||
|
||||
def registerTask(String moduleName, Closure task) {
|
||||
tasks << ({Module module, String outputFolder ->
|
||||
if (module.name == moduleName) {
|
||||
task(module, outputFolder)
|
||||
}
|
||||
} as ModuleBuildTask)
|
||||
}
|
||||
package org.jetbrains.jps.builders
|
||||
|
||||
import com.intellij.ant.InstrumentationUtil
|
||||
import com.intellij.ant.InstrumentationUtil.FormInstrumenter
|
||||
import com.intellij.ant.PrefixedPath
|
||||
import org.apache.tools.ant.BuildListener
|
||||
import org.jetbrains.ether.ProjectWrapper
|
||||
import org.jetbrains.ether.dependencyView.AntListener
|
||||
import org.jetbrains.ether.dependencyView.StringCache
|
||||
import org.jetbrains.ether.dependencyView.StringCache.S
|
||||
import org.jetbrains.jps.builders.javacApi.Java16ApiCompilerRunner
|
||||
import org.jetbrains.jps.*
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
class JavacBuilder implements ModuleBuilder, ModuleCycleBuilder {
|
||||
|
||||
def preprocessModuleCycle(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
doBuildModule(moduleChunk, state)
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
doBuildModule(moduleChunk, state)
|
||||
}
|
||||
|
||||
def doBuildModule(ModuleChunk module, ModuleBuildState state) {
|
||||
if (state.sourceRoots.isEmpty()) return;
|
||||
|
||||
String sourceLevel = module["sourceLevel"]
|
||||
String targetLevel = module["targetLevel"]
|
||||
String customArgs = module["javac_args"]; // it seems javac_args property is not set, can we drop it?
|
||||
if (module.project.builder.useInProcessJavac) {
|
||||
String version = System.getProperty("java.version")
|
||||
if (true) {
|
||||
if (Java16ApiCompilerRunner.compile(module, state, sourceLevel, targetLevel, customArgs)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
module.project.info("In-process Javac won't be used for '${module.name}', because Java version ($version) doesn't match to source level ($sourceLevel)")
|
||||
}
|
||||
}
|
||||
|
||||
def params = [:]
|
||||
params.destdir = state.targetFolder
|
||||
if (sourceLevel != null) params.source = sourceLevel
|
||||
if (targetLevel != null) params.target = targetLevel
|
||||
|
||||
def javacOpts = module.project.props["compiler.javac.options"];
|
||||
def memHeapSize = javacOpts["MAXIMUM_HEAP_SIZE"] == null ? "512m" : javacOpts["MAXIMUM_HEAP_SIZE"] + "m";
|
||||
def boolean debugInfo = !"false".equals(javacOpts["DEBUGGING_INFO"]);
|
||||
def boolean nowarn = "true".equals(javacOpts["GENERATE_NO_WARNINGS"]);
|
||||
def boolean deprecation = !"false".equals(javacOpts["DEPRECATION"]);
|
||||
customArgs = javacOpts["ADDITIONAL_OPTIONS_STRING"];
|
||||
|
||||
params.fork = "true"
|
||||
params.memoryMaximumSize = memHeapSize;
|
||||
params.debug = String.valueOf(debugInfo);
|
||||
params.nowarn = String.valueOf(nowarn);
|
||||
params.deprecation = String.valueOf(deprecation);
|
||||
params.verbose = "true"
|
||||
|
||||
def javacExecutable = getJavacExecutable(module)
|
||||
if (javacExecutable != null) {
|
||||
params.executable = javacExecutable
|
||||
}
|
||||
|
||||
def ant = module.project.binding.ant
|
||||
|
||||
final BuildListener listener = new AntListener(state.targetFolder, state.sourceRoots, state.callback);
|
||||
|
||||
ant.project.addBuildListener(listener);
|
||||
|
||||
ant.javac(params) {
|
||||
if (customArgs) {
|
||||
compilerarg(line: customArgs)
|
||||
}
|
||||
|
||||
if (state.sourceFiles != null) {
|
||||
List patterns = []
|
||||
|
||||
state.sourceFiles.each {
|
||||
for (String root: state.sourceRoots) {
|
||||
if (it.startsWith(root) && it.endsWith(".java")) {
|
||||
patterns << it.substring(root.length() + 1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
patterns.each {
|
||||
include(name: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
state.excludes.each { String root ->
|
||||
state.sourceRoots.each {String src ->
|
||||
if (root.startsWith("${src}/")) {
|
||||
exclude(name: "${root.substring(src.length() + 1)}/**")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ant.project.removeBuildListener(listener);
|
||||
|
||||
if (state.sourceFiles != null) {
|
||||
module.project.builder.listeners*.onJavaFilesCompiled(module, state.sourceFiles.size())
|
||||
}
|
||||
}
|
||||
|
||||
private String getJavacExecutable(ModuleChunk module) {
|
||||
def customJavac = module["javac"]
|
||||
def jdk = module.getSdk()
|
||||
if (customJavac != null) {
|
||||
return customJavac
|
||||
}
|
||||
else if (jdk instanceof JavaSdk) {
|
||||
return jdk.getJavacExecutable()
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class ResourceCopier implements ModuleBuilder {
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (state.iterated) return;
|
||||
|
||||
state.iterated = true
|
||||
|
||||
if (state.sourceRoots.isEmpty()) return;
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
state.sourceRoots.each {String root ->
|
||||
if (new File(root).exists()) {
|
||||
def target = state.targetFolder
|
||||
def prefix = moduleChunk.modules.collect { it.sourceRootPrefixes[root] }.find {it != null}
|
||||
if (prefix != null) {
|
||||
if (!(target.endsWith("/") || target.endsWith("\\"))) {
|
||||
target += "/"
|
||||
}
|
||||
target += prefix
|
||||
}
|
||||
|
||||
ant.copy(todir: target) {
|
||||
fileset(dir: root) {
|
||||
patternset(refid: moduleChunk["compiler.resources.id"])
|
||||
type(type: "file")
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.warning("$root doesn't exist")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GroovycBuilder implements ModuleBuilder {
|
||||
def GroovycBuilder(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "groovyc", classname: "org.codehaus.groovy.ant.Groovyc")
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (!GroovyFileSearcher.containGroovyFiles(state.sourceRoots)) return
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
final String destDir = state.targetFolder
|
||||
|
||||
ant.touch(millis: 239) {
|
||||
fileset(dir: destDir) {
|
||||
include(name: "**/*.class")
|
||||
}
|
||||
}
|
||||
|
||||
// unfortunately we have to disable fork here because of a bug in Groovyc task: it creates too long command line if classpath is large
|
||||
ant.groovyc(destdir: destDir /*, fork: "true"*/) {
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
include(name: "**/*.groovy")
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
|
||||
pathelement(location: destDir) // Includes classes generated there by javac compiler
|
||||
}
|
||||
}
|
||||
|
||||
ant.touch() {
|
||||
fileset(dir: destDir) {
|
||||
include(name: "**/*.class")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GroovyStubGenerator implements ModuleBuilder {
|
||||
|
||||
def GroovyStubGenerator(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "generatestubs", classname: "org.codehaus.groovy.ant.GenerateStubsTask")
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (!GroovyFileSearcher.containGroovyFiles(state.sourceRoots)) return
|
||||
|
||||
def ant = project.binding.ant
|
||||
|
||||
String targetFolder = project.targetFolder
|
||||
File dir = new File(targetFolder != null ? targetFolder : ".", "___temp___")
|
||||
BuildUtil.deleteDir(project, dir.absolutePath)
|
||||
ant.mkdir(dir: dir)
|
||||
|
||||
def stubsRoot = dir.getAbsolutePath()
|
||||
ant.generatestubs(destdir: stubsRoot) {
|
||||
state.sourceRoots.each {
|
||||
src(path: it)
|
||||
}
|
||||
|
||||
include(name: "**/*.groovy")
|
||||
include(name: "**/*.java")
|
||||
|
||||
classpath {
|
||||
state.classpath.each {
|
||||
pathelement(location: it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
state.sourceRoots << stubsRoot
|
||||
state.tempRootsToDelete << stubsRoot
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class JetBrainsInstrumentations implements ModuleBuilder {
|
||||
class CustomFormInstrumenter extends
|
||||
FormInstrumenter {
|
||||
final List<String> formFiles;
|
||||
final ModuleBuildState state;
|
||||
|
||||
@Override
|
||||
void associate(final String formFile, final String classFile) {
|
||||
if (state.callback != null) {
|
||||
final String formRelPath = state.projectWrapper.getRelativePath(formFile);
|
||||
final String classRelPath = state.projectWrapper.getRelativePath(classFile);
|
||||
|
||||
state.callback.associateForm(StringCache.get(formRelPath), StringCache.get(classRelPath));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void log(String msg, int option) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
void fireError(String msg) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
CustomFormInstrumenter(final File destDir, final List<String> nestedFormPathList, final List<String> ff, final ModuleBuildState s) {
|
||||
super(destDir, nestedFormPathList);
|
||||
formFiles = ff;
|
||||
state = s;
|
||||
}
|
||||
}
|
||||
|
||||
def JetBrainsInstrumentations(org.jetbrains.jps.Project project) {
|
||||
project.taskdef(name: "jb_instrumentations", classname: "com.intellij.ant.InstrumentIdeaExtensions")
|
||||
}
|
||||
|
||||
def getPrefixedPath(org.jetbrains.jps.Project project, String root, ModuleChunk moduleChunk) {
|
||||
final path = new PrefixedPath(project.binding.ant.project, root)
|
||||
|
||||
moduleChunk.elements.each {module ->
|
||||
final String prefix = module.sourceRootPrefixes[root]
|
||||
if (prefix != null) {
|
||||
path.setPrefix(prefix)
|
||||
}
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
if (state.loader == null) {
|
||||
final StringBuffer cp = new StringBuffer()
|
||||
|
||||
cp.append(state.targetFolder)
|
||||
cp.append(File.pathSeparator)
|
||||
|
||||
state.classpath.each {
|
||||
cp.append(it)
|
||||
cp.append(File.pathSeparator)
|
||||
}
|
||||
|
||||
state.loader = InstrumentationUtil.createPseudoClassLoader(cp.toString())
|
||||
|
||||
final List<File> formFiles = new ArrayList<File>();
|
||||
final ProjectWrapper pw = state.projectWrapper;
|
||||
|
||||
for (Module m: moduleChunk.elements) {
|
||||
final Set<S> names = state.tests ? pw.getModule(m.getName()).getTests() : pw.getModule(m.getName()).getSources();
|
||||
for (S name: names) {
|
||||
if (name.value.endsWith(".form")) {
|
||||
formFiles.add(new File(pw.getAbsolutePath(name.value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<PrefixedPath> nestedFormDirs = new ArrayList<PrefixedPath>();
|
||||
|
||||
state.sourceRoots.each {
|
||||
nestedFormDirs << getPrefixedPath(project, it, moduleChunk)
|
||||
}
|
||||
|
||||
state.moduleDependenciesSourceRoots.each {
|
||||
nestedFormDirs << getPrefixedPath(project, it, moduleChunk)
|
||||
}
|
||||
|
||||
state.formInstrumenter = new CustomFormInstrumenter(new File(state.targetFolder), nestedFormDirs, formFiles, state);
|
||||
|
||||
if (!state.incremental) {
|
||||
for (File formFile: formFiles) {
|
||||
state.formInstrumenter.instrumentForm(formFile, state.loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.incremental) {
|
||||
for (String f: state.sourceFiles) {
|
||||
if (f.endsWith(".form")) {
|
||||
state.formInstrumenter.instrumentForm(new File(f), state.loader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (project.getBuilder().useInProcessJavac)
|
||||
return;
|
||||
|
||||
if (!state.incremental) {
|
||||
new Object() {
|
||||
public void traverse(final File root) {
|
||||
final File[] files = root.listFiles();
|
||||
|
||||
for (File f: files) {
|
||||
final String name = f.getName();
|
||||
|
||||
if (name.endsWith(".class")) {
|
||||
InstrumentationUtil.instrumentNotNull(f, state.loader)
|
||||
}
|
||||
else if (f.isDirectory()) {
|
||||
traverse(f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.traverse(new File(state.targetFolder))
|
||||
}
|
||||
else {
|
||||
final Collection<StringCache.S> classes = state.callback.getClassFiles()
|
||||
|
||||
classes.each {
|
||||
InstrumentationUtil.instrumentNotNull(new File(state.targetFolder + File.separator + it.value + ".class"), state.loader)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTasksBuilder implements ModuleBuilder {
|
||||
List<ModuleBuildTask> tasks = []
|
||||
|
||||
def processModule(ModuleBuildState state, ModuleChunk moduleChunk, org.jetbrains.jps.Project project) {
|
||||
moduleChunk.modules.each {Module module ->
|
||||
tasks*.perform(module, state.targetFolder)
|
||||
}
|
||||
}
|
||||
|
||||
def registerTask(String moduleName, Closure task) {
|
||||
tasks << ({Module module, String outputFolder ->
|
||||
if (module.name == moduleName) {
|
||||
task(module, outputFolder)
|
||||
}
|
||||
} as ModuleBuildTask)
|
||||
}
|
||||
}
|
||||
@@ -2,69 +2,73 @@ package org.jetbrains.jps
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.codehaus.gant.GantBinding
|
||||
import org.jetbrains.ether.ProjectWrapper
|
||||
import org.jetbrains.jps.idea.IdeaProjectLoader
|
||||
import org.jetbrains.jps.util.FileSystemItem
|
||||
import org.jetbrains.jps.util.FileUtil;
|
||||
import org.jetbrains.jps.util.FileUtil
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
abstract class JpsBuildTestCase extends TestCase {
|
||||
|
||||
def doTest(String projectPath, Closure initProject, Closure expectedOutput) {
|
||||
doTest(projectPath, [:], initProject, expectedOutput)
|
||||
}
|
||||
|
||||
def doTest(String projectPath, Map<String, String> pathVariables, Closure initProject, Closure expectedOutput) {
|
||||
Project project = buildAll(projectPath, pathVariables, initProject)
|
||||
assertOutput(project, project.targetFolder, expectedOutput);
|
||||
}
|
||||
|
||||
def protected assertOutput(Project project, String targetFolder, Closure expectedOutput) {
|
||||
def root = new FileSystemItem(name: "<root>")
|
||||
initFileSystemItem(root, expectedOutput)
|
||||
root.assertDirectoryEqual(new File(targetFolder), "")
|
||||
}
|
||||
|
||||
def protected buildAll(String projectPath, Map<String, String> pathVariables, Closure initProject) {
|
||||
Project project = loadProject(projectPath, pathVariables)
|
||||
def target = FileUtil.createTempDirectory("targetDir")
|
||||
project.targetFolder = target.absolutePath
|
||||
initProject(project)
|
||||
project.clean()
|
||||
project.makeAll()
|
||||
project.buildArtifacts()
|
||||
project.deleteTempFiles()
|
||||
return project
|
||||
}
|
||||
|
||||
protected Project loadProject(String projectPath, Map<String, String> pathVariables) {
|
||||
def binding = new GantBinding()
|
||||
binding.includeTool << Jps
|
||||
def project = new Project(binding)
|
||||
IdeaProjectLoader.loadFromPath(project, projectPath, pathVariables, null)
|
||||
return project
|
||||
}
|
||||
|
||||
def initFileSystemItem(FileSystemItem item, Closure initializer) {
|
||||
def meta = new InitializingExpando()
|
||||
meta.dir = {String name, Closure content ->
|
||||
def dir = new FileSystemItem(name: name, directory: true)
|
||||
initFileSystemItem(dir, content)
|
||||
item << dir
|
||||
}
|
||||
meta.archive = {String name, Closure content ->
|
||||
def archive = new FileSystemItem(name: name, archive: true)
|
||||
initFileSystemItem(archive, content)
|
||||
item << archive
|
||||
}
|
||||
meta.file = {Object[] args ->
|
||||
item << new FileSystemItem(name: args[0], content: args.length > 1 ? args[1] : null)
|
||||
def doTest(String projectPath, Closure initProject, Closure expectedOutput) {
|
||||
doTest(projectPath, [:], initProject, expectedOutput)
|
||||
}
|
||||
|
||||
initializer.delegate = meta
|
||||
initializer.setResolveStrategy Closure.DELEGATE_FIRST
|
||||
initializer()
|
||||
}
|
||||
def doTest(String projectPath, Map<String, String> pathVariables, Closure initProject, Closure expectedOutput) {
|
||||
Project project = buildAll(projectPath, pathVariables, initProject)
|
||||
assertOutput(project, project.targetFolder, expectedOutput);
|
||||
}
|
||||
|
||||
def protected assertOutput(Project project, String targetFolder, Closure expectedOutput) {
|
||||
def root = new FileSystemItem(name: "<root>")
|
||||
initFileSystemItem(root, expectedOutput)
|
||||
root.assertDirectoryEqual(new File(targetFolder), "")
|
||||
}
|
||||
|
||||
def protected buildAll(String projectPath, Map<String, String> pathVariables, Closure initProject) {
|
||||
def binding = new GantBinding()
|
||||
binding.includeTool << Jps
|
||||
ProjectWrapper pw = ProjectWrapper.load(binding, projectPath, null, pathVariables)
|
||||
Project project = pw.getProject()
|
||||
def target = FileUtil.createTempDirectory("targetDir")
|
||||
project.targetFolder = target.absolutePath
|
||||
initProject(project)
|
||||
pw.clean()
|
||||
pw.rebuild()
|
||||
pw.buildArtifacts()
|
||||
pw.deleteTempFiles()
|
||||
return project
|
||||
}
|
||||
|
||||
protected Project loadProject(String projectPath, Map<String, String> pathVariables) {
|
||||
def binding = new GantBinding()
|
||||
binding.includeTool << Jps
|
||||
def project = new Project(binding)
|
||||
IdeaProjectLoader.loadFromPath(project, projectPath, pathVariables, null)
|
||||
return project
|
||||
}
|
||||
|
||||
def initFileSystemItem(FileSystemItem item, Closure initializer) {
|
||||
def meta = new InitializingExpando()
|
||||
meta.dir = {String name, Closure content ->
|
||||
def dir = new FileSystemItem(name: name, directory: true)
|
||||
initFileSystemItem(dir, content)
|
||||
item << dir
|
||||
}
|
||||
meta.archive = {String name, Closure content ->
|
||||
def archive = new FileSystemItem(name: name, archive: true)
|
||||
initFileSystemItem(archive, content)
|
||||
item << archive
|
||||
}
|
||||
meta.file = {Object[] args ->
|
||||
item << new FileSystemItem(name: args[0], content: args.length > 1 ? args[1] : null)
|
||||
}
|
||||
|
||||
initializer.delegate = meta
|
||||
initializer.setResolveStrategy Closure.DELEGATE_FIRST
|
||||
initializer()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user