build scripts: code which builds standalone-jps artifact rewritten

Now it uses statically-typed LayoutBuilder instead of dynamic gant code.
This commit is contained in:
nik
2017-03-17 17:30:06 +03:00
parent 8a00e087a4
commit d8162aa3d9
6 changed files with 146 additions and 125 deletions
@@ -0,0 +1,128 @@
/*
* Copyright 2000-2017 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.intellij.build
import org.jetbrains.intellij.build.impl.LayoutBuilder
/**
* Creates JARs containing classes required to run the external build for IDEA project without IDE.
*
* @author nik
*/
class CommunityStandaloneJpsBuilder {
private final BuildContext buildContext
CommunityStandaloneJpsBuilder(BuildContext buildContext) {
this.buildContext = buildContext
}
void layoutJps(String targetDir, String buildNumber, @DelegatesTo(LayoutBuilder.LayoutSpec) Closure additionalJars) {
AntBuilder ant = buildContext.ant
String home = buildContext.paths.communityHome
new LayoutBuilder(ant, buildContext.project, false).layout(targetDir) {
zip("standalone-jps-${buildNumber}.zip") {
jar("util.jar") {
module("annotations-common")
module("annotations")
module("util-rt")
module("util")
}
jar("jps-launcher.jar") {
module("jps-launcher")
}
jar("jps-model.jar") {
module("jps-model-api")
module("jps-model-impl")
module("jps-model-serialization")
}
jar("jps-builders.jar") {
module("forms_rt")
module("forms-compiler")
module("instrumentation-util")
module("instrumentation-util-8")
module("javac-ref-scanner-8")
module("jps-builders")
module("jps-standalone-builder")
}
jar("idea_rt.jar") {
module("java-runtime")
}
jar("jps-builders-6.jar") {
module("jps-builders-6")
}
//layout of groovy jars must be consistent with GroovyBuilder.getGroovyRtRoots method
jar("groovy-jps-plugin.jar") {
module("groovy-jps-plugin")
}
jar("groovy_rt.jar") {
module("groovy_rt")
}
jar("groovy-rt-constants.jar") {
module("groovy-rt-constants")
}
jar("ui-designer-jps-plugin.jar") { module("ui-designer-jps-plugin") }
jar("maven-jps-plugin.jar") { module("maven-jps-plugin") }
jar("aether-dependency-resolver.jar") { module("aether-dependency-resolver") }
ant.fileset(dir: "$home/plugins/maven/lib") {
include(name: "aether-*.jar")
include(name: "maven-aether-provider-*.jar")
}
jar("gradle-jps-plugin.jar") { module("gradle-jps-plugin") }
ant.fileset(dir: "$home/plugins/maven/maven30-server-impl/lib/maven3/lib") { include(name: "plexus-utils-*.jar") }
jar("eclipse-jps-plugin.jar") {
module("common-eclipse-util")
module("eclipse-jps-plugin")
}
jar("devkit-jps-plugin.jar") { module("devkit-jps-plugin") }
jar("intellilang-jps-plugin.jar") { module("intellilang-jps-plugin") }
ant.fileset(dir: "$home/lib") {
include(name: "jdom.jar")
include(name: "jna.jar")
include(name: "jna-platform.jar")
include(name: "oromatcher.jar")
include(name: "trove4j.jar")
include(name: "asm-all.jar")
include(name: "nanoxml-*.jar")
include(name: "protobuf-*.jar")
include(name: "cli-parser-*.jar")
include(name: "log4j.jar")
include(name: "jgoodies-forms.jar")
include(name: "ecj*.jar")
include(name: "netty-all-*.jar")
include(name: "snappy-in-java-*.jar")
include(name: "xercesImpl.jar")
include(name: "xml-apis.jar")
}
ant.fileset(dir: "$home/jps/lib") {
include(name: "optimizedFileManager.jar")
}
jar("ant-jps-plugin.jar") { module("ant-jps-plugin") }
include(additionalJars)
}
jar("jps-build-test-${buildNumber}.jar") {
moduleTests("jps-builders")
moduleTests("jps-model-tests")
moduleTests("jps-serialization-tests")
}
}
buildContext.notifyArtifactBuilt(targetDir)
}
}
@@ -48,13 +48,16 @@ class IdeaCommunityBuilder {
void buildDistJars() {
BuildTasks.create(buildContext).buildDistributions()
layoutAdditionalArtifacts()
layoutCoreArtifacts()
}
void buildDistributions() {
def tasks = BuildTasks.create(buildContext)
tasks.buildDistributions()
layoutAdditionalArtifacts(true)
buildContext.messages.block("Build standalone JPS") {
String jpsArtifactDir = "$buildContext.paths.artifacts/jps"
new CommunityStandaloneJpsBuilder(buildContext).layoutJps(jpsArtifactDir, buildContext.fullBuildNumber, {})
}
tasks.buildUpdaterJar()
}
@@ -62,15 +65,7 @@ class IdeaCommunityBuilder {
BuildTasks.create(buildContext).buildUnpackedDistribution(targetDirectory)
}
void layoutAdditionalArtifacts(boolean buildJps = false) {
def layouts = binding["includeFile"]("$buildContext.paths.communityHome/build/scripts/layouts.gant")
void layoutCoreArtifacts() {
new IntelliJCoreArtifactsBuilder(buildContext).layoutIntelliJCore()
if (buildJps) {
buildContext.messages.block("Build standalone JPS") {
String jpsArtifactDir = "$buildContext.paths.artifacts/jps"
layouts.layoutJps(buildContext.paths.communityHome, jpsArtifactDir, buildContext.fullBuildNumber, {})
buildContext.notifyArtifactBuilt(jpsArtifactDir)
}
}
}
}
-112
View File
@@ -1,112 +0,0 @@
/*
* Copyright 2000-2016 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.
*/
import static org.jetbrains.jps.idea.IdeaProjectLoader.guessHome
includeTargets << new File("${guessHome(this)}/build/scripts/utils.gant")
def layoutJps(String home, String targetDir, String buildNumber, Closure additionalJars) {
layout(targetDir) {
zip("standalone-jps-${buildNumber}.zip") {
jar("util.jar") {
module("annotations-common")
module("annotations")
module("util-rt")
module("util")
}
jar("jps-launcher.jar") {
module("jps-launcher")
}
jar("jps-model.jar") {
module("jps-model-api")
module("jps-model-impl")
module("jps-model-serialization")
}
jar("jps-builders.jar") {
module("forms_rt")
module("forms-compiler")
module("instrumentation-util")
module("instrumentation-util-8")
module("javac-ref-scanner-8")
module("jps-builders")
module("jps-standalone-builder")
}
jar("idea_rt.jar") {
module("java-runtime")
}
jar("jps-builders-6.jar") {
module("jps-builders-6")
}
//layout of groovy jars must be consistent with GroovyBuilder.getGroovyRtRoots method
jar("groovy-jps-plugin.jar") {
module("groovy-jps-plugin")
}
jar("groovy_rt.jar") {
module("groovy_rt")
}
jar("groovy-rt-constants.jar") {
module("groovy-rt-constants")
}
jar("ui-designer-jps-plugin.jar") { module("ui-designer-jps-plugin") }
jar("maven-jps-plugin.jar") { module("maven-jps-plugin") }
jar("aether-dependency-resolver.jar") { module("aether-dependency-resolver") }
fileset(dir: "$home/plugins/maven/lib") {
include(name: "aether-*.jar")
include(name: "maven-aether-provider-*.jar")
}
jar("gradle-jps-plugin.jar") { module("gradle-jps-plugin") }
fileset(dir: "$home/plugins/maven/maven30-server-impl/lib/maven3/lib") {include(name: "plexus-utils-*.jar")}
jar("eclipse-jps-plugin.jar") {
module("common-eclipse-util")
module("eclipse-jps-plugin")
}
jar("devkit-jps-plugin.jar") { module("devkit-jps-plugin") }
jar("intellilang-jps-plugin.jar") { module("intellilang-jps-plugin") }
fileset(dir: "$home/lib") {
include(name: "jdom.jar")
include(name: "jna.jar")
include(name: "jna-platform.jar")
include(name: "oromatcher.jar")
include(name: "trove4j.jar")
include(name: "asm-all.jar")
include(name: "nanoxml-*.jar")
include(name: "protobuf-*.jar")
include(name: "cli-parser-*.jar")
include(name: "log4j.jar")
include(name: "jgoodies-forms.jar")
include(name: "ecj*.jar")
include(name: "netty-all-*.jar")
include(name: "snappy-in-java-*.jar")
include(name: "xercesImpl.jar")
include(name: "xml-apis.jar")
}
fileset(dir: "$home/jps/lib") {
include(name: "optimizedFileManager.jar")
}
jar("ant-jps-plugin.jar") { module("ant-jps-plugin") }
additionalJars()
}
jar("jps-build-test-${buildNumber}.jar") {
moduleTests("jps-builders")
moduleTests("jps-model-tests")
moduleTests("jps-serialization-tests")
}
}
}
@@ -72,7 +72,7 @@ public class ClasspathBootstrap {
cp.addAll(getInstrumentationUtilRoots());
cp.add(getResourcePath(IXMLBuilder.class)); // nano-xml
cp.addAll(getJavac8RefScannerClasspath());
//don't forget to update layoutCommunityJps() in layouts.gant accordingly
//don't forget to update CommunityStandaloneJpsBuilder.layoutJps accordingly
try {
final Class<?> cmdLineWrapper = Class.forName("com.intellij.rt.execution.CommandLineWrapper");
@@ -184,6 +184,15 @@ class LayoutBuilder {
}
}
/**
* Include files and directories specified in {@code inner} into the current place in this layout
*/
def include(@DelegatesTo(LayoutSpec) Closure inner) {
def body = inner.rehydrate(null, this, inner.thisObject)
body.resolveStrategy = Closure.OWNER_FIRST
body()
}
JpsModule findModule(String name) {
def module = project.modules.find { it.name == name }
if (module == null) {
@@ -19,6 +19,7 @@
<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="antlayout" />
<orderEntry type="module" module-name="jps-model-api" exported="" />
<orderEntry type="module" module-name="jps-standalone-builder" exported="" />
<orderEntry type="module" module-name="util" exported="" />
@@ -35,6 +36,6 @@
</library>
</orderEntry>
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" scope="TEST" name="JUnit4" level="project"/>
<orderEntry type="library" scope="TEST" name="JUnit4" level="project" />
</component>
</module>