Support default module name in ant task
This commit is contained in:
@@ -70,6 +70,14 @@ public class Kotlin2JvmTask : KotlinCompilerBaseTask() {
|
||||
args.add(it.list().join(pathSeparator))
|
||||
}
|
||||
|
||||
if (moduleName == null) {
|
||||
if (owningTarget != null) {
|
||||
moduleName = owningTarget.name
|
||||
} else {
|
||||
moduleName = getProject().name
|
||||
}
|
||||
}
|
||||
|
||||
moduleName?.let {
|
||||
args.add("-module-name")
|
||||
args.add(moduleName!!)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
[java] Module info 'META-INF/test.kotlin_module' exists
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,14 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" modulename="test"/>
|
||||
|
||||
<java classname="hello.HelloPackage" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${temp}/hello.jar"/>
|
||||
<pathelement location="${kotlin.runtime.jar}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val systemClassLoader = ClassLoader.getSystemClassLoader()
|
||||
val moduleName = "META-INF/test.kotlin_module"
|
||||
val resourceAsStream = systemClassLoader.getResourceAsStream(moduleName)
|
||||
|
||||
if (resourceAsStream != null) {
|
||||
println("Module info '$moduleName' exists")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
[java] Module info 'META-INF/build.kotlin_module' exists
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,14 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
||||
|
||||
<java classname="hello.HelloPackage" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${temp}/hello.jar"/>
|
||||
<pathelement location="${kotlin.runtime.jar}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val systemClassLoader = ClassLoader.getSystemClassLoader()
|
||||
val moduleName = "META-INF/build.kotlin_module"
|
||||
val resourceAsStream = systemClassLoader.getResourceAsStream(moduleName)
|
||||
|
||||
if (resourceAsStream != null) {
|
||||
println("Module info '$moduleName' exists")
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,18 @@ public class AntTaskTestGenerated extends AbstractAntTaskTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("moduleName")
|
||||
public void testModuleName() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/moduleName/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("moduleNameDefault")
|
||||
public void testModuleNameDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/moduleNameDefault/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noStdlibForJavac")
|
||||
public void testNoStdlibForJavac() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/noStdlibForJavac/");
|
||||
|
||||
Reference in New Issue
Block a user