build scripts simplified: extracted common code from *.gant files, unnecessary *Builder.groovy files removed

This commit is contained in:
nik
2016-09-07 16:49:17 +03:00
parent 3415f72ef3
commit 9a893c338d
3 changed files with 29 additions and 48 deletions
@@ -15,8 +15,13 @@
*/
package org.jetbrains.intellij.build
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.codehaus.gant.GantBinding
import org.jetbrains.intellij.build.impl.BuildTasksImpl
import org.jetbrains.intellij.build.impl.BuildUtils
import org.jetbrains.jps.gant.JpsGantTool
import org.jetbrains.jps.idea.IdeaProjectLoader
/**
* @author nik
@@ -70,4 +75,26 @@ abstract class BuildTasks {
static BuildTasks create(BuildContext context) {
return new BuildTasksImpl(context)
}
/**
* Produces distributions for all operating systems. This method must be invoked from a gant script.
* @param productPropertiesClassName qualified name of a Groovy class which extends {@link ProductProperties} and describes the product.
* The class must have single constructor with single {@code projectHome} parameter of type {@code String}.
* @param groovyRootRelativePaths paths to root folders containing {@code productPropertiesClassName} and required classes, relative to project home
* @param communityHomeRelativePath path to a directory containing sources from idea/community Git repository relative to project home
*/
@CompileDynamic
static void buildProduct(String productPropertiesClassName, List<String> groovyRootRelativePaths, String communityHomeRelativePath, Script gantScript,
ProprietaryBuildTools proprietaryBuildTools = ProprietaryBuildTools.DUMMY) {
String projectHome = IdeaProjectLoader.guessHome(gantScript)
GantBinding binding = (GantBinding)gantScript.binding
groovyRootRelativePaths.each {
BuildUtils.addToClassPath("$projectHome/$it", binding.ant)
}
binding.includeTool << JpsGantTool
ProductProperties productProperties = (ProductProperties) Class.forName(productPropertiesClassName).constructors[0].newInstance(projectHome)
def context = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global,
"$projectHome/$communityHomeRelativePath", projectHome, productProperties, proprietaryBuildTools)
create(context).compileModulesAndBuildDistributions()
}
}
@@ -1,40 +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.
*/
package org.jetbrains.intellij.build.pycharm
import org.codehaus.gant.GantBinding
import org.jetbrains.intellij.build.BuildContext
import org.jetbrains.intellij.build.BuildTasks
/**
* @author nik
*/
class PyCharmCommunityBuilder {
private final GantBinding binding
private final String home
PyCharmCommunityBuilder(String home, GantBinding binding) {
this.home = home
this.binding = binding
}
def build() {
def buildContext = BuildContext.createContext(binding.ant, binding.projectBuilder, binding.project, binding.global,
home, home, new PyCharmCommunityProperties(home))
def buildTasks = BuildTasks.create(buildContext)
buildTasks.compileModulesAndBuildDistributions()
}
}
+2 -8
View File
@@ -1,11 +1,5 @@
import org.jetbrains.intellij.build.impl.BuildUtils
import org.jetbrains.jps.gant.JpsGantTool
import org.jetbrains.jps.idea.IdeaProjectLoader
includeTool << JpsGantTool
import org.jetbrains.intellij.build.BuildTasks
target("default": "Default") {
String home = new File(IdeaProjectLoader.guessHome(this)).absolutePath
BuildUtils.addToClassPath("$home/python/build/groovy", ant)
Class.forName("org.jetbrains.intellij.build.pycharm.PyCharmCommunityBuilder").constructors[0].newInstance(home, binding).build()
BuildTasks.buildProduct("org.jetbrains.intellij.build.pycharm.PyCharmCommunityProperties", ["python/build/groovy"], "", this)
}