mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build scripts: add kotlin compiler jars to classpath inside the script to allow developers run gant build scripts directly from IDEA
This commit is contained in:
@@ -388,6 +388,8 @@ idea.fatal.error.notification=disabled
|
||||
return
|
||||
}
|
||||
|
||||
ensureKotlinCompilerAddedToClassPath()
|
||||
|
||||
buildContext.projectBuilder.cleanOutput()
|
||||
if (moduleNames == null) {
|
||||
buildContext.projectBuilder.buildProduction()
|
||||
@@ -406,6 +408,24 @@ idea.fatal.error.notification=disabled
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureKotlinCompilerAddedToClassPath() {
|
||||
try {
|
||||
Class.forName("org.jetbrains.kotlin.jps.build.KotlinBuilder")
|
||||
return
|
||||
}
|
||||
catch (ClassNotFoundException ignored) {}
|
||||
|
||||
def kotlinPluginLibPath = "$buildContext.paths.communityHome/build/kotlinc/plugin/Kotlin/lib"
|
||||
if (new File(kotlinPluginLibPath).exists()) {
|
||||
["jps/kotlin-jps-plugin.jar", "kotlin-plugin.jar", "kotlin-runtime.jar"].each {
|
||||
BuildUtils.addToJpsClassPath("$kotlinPluginLibPath/$it", buildContext.ant)
|
||||
}
|
||||
}
|
||||
else {
|
||||
buildContext.messages.error("Could not find Kotlin JARs at $kotlinPluginLibPath: run download_kotlin.gant script to download them")
|
||||
}
|
||||
}
|
||||
|
||||
private void runInParallel(List<BuildTaskRunnable> tasks) {
|
||||
if (!buildContext.options.runBuildStepsInParallel) {
|
||||
tasks.each {
|
||||
|
||||
@@ -18,9 +18,10 @@ package org.jetbrains.intellij.build.impl
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import groovy.transform.CompileStatic
|
||||
import org.apache.tools.ant.BuildException
|
||||
import org.apache.tools.ant.Main
|
||||
import org.apache.tools.ant.Project
|
||||
import org.codehaus.gant.GantBinding
|
||||
import org.codehaus.groovy.tools.RootLoader
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -28,13 +29,29 @@ import org.codehaus.gant.GantBinding
|
||||
@CompileStatic
|
||||
class BuildUtils {
|
||||
static void addToClassPath(String path, AntBuilder ant) {
|
||||
def classLoader = (GroovyClassLoader)BuildUtils.class.classLoader
|
||||
addToClassLoaderClassPath(path, ant, BuildUtils.class.classLoader)
|
||||
}
|
||||
|
||||
static void addToJpsClassPath(String path, AntBuilder ant) {
|
||||
//we need to add path to classloader of BuilderService to ensure that classes from that path will be returned by JpsServiceManager.getExtensions
|
||||
addToClassLoaderClassPath(path, ant, Class.forName("org.jetbrains.jps.incremental.BuilderService").classLoader)
|
||||
}
|
||||
|
||||
private static void addToClassLoaderClassPath(String path, AntBuilder ant, ClassLoader classLoader) {
|
||||
if (new File(path).exists()) {
|
||||
if (classLoader instanceof GroovyClassLoader) {
|
||||
classLoader.addClasspath(path)
|
||||
}
|
||||
else if (classLoader instanceof RootLoader) {
|
||||
classLoader.addURL(new File(path).toURI().toURL())
|
||||
}
|
||||
else {
|
||||
throw new BuildException("Cannot add to classpath: non-groovy classloader $classLoader")
|
||||
}
|
||||
ant.project.log("'$path' added to classpath", Project.MSG_INFO)
|
||||
classLoader.addClasspath(path)
|
||||
}
|
||||
else {
|
||||
ant.project.log("Cannot add to classpath: $path doesn't exist", Project.MSG_WARN)
|
||||
throw new BuildException("Cannot add to classpath: $path doesn't exist")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user