mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
build scripts migrated to new JPS
This commit is contained in:
Generated
-11
@@ -1,11 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="JPS">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/build/lib/gant/lib/jps.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$PROJECT_DIR$/build/lib/gant/jps-sources.zip!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
+12
-4
@@ -7,10 +7,18 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Groovy" level="project" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="library" name="JPS" level="project" />
|
||||
<orderEntry type="module" module-name="jps-model-api" />
|
||||
<orderEntry type="library" exported="" name="Groovy" level="project" />
|
||||
<orderEntry type="library" exported="" name="Ant" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="asm4" level="project" />
|
||||
<orderEntry type="library" exported="" scope="RUNTIME" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="JDOM" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Netty" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="protobuf" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Log4J" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="jna" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Trove4j" level="project" />
|
||||
<orderEntry type="module" module-name="jps-model-api" exported="" />
|
||||
<orderEntry type="module" module-name="jps-standalone-builder" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+23
-1
@@ -2,15 +2,37 @@
|
||||
<dirname property="build.dir" file="${ant.file}"/>
|
||||
<property name="project.home" value="${build.dir}/.."/>
|
||||
<property name="gant.home" value="${project.home}/build/lib/gant"/>
|
||||
<property name="idea.lib" value="${project.home}/lib"/>
|
||||
<property name="gant.target" value="default"/>
|
||||
|
||||
<path id="gant.classpath">
|
||||
<fileset dir="${gant.home}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${project.home}/build/lib/jps">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${idea.lib}">
|
||||
<include name="jdom.jar"/>
|
||||
<include name="log4j.jar"/>
|
||||
<include name="trove4j.jar"/>
|
||||
<include name="groovy-all-*.jar"/>
|
||||
<include name="protobuf*.jar"/>
|
||||
<include name="netty*.jar"/>
|
||||
<include name="asm4-all.jar"/>
|
||||
<include name="asm-commons.jar"/>
|
||||
<include name="jgoodies-forms.jar"/>
|
||||
<include name="guava*.jar"/>
|
||||
<include name="picocontainer.jar"/>
|
||||
<include name="jna.jar"/>
|
||||
<include name="jna-utils.jar"/>
|
||||
<include name="oromatcher.jar"/>
|
||||
<include name="cli-parser-*.jar"/>
|
||||
<include name="nanoxml-*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<taskdef name="gant" classname="org.codehaus.gant.ant.Gant">
|
||||
<taskdef name="gant" classname="org.jetbrains.jps.gant.GantWithClasspathTask">
|
||||
<classpath refid="gant.classpath"/>
|
||||
</taskdef>
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
The source code for JPS, JetBrains' Gant-based build system used for
|
||||
building IntelliJ, can be found on GitHub:
|
||||
|
||||
http://github.com/JetBrains/JPS
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,9 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.jetbrains.jps.ClasspathKind
|
||||
import org.jetbrains.jps.Library
|
||||
import org.jetbrains.jps.Module
|
||||
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.library.JpsOrderRootType
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
|
||||
class LibraryLicense {
|
||||
String name, url, version
|
||||
@@ -44,27 +46,25 @@ binding.setVariable("jetbrainsLibrary", {String name ->
|
||||
jetbrainsLibraries << name
|
||||
})
|
||||
|
||||
def String getLibraryName(Library lib) {
|
||||
def String getLibraryName(JpsLibrary lib) {
|
||||
def name = lib.name
|
||||
if (name.startsWith("moduleLibrary#")) {
|
||||
if (lib.classpath.size() != 1) {
|
||||
if (name.startsWith("#")) {
|
||||
if (lib.getRoots(JpsOrderRootType.COMPILED).size() != 1) {
|
||||
projectBuilder.warning("Non-single entry module library $name: $lib.classpath");
|
||||
}
|
||||
String filePath = lib.classpath[0]
|
||||
return filePath.substring(filePath.lastIndexOf('/')+1)
|
||||
File file = lib.getFiles(JpsOrderRootType.COMPILED)[0]
|
||||
return file.name
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
binding.setVariable("checkLibLicenses", {
|
||||
def libraries = new HashSet<Library>()
|
||||
def lib2Module = new HashMap<Library, Module>();
|
||||
allModules().each {Module module ->
|
||||
module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {
|
||||
if (it instanceof Library) {
|
||||
lib2Module[it] = module
|
||||
libraries << it
|
||||
}
|
||||
def libraries = new HashSet<JpsLibrary>()
|
||||
def lib2Module = new HashMap<JpsLibrary, JpsModule>();
|
||||
allModules().each {JpsModule module ->
|
||||
JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).getLibraries().each {
|
||||
lib2Module[it] = module
|
||||
libraries << it
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ binding.setVariable("checkLibLicenses", {
|
||||
libWithLicenses.addAll(jetbrainsLibraries)
|
||||
|
||||
List<String> withoutLicenses = []
|
||||
libraries.each {Library lib ->
|
||||
libraries.each {JpsLibrary lib ->
|
||||
def name = getLibraryName(lib)
|
||||
if (!libWithLicenses.contains(name)) {
|
||||
withoutLicenses << "$name (used in module ${lib2Module[lib].name})".toString()
|
||||
@@ -94,13 +94,11 @@ binding.setVariable("checkLibLicenses", {
|
||||
binding.setVariable("generateLicensesTable", {String filePath, Set<String> usedModulesNames ->
|
||||
projectBuilder.info("Generating licenses table")
|
||||
projectBuilder.info("Used modules: $usedModulesNames")
|
||||
Set<Module> usedModules = allModules().findAll {usedModulesNames.contains(it.name)}
|
||||
Set<JpsModule> usedModules = allModules().findAll {usedModulesNames.contains(it.name)}
|
||||
Map<String, String> usedLibraries = [:]
|
||||
usedModules.each {Module module ->
|
||||
module.getClasspath(ClasspathKind.PRODUCTION_RUNTIME).each {item ->
|
||||
if (item instanceof Library) {
|
||||
usedLibraries[getLibraryName(item)] = module.name
|
||||
}
|
||||
usedModules.each {JpsModule module ->
|
||||
JpsJavaExtensionService.dependencies(module).includedIn(JpsJavaClasspathKind.PRODUCTION_RUNTIME).getLibraries().each {item ->
|
||||
usedLibraries[getLibraryName(item)] = module.name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-11
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.jetbrains.jps.Jps
|
||||
import org.jetbrains.jps.Module
|
||||
import org.jetbrains.jps.idea.IdeaProjectLoader
|
||||
import org.jetbrains.jps.gant.JpsGantTool
|
||||
import org.jetbrains.jps.gant.TeamCityBuildInfoPrinter
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
|
||||
includeTool << Jps
|
||||
includeTool << JpsGantTool
|
||||
|
||||
binding.setVariable("p", {String key ->
|
||||
return getProperty(key) as String
|
||||
@@ -122,23 +123,24 @@ binding.setVariable("loadProject", {
|
||||
classpath "$jdkHome/lib/tools.jar"
|
||||
}
|
||||
}
|
||||
IdeaProjectLoader.loadFromPath(project, "${home}")
|
||||
projectBuilder.dataStorageRoot = new File("$home/.jps-build-data")
|
||||
loadProjectFromPath(home)
|
||||
})
|
||||
|
||||
boolean hasSourceRoots(Module module) {
|
||||
return !module.sourceRoots.isEmpty()
|
||||
boolean hasSourceRoots(JpsModule module) {
|
||||
return module.getSourceRoots(JavaSourceRootType.SOURCE).iterator().hasNext()
|
||||
}
|
||||
|
||||
binding.setVariable("findModule", {String name ->
|
||||
project.modules[name]
|
||||
project.modules.find { it.name == name }
|
||||
})
|
||||
|
||||
binding.setVariable("allModules", {
|
||||
return project.modules.values()
|
||||
return project.modules
|
||||
})
|
||||
|
||||
binding.setVariable("printUnusedModules", {Set<String> usedModules ->
|
||||
allModules().each {Module m ->
|
||||
allModules().each {JpsModule m ->
|
||||
if (!usedModules.contains(m.name) && hasSourceRoots(m)) {
|
||||
projectBuilder.warning("Module $m.name is not used in project layout")
|
||||
}
|
||||
@@ -158,7 +160,7 @@ String readSnapshotBuild() {
|
||||
|
||||
binding.setVariable("snapshot", readSnapshotBuild())
|
||||
|
||||
projectBuilder.buildInfoPrinter = new org.jetbrains.jps.teamcity.TeamcityBuildInfoPrinter()
|
||||
projectBuilder.buildInfoPrinter = new TeamCityBuildInfoPrinter()
|
||||
projectBuilder.compressJars = false
|
||||
|
||||
binding.setVariable("notifyArtifactBuilt", { String artifactPath ->
|
||||
|
||||
@@ -36,9 +36,6 @@
|
||||
<fileset dir="${project.home}/lib/ant/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${gant.home}/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
|
||||
<arg value="-f"/>
|
||||
|
||||
@@ -91,13 +91,12 @@ public class CompileScopeImpl extends CompileScope {
|
||||
}
|
||||
|
||||
private boolean isAffectedByAssociatedModule(BuildTarget<?> target) {
|
||||
final JpsModule module = target instanceof ModuleBasedTarget ? ((ModuleBasedTarget)target).getModule() : null;
|
||||
if (module != null) {
|
||||
if (target instanceof ModuleBasedTarget) {
|
||||
final JpsModule module = ((ModuleBasedTarget)target).getModule();
|
||||
// this target is associated with module
|
||||
for (JavaModuleBuildTargetType moduleType : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
if (myTypes.contains(moduleType) || myTargets.contains(new ModuleBuildTarget(module, moduleType))) {
|
||||
return true;
|
||||
}
|
||||
JavaModuleBuildTargetType targetType = JavaModuleBuildTargetType.getInstance(((ModuleBasedTarget)target).isTests());
|
||||
if (myTypes.contains(targetType) || myTargets.contains(new ModuleBuildTarget(module, targetType))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
<orderEntry type="library" name="Groovy" level="project" />
|
||||
<orderEntry type="module" module-name="jps-builders" />
|
||||
<orderEntry type="module" module-name="jps-model-api" />
|
||||
<orderEntry type="library" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="module" module-name="jps-model-serialization" />
|
||||
<orderEntry type="module-library" scope="PROVIDED">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../lib/gant-1.9.5_groovy-1.7.10.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/../../build/lib/gant/lib/gant_groovy2.0-1.9.8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" name="Ant" level="project" />
|
||||
<orderEntry type="module" module-name="jps-model-serialization" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -168,13 +168,20 @@ public class Standalone {
|
||||
}
|
||||
}
|
||||
if (!artifactsList.isEmpty()) {
|
||||
scopes.add(TargetTypeBuildScope.newBuilder().setTypeId(ArtifactBuildTargetType.INSTANCE.getTypeId()).setForceBuild(forceBuild).addAllTargetId(artifactsList).build());
|
||||
scopes.add(TargetTypeBuildScope.newBuilder().setTypeId(ArtifactBuildTargetType.INSTANCE.getTypeId())
|
||||
.setForceBuild(forceBuild).addAllTargetId(artifactsList).build());
|
||||
}
|
||||
|
||||
final BuildRunner buildRunner = new BuildRunner(loader, Collections.<String>emptyList(), Collections.<String, String>emptyMap());
|
||||
runBuild(loader, dataStorageRoot, messageHandler, scopes, true);
|
||||
}
|
||||
|
||||
public static void runBuild(JpsModelLoader loader, File dataStorageRoot, MessageHandler messageHandler, List<TargetTypeBuildScope> scopes,
|
||||
boolean includeDependenciesToScope) throws Exception {
|
||||
final BuildRunner buildRunner = new BuildRunner(loader, Collections.<String>emptyList(), Collections.<String, String>emptyMap()
|
||||
);
|
||||
ProjectDescriptor descriptor = buildRunner.load(messageHandler, dataStorageRoot, new BuildFSState(true));
|
||||
try {
|
||||
buildRunner.runBuild(descriptor, CanceledStatus.NULL, null, messageHandler, BuildType.BUILD, scopes, true);
|
||||
buildRunner.runBuild(descriptor, CanceledStatus.NULL, null, messageHandler, BuildType.BUILD, scopes, includeDependenciesToScope);
|
||||
}
|
||||
finally {
|
||||
descriptor.release();
|
||||
|
||||
@@ -20,11 +20,17 @@ package org.jetbrains.jps.gant;
|
||||
*/
|
||||
public interface BuildInfoPrinter {
|
||||
|
||||
void printProgressMessage(JpsGantProjectBuilder project, String message);
|
||||
void printProgressMessage(JpsGantProjectBuilder builder, String message);
|
||||
|
||||
void printCompilationErrors(JpsGantProjectBuilder project, String compilerName, String messages);
|
||||
void printBlockOpenedMessage(JpsGantProjectBuilder builder, String blockId);
|
||||
|
||||
void printCompilationFinish(JpsGantProjectBuilder project, String compilerName);
|
||||
void printBlockClosedMessage(JpsGantProjectBuilder builder, String blockId);
|
||||
|
||||
void printCompilationStart(JpsGantProjectBuilder project, String compilerName);
|
||||
void printStatisticsMessage(JpsGantProjectBuilder builder, String key, String value);
|
||||
|
||||
void printCompilationErrors(JpsGantProjectBuilder builder, String compilerName, String messages);
|
||||
|
||||
void printCompilationFinish(JpsGantProjectBuilder builder, String compilerName);
|
||||
|
||||
void printCompilationStart(JpsGantProjectBuilder builder, String compilerName);
|
||||
}
|
||||
|
||||
@@ -20,20 +20,33 @@ package org.jetbrains.jps.gant;
|
||||
*/
|
||||
public class DefaultBuildInfoPrinter implements BuildInfoPrinter {
|
||||
@Override
|
||||
public void printProgressMessage(JpsGantProjectBuilder project, String message) {
|
||||
project.info(message);
|
||||
public void printProgressMessage(JpsGantProjectBuilder builder, String message) {
|
||||
builder.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationErrors(JpsGantProjectBuilder project, String compilerName, String messages) {
|
||||
project.error(messages);
|
||||
public void printBlockOpenedMessage(JpsGantProjectBuilder builder, String blockId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationFinish(JpsGantProjectBuilder project, String compilerName) {
|
||||
public void printBlockClosedMessage(JpsGantProjectBuilder builder, String blockId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationStart(JpsGantProjectBuilder project, String compilerName) {
|
||||
public void printStatisticsMessage(JpsGantProjectBuilder builder, String key, String value) {
|
||||
builder.info("Build statistics: " + key + " = " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationErrors(JpsGantProjectBuilder builder, String compilerName, String messages) {
|
||||
builder.error(messages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationFinish(JpsGantProjectBuilder builder, String compilerName) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationStart(JpsGantProjectBuilder builder, String compilerName) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.jps.gant;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.codehaus.gant.ant.Gant;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class GantWithClasspathTask extends Gant {
|
||||
@Override
|
||||
public void execute() throws BuildException {
|
||||
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
ClassLoader loader = getClass().getClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(loader);
|
||||
try {
|
||||
Field field = Gant.class.getDeclaredField("file");
|
||||
field.setAccessible(true);
|
||||
getProject().log("Starting gant script " + field.get(this));
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
super.execute();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(oldLoader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,20 @@ package org.jetbrains.jps.gant;
|
||||
import com.intellij.openapi.diagnostic.DefaultLogger;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.build.Standalone;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.cmdline.JpsModelLoader;
|
||||
import org.jetbrains.jps.incremental.MessageHandler;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.BuildingTargetProgressMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
|
||||
@@ -37,6 +42,8 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
@@ -48,6 +55,9 @@ public class JpsGantProjectBuilder {
|
||||
private JpsModelLoader myModelLoader;
|
||||
private boolean myDryRun;
|
||||
private BuildInfoPrinter myBuildInfoPrinter = new DefaultBuildInfoPrinter();
|
||||
private Set<String> myCompiledModules = new HashSet<String>();
|
||||
private Set<String> myCompiledModuleTests = new HashSet<String>();
|
||||
private boolean myStatisticsReported;
|
||||
|
||||
public JpsGantProjectBuilder(Project project, JpsModel model) {
|
||||
myProject = project;
|
||||
@@ -67,6 +77,7 @@ public class JpsGantProjectBuilder {
|
||||
public void setTargetFolder(String targetFolder) {
|
||||
String url = "file://" + FileUtil.toSystemIndependentName(targetFolder);
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myModel.getProject()).setOutputUrl(url);
|
||||
exportModuleOutputProperties();
|
||||
}
|
||||
|
||||
public boolean isCompressJars() {
|
||||
@@ -131,12 +142,28 @@ public class JpsGantProjectBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
myCompiledModules.clear();
|
||||
myCompiledModuleTests.clear();
|
||||
}
|
||||
|
||||
public void makeModule(JpsModule module) {
|
||||
runBuild(getModuleDependencies(module, false), false, false);
|
||||
}
|
||||
|
||||
public void buildModules(List<JpsModule> modules) {
|
||||
Set<String> names = new LinkedHashSet<String>();
|
||||
info("Collecting dependencies for " + modules.size() + " modules");
|
||||
for (JpsModule module : modules) {
|
||||
Set<String> dependencies = getModuleDependencies(module, false);
|
||||
for (String dependency : dependencies) {
|
||||
if (names.add(dependency)) {
|
||||
info(" adding " + dependency + " required for " + module.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
runBuild(names, false, false);
|
||||
}
|
||||
|
||||
public void makeModuleTests(JpsModule module) {
|
||||
runBuild(getModuleDependencies(module, true), false, true);
|
||||
}
|
||||
@@ -152,16 +179,21 @@ public class JpsGantProjectBuilder {
|
||||
public void exportModuleOutputProperties() {
|
||||
for (JpsModule module : myModel.getProject().getModules()) {
|
||||
for (boolean test : new boolean[]{true, false}) {
|
||||
myProject.setProperty("module." + module.getName() + ".output." + (test ? "test" : "main"), getModuleOutput(module, test));
|
||||
String propertyName = "module." + module.getName() + ".output." + (test ? "test" : "main");
|
||||
String outputPath = getModuleOutput(module, test);
|
||||
myProject.setProperty(propertyName, outputPath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Set<String> getModuleDependencies(JpsModule module, boolean includeTests) {
|
||||
Set<JpsModule> modules = JpsJavaExtensionService.dependencies(module).recursively().includedIn(JpsJavaClasspathKind.compile(includeTests)).getModules();
|
||||
JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module).recursively();
|
||||
if (!includeTests) {
|
||||
enumerator = enumerator.productionOnly();
|
||||
}
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (JpsModule depModule : modules) {
|
||||
for (JpsModule depModule : enumerator.getModules()) {
|
||||
names.add(depModule.getName());
|
||||
}
|
||||
return names;
|
||||
@@ -171,10 +203,40 @@ public class JpsGantProjectBuilder {
|
||||
if (!myDryRun) {
|
||||
final AntMessageHandler messageHandler = new AntMessageHandler();
|
||||
Logger.setFactory(new AntLoggerFactory(messageHandler));
|
||||
info("Starting build: modules = " + modulesSet + ", caches are saved to " + myDataStorageRoot.getAbsolutePath());
|
||||
boolean forceBuild = true;
|
||||
|
||||
List<TargetTypeBuildScope> scopes = new ArrayList<TargetTypeBuildScope>();
|
||||
for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
if (includeTests || !type.isTests()) {
|
||||
List<String> namesToCompile = new ArrayList<String>(allModules ? getAllModules() : modulesSet);
|
||||
if (type.isTests()) {
|
||||
namesToCompile.removeAll(myCompiledModuleTests);
|
||||
myCompiledModuleTests.addAll(namesToCompile);
|
||||
}
|
||||
else {
|
||||
namesToCompile.removeAll(myCompiledModules);
|
||||
myCompiledModules.addAll(namesToCompile);
|
||||
}
|
||||
if (namesToCompile.isEmpty()) continue;
|
||||
|
||||
TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(type.getTypeId()).setForceBuild(forceBuild);
|
||||
if (allModules) {
|
||||
scopes.add(builder.setAllTargets(true).build());
|
||||
}
|
||||
else if (!modulesSet.isEmpty()) {
|
||||
scopes.add(builder.addAllTargetId(modulesSet).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info("Starting build; cache directory: " + myDataStorageRoot.getAbsolutePath());
|
||||
try {
|
||||
Standalone.runBuild(myModelLoader, myDataStorageRoot, true, modulesSet, allModules, Collections.<String>emptyList(), includeTests,
|
||||
messageHandler);
|
||||
long compilationStart = System.currentTimeMillis();
|
||||
Standalone.runBuild(myModelLoader, myDataStorageRoot, messageHandler, scopes, false);
|
||||
if (!myStatisticsReported) {
|
||||
myBuildInfoPrinter.printStatisticsMessage(this, "Compilation time, ms", String.valueOf(System.currentTimeMillis() - compilationStart));
|
||||
myStatisticsReported = true;
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {
|
||||
error(e);
|
||||
@@ -185,6 +247,14 @@ public class JpsGantProjectBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getAllModules() {
|
||||
HashSet<String> modules = new HashSet<String>();
|
||||
for (JpsModule module : myModel.getProject().getModules()) {
|
||||
modules.add(module.getName());
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
public String moduleOutput(JpsModule module) {
|
||||
return getModuleOutput(module, false);
|
||||
}
|
||||
@@ -217,6 +287,7 @@ public class JpsGantProjectBuilder {
|
||||
case ERROR:
|
||||
String compilerName = msg instanceof CompilerMessage ? ((CompilerMessage)msg).getCompilerName() : "";
|
||||
myBuildInfoPrinter.printCompilationErrors(JpsGantProjectBuilder.this, compilerName, text);
|
||||
error("Compilation failed");
|
||||
break;
|
||||
case WARNING:
|
||||
warning(text);
|
||||
@@ -227,7 +298,24 @@ public class JpsGantProjectBuilder {
|
||||
}
|
||||
break;
|
||||
case PROGRESS:
|
||||
myBuildInfoPrinter.printProgressMessage(JpsGantProjectBuilder.this, text);
|
||||
if (msg instanceof BuildingTargetProgressMessage) {
|
||||
String targetsString = StringUtil.join(((BuildingTargetProgressMessage)msg).getTargets(),
|
||||
new NotNullFunction<BuildTarget<?>, String>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public String fun(BuildTarget<?> dom) {
|
||||
return dom.getPresentableName();
|
||||
}
|
||||
}, ",");
|
||||
switch (((BuildingTargetProgressMessage)msg).getEventType()) {
|
||||
case STARTED:
|
||||
myBuildInfoPrinter.printBlockOpenedMessage(JpsGantProjectBuilder.this, targetsString);
|
||||
break;
|
||||
case FINISHED:
|
||||
myBuildInfoPrinter.printBlockClosedMessage(JpsGantProjectBuilder.this, targetsString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,16 +93,18 @@ final class JpsGantTool {
|
||||
return layoutInfo
|
||||
})
|
||||
|
||||
binding.ant.taskdef(name: "layout", classname: "jetbrains.antlayout.tasks.LayoutTask")
|
||||
def contextLoaderRef = "GANT_CONTEXT_CLASS_LOADER";
|
||||
binding.ant.project.addReference(contextLoaderRef, Thread.currentThread().contextClassLoader)
|
||||
binding.ant.taskdef(name: "layout", loaderRef: contextLoaderRef, classname: "jetbrains.antlayout.tasks.LayoutTask")
|
||||
}
|
||||
|
||||
private void loadProject(String path, JpsModel model, JpsGantProjectBuilder builder) {
|
||||
JpsProjectLoader.loadProject(model.project, [:], path)
|
||||
builder.exportModuleOutputProperties();
|
||||
if (builder.getDataStorageRoot() == null) {
|
||||
builder.setDataStorageRoot(Utils.getDataStorageRoot(path))
|
||||
}
|
||||
builder.info("Loaded project " + path + ": " + model.getProject().getModules().size() + " modules, " + model.getProject().getLibraryCollection().getLibraries().size() + " libraries")
|
||||
builder.exportModuleOutputProperties()
|
||||
}
|
||||
|
||||
private void createJavaSdk(JpsGlobal global, String name, String homePath, Closure initializer) {
|
||||
|
||||
@@ -50,27 +50,42 @@ public class TeamCityBuildInfoPrinter implements BuildInfoPrinter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printProgressMessage(JpsGantProjectBuilder project, String message) {
|
||||
public void printProgressMessage(JpsGantProjectBuilder builder, String message) {
|
||||
String escapedMessage = escape(message);
|
||||
project.info("##teamcity[progressMessage '" + escapedMessage + "']");
|
||||
builder.info("##teamcity[progressMessage '" + escapedMessage + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationErrors(JpsGantProjectBuilder project, String compilerName, String messages) {
|
||||
public void printBlockOpenedMessage(JpsGantProjectBuilder builder, String blockId) {
|
||||
builder.info("##teamcity[blockOpened name='" + escape(blockId) + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printBlockClosedMessage(JpsGantProjectBuilder builder, String blockId) {
|
||||
builder.info("##teamcity[blockClosed name='" + escape(blockId) + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStatisticsMessage(JpsGantProjectBuilder builder, String key, String value) {
|
||||
builder.info("##teamcity[buildStatisticValue key='" + escape(key) + "' value='" + escape(value) + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationErrors(JpsGantProjectBuilder builder, String compilerName, String messages) {
|
||||
String escapedCompiler = escape(compilerName);
|
||||
String escapedOutput = escape(messages);
|
||||
project.info("##teamcity[compilationStarted compiler='" + escapedCompiler + "']");
|
||||
project.info("##teamcity[message text='" + escapedOutput + "' status='ERROR']");
|
||||
project.info("##teamcity[compilationFinished compiler='" + escapedCompiler + "']");
|
||||
builder.info("##teamcity[compilationStarted compiler='" + escapedCompiler + "']");
|
||||
builder.info("##teamcity[message text='" + escapedOutput + "' status='ERROR']");
|
||||
builder.info("##teamcity[compilationFinished compiler='" + escapedCompiler + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationStart(JpsGantProjectBuilder project, String compilerName) {
|
||||
project.info("##teamcity[compilationStarted compiler='" + escape(compilerName) + "']");
|
||||
public void printCompilationStart(JpsGantProjectBuilder builder, String compilerName) {
|
||||
builder.info("##teamcity[compilationStarted compiler='" + escape(compilerName) + "']");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printCompilationFinish(JpsGantProjectBuilder project, String compilerName) {
|
||||
project.info("##teamcity[compilationFinished compiler='" + escape(compilerName) + "']");
|
||||
public void printCompilationFinish(JpsGantProjectBuilder builder, String compilerName) {
|
||||
builder.info("##teamcity[compilationFinished compiler='" + escape(compilerName) + "']");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user