Minor, fix style issues in ant tasks

This commit is contained in:
Alexander Udalov
2014-12-11 19:43:45 +03:00
parent 444ac32f98
commit a6566139ee
4 changed files with 24 additions and 68 deletions
+6
View File
@@ -23,8 +23,14 @@
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Profile " />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
@@ -21,10 +21,6 @@ import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.jet.cli.js.K2JSCompiler
import java.io.File
/**
* Kotlin JavaScript compiler Ant task.
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
*/
public class Kotlin2JsTask : KotlinCompilerBaseTask<K2JSCompilerArguments>() {
override val arguments = K2JSCompilerArguments()
override val compiler = K2JSCompiler()
@@ -52,13 +48,13 @@ public class Kotlin2JsTask : KotlinCompilerBaseTask<K2JSCompilerArguments>() {
}
override fun fillSpecificArguments() {
arguments.outputFile = getPath(output!!)
arguments.outputFile = output!!.canonicalPath
arguments.noStdlib = noStdlib
// TODO: write test
library?.let {
arguments.libraryFiles = it.list().map { getPath(File(it)) }.copyToArray()
arguments.libraryFiles = it.list().map { File(it).canonicalPath }.copyToArray()
}
arguments.outputPrefix = outputPrefix?.canonicalPath
@@ -18,24 +18,12 @@ package org.jetbrains.jet.buildtools.ant
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.types.Reference
import org.jetbrains.jet.cli.jvm.K2JVMCompiler
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
import java.io.File
import java.io.File.pathSeparator
import org.jetbrains.jet.cli.jvm.K2JVMCompiler
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
import com.intellij.openapi.util.io.FileUtilRt
/**
* Kotlin bytecode compiler Ant task.
* <p/>
* See
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
* http://evgeny-goldin.org/javadoc/ant/develop.html
* http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?view=markup.
*/
public class Kotlin2JvmTask : KotlinCompilerBaseTask<K2JVMCompilerArguments>() {
public class Kotlin2JvmTask : KotlinCompilerBaseTask<K2JVMCompilerArguments>() {
override val arguments = K2JVMCompilerArguments()
override val compiler = K2JVMCompiler()
@@ -51,43 +39,28 @@ public class Kotlin2JvmTask : KotlinCompilerBaseTask<K2JVMCompilerArguments>()
return externalAnnotations!!.createPath()
}
/**
* Set the classpath to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public fun setClasspath(classpath: Path) {
if (this.compileClasspath == null) {
this.compileClasspath = classpath
if (compileClasspath == null) {
compileClasspath = classpath
}
else {
this.compileClasspath!!.append(classpath)
compileClasspath!!.append(classpath)
}
}
/**
* Adds a reference to a classpath defined elsewhere.
*
* @param ref a reference to a classpath.
*/
public fun setClasspathRef(ref: Reference) {
if (this.compileClasspath == null) {
this.compileClasspath = Path(getProject())
if (compileClasspath == null) {
compileClasspath = Path(getProject())
}
this.compileClasspath!!.createPath().setRefid(ref)
compileClasspath!!.createPath().setRefid(ref)
}
/**
* Set the nested {@code <classpath>} to be used for this compilation.
*
* @param classpath an Ant Path object containing the compilation classpath.
*/
public fun addConfiguredClasspath(classpath: Path) {
setClasspath(classpath)
}
override fun fillSpecificArguments() {
arguments.destination = getPath(output!!)
arguments.destination = output!!.canonicalPath
val classpath = arrayListOf<String>()
compileClasspath?.let { classpath.addAll(it.list()) }
@@ -19,7 +19,6 @@ package org.jetbrains.jet.buildtools.ant
import org.apache.tools.ant.Task
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.types.Reference
import org.jetbrains.jet.cli.common.messages.MessageCollectorPlainTextToStream
import java.io.File
import org.apache.tools.ant.BuildException
import org.jetbrains.jet.cli.common.ExitCode
@@ -27,25 +26,9 @@ import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.jet.cli.common.CLICompiler
import org.apache.tools.ant.types.Commandline
import com.sampullara.cli.Args
import java.io.IOException
import org.jetbrains.jet.config
import org.jetbrains.jet.cli.common.messages.PrintingMessageCollector
import org.jetbrains.jet.cli.common.messages.MessageRenderer
/**
* {@code file.getCanonicalPath()} convenience wrapper.
*
* @param file - file to get its canonical path.
* @return file's canonical path
*/
fun getPath(file: File): String {
try {
return file.getCanonicalPath()
}
catch (e: IOException) {
throw RuntimeException("Failed to resolve canonical file of [$file]: $e", e)
}
}
import org.jetbrains.jet.config.Services
/**
* Base class for Kotlin compiler Ant tasks.
@@ -90,7 +73,7 @@ public abstract class KotlinCompilerBaseTask<T : CommonCompilerArguments> : Task
private fun fillArguments() {
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
arguments.freeArgs = sourcePaths.list().map { getPath(File(it)) }
arguments.freeArgs = sourcePaths.list().map { File(it).canonicalPath }
output ?: throw BuildException("\"output\" should be specified")
@@ -98,7 +81,7 @@ public abstract class KotlinCompilerBaseTask<T : CommonCompilerArguments> : Task
arguments.verbose = verbose
arguments.version = printVersion
val args = additionalArguments.flatMap { it.getParts()!!.toList() }
val args = additionalArguments.flatMap { it.getParts().toList() }
try {
Args.parse(arguments, args.copyToArray())
}
@@ -109,15 +92,13 @@ public abstract class KotlinCompilerBaseTask<T : CommonCompilerArguments> : Task
fillSpecificArguments()
}
final override fun execute(): Unit {
final override fun execute() {
fillArguments()
val outputPath = getPath(output!!)
log("Compiling ${arguments.freeArgs} => [${outputPath}]");
log("Compiling ${arguments.freeArgs} => [${output!!.canonicalPath}]");
val collector = PrintingMessageCollector(System.err, MessageRenderer.PLAIN, arguments.verbose)
val exitCode = compiler.exec(collector, config.Services.EMPTY, arguments)
val exitCode = compiler.exec(collector, Services.EMPTY, arguments)
if (exitCode != ExitCode.OK) {
throw BuildException("Compilation finished with exit code $exitCode")