diff --git a/build-tools/Wiki.txt b/build-tools/Wiki.txt index ccaf48a8e1c..b4cfc559d82 100644 --- a/build-tools/Wiki.txt +++ b/build-tools/Wiki.txt @@ -12,30 +12,35 @@ To define an Ant's {{**}} task you need to define a {{*KOTLIN_HOME*}} e {code} + +Alternatively, you can copy all jar files from Kotlin distribution to Ant's {{"lib"}} folder. + + h2. {{**}} attributes || {align:center}Name{align} || {align:center}Description{align} || {align:center}Required{align} || {align:center}Default Value{align} || -| {align:center}{{*file*}}{align} | Kotlin source file to compile | {{"file"}}, {{"srcdir"}}, or {{"module"}} needs to be specified |   | -| {align:center}{{*srcdir*}}{align} | Kotlin source directory to compile | {{"file"}}, {{"srcdir"}}, or {{"module"}} needs to be specified |   | -| {align:center}{{*module*}}{align} | Kotlin [module|http://confluence.jetbrains.net/display/Kotlin/Modules+and+Compilation] to compile, can only be used with {{*"destjar"*}}.| {{"file"}}, {{"srcdir"}}, or {{"module"}} needs to be specified |   | -| {align:center}{{*destdir*}}{align} | Destination directory | {{"destdir"}} or {{"destjar"}} needs to be specified |   | -| {align:center}{{*destjar*}}{align} | Destination jar file | {{"destdir"}} or {{"destjar"}} needs to be specified |   | +| {align:center}{{*src*}}{align} | Kotlin source file or directory to compile | {{"src"}} or {{"module"}} needs to be specified |   | +| {align:center}{{*module*}}{align} | Kotlin [module|http://confluence.jetbrains.net/display/Kotlin/Modules+and+Compilation] to compile | {{"src"}} or {{"module"}} needs to be specified |   | +| {align:center}{{*output*}}{align} | Destination directory | If {{"src"}} is used - {{"output"}} or {{"jar"}} needs to be specified |   | +| {align:center}{{*jar*}}{align} | Destination jar file | If {{"src"}} is used - {{"output"}} or {{"jar"}} needs to be specified +If {{"module"}} is used - only {{"jar"}} can be specified or it can be omitted | {align:center}{{"moduleName.jar"}}{align} | | {align:center}{{*stdlib*}}{align} | Path to {{"kotlin-runtime.jar"}} | {align:center}{{false}}{align} | {align:center}{{""}}{align} | -| {align:center}{{*includeRuntime*}}{align} | Whether Kotlin runtime library is included in compilation | {align:center}{{false}}{align} | {align:center}{{true}}{align} | +| {align:center}{{*includeRuntime*}}{align} | If {{"jar"}} is used - whether Kotlin runtime library is included | {align:center}{{false}}{align} | {align:center}{{true}}{align} | h2. Examples {code} - - + + - - + + - + + {code} {{"Smoke.kts"}}: diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java index 9bfafacf94e..f57dfe39001 100644 --- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java +++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/BytecodeCompilerTask.java @@ -16,62 +16,57 @@ import java.io.File; */ public class BytecodeCompilerTask extends Task { - private boolean includeRuntime = true; - private String stdlib; - + private File output; + private File jar; + private File stdlib; + private File src; private File module; - private File srcdir; - private File file; - private File destdir; - private File destjar; - - - public void setStdlib ( String stdlib ) { this.stdlib = stdlib; } - public void setModule ( File module ) { this.module = module; } - public void setSrcdir ( File srcdir ) { this.srcdir = srcdir; } - public void setFile ( File file ) { this.file = file; } - public void setDestdir ( File destdir ) { this.destdir = destdir; } - public void setDestjar ( File destjar ) { this.destjar = destjar; } + private boolean includeRuntime = true; + public void setOutput ( File output ) { this.output = output; } + public void setJar ( File jar ) { this.jar = jar; } + public void setStdlib ( File stdlib ) { this.stdlib = stdlib; } + public void setSrc ( File src ) { this.src = src; } + public void setModule ( File module ) { this.module = module; } public void setIncludeRuntime ( boolean includeRuntime ) { this.includeRuntime = includeRuntime; } @Override public void execute() { - final BytecodeCompiler compiler = new BytecodeCompiler( this.stdlib ); + final BytecodeCompiler compiler = new BytecodeCompiler( this.stdlib != null ? getPath( this.stdlib ) : null ); - if (( this.srcdir != null ) || ( this.file != null )) { + if ( this.src != null ) { - if (( this.destdir == null ) && ( this.destjar == null )) { - throw new RuntimeException( "\"destdir\" or \"destjar\" should be specified" ); + if (( this.output == null ) && ( this.jar == null )) { + throw new RuntimeException( "\"output\" or \"jar\" should be specified" ); } - String src = getPath( this.srcdir != null ? this.srcdir : this.file ); - String dest = getPath( this.destdir != null ? this.destdir : this.destjar ); + String source = getPath( this.src ); + String destination = getPath( this.output != null ? this.output : this.jar ); - log( String.format( "[%s] => [%s]", src, dest )); + log( String.format( "[%s] => [%s]", source, destination )); - if ( this.destdir != null ) { - compiler.sourcesToDir( src, dest ); + if ( this.output != null ) { + compiler.sourcesToDir( source, destination ); } else { - compiler.sourcesToJar( src, dest, this.includeRuntime ); + compiler.sourcesToJar( source, destination, this.includeRuntime ); } } else if ( this.module != null ) { - if ( this.destdir != null ) { + if ( this.output != null ) { throw new RuntimeException( "Module compilation is only supported for jar destination" ); } String modulePath = getPath( this.module ); - String jarPath = ( this.destjar != null ? getPath( this.destjar ) : null ); + String jarPath = ( this.jar != null ? getPath( this.jar ) : null ); compiler.moduleToJar( modulePath, jarPath, this.includeRuntime ); } else { - throw new RuntimeException( "This operation is not supported" ); + throw new RuntimeException( "\"src\" or \"module\" should be specified" ); } } } diff --git a/build-tools/build.xml b/build-tools/build.xml index 8d708cd316e..5ca0a186b4e 100644 --- a/build-tools/build.xml +++ b/build-tools/build.xml @@ -74,32 +74,19 @@ - - - - + + - - - - - - - - - - - + - - + @@ -108,30 +95,12 @@ - - - + - + - - - - - - - - - - - - - - - - - + @@ -203,16 +172,16 @@ - + - + - + - + @@ -234,14 +203,14 @@ - + - + @@ -255,13 +224,13 @@ - - - + + + - - - + + + @@ -283,7 +252,7 @@ - + @@ -301,7 +270,7 @@ - + diff --git a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java index bb6c4c6d8e2..49150f9ba0c 100644 --- a/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java +++ b/build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java @@ -11,6 +11,10 @@ public class BytecodeCompiler { private final CompileEnvironment ENV; + /** + * Initializes an instance of this bytecode compiler. + * @param stdlib "stdlib" compiler argument, path to "kotlin-runtime.jar", allowed to be null or empty. + */ public BytecodeCompiler ( String stdlib ) { ENV = new CompileEnvironment(); if (( stdlib != null ) && ( stdlib.trim().length() > 0 )) {