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 7d0099cf964..199167ec4dc 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,7 +16,6 @@ package org.jetbrains.jet.buildtools.ant; -import static org.jetbrains.jet.buildtools.core.Util.*; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; @@ -25,10 +24,12 @@ import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException; import java.io.File; +import static org.jetbrains.jet.buildtools.core.Util.getPath; + /** * Kotlin bytecode compiler Ant task. - * + *
* See * http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html * http://evgeny-goldin.org/javadoc/ant/develop.html @@ -36,20 +37,37 @@ import java.io.File; */ public class BytecodeCompilerTask extends Task { - private File output; - private File jar; - private File stdlib; - private File src; - private File module; - private Path compileClasspath; + private File output; + private File jar; + private File stdlib; + private File src; + private File module; + private Path compileClasspath; 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; } + 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; + } /** @@ -57,25 +75,26 @@ public class BytecodeCompilerTask extends Task { * * @param classpath an Ant Path object containing the compilation classpath. */ - public void setClasspath ( Path classpath ) { - if ( this.compileClasspath == null ) { + public void setClasspath(Path classpath) { + if (this.compileClasspath == null) { this.compileClasspath = classpath; } else { - this.compileClasspath.append( classpath ); + this.compileClasspath.append(classpath); } } /** * Adds a reference to a classpath defined elsewhere. + * * @param ref a reference to a classpath. */ - public void setClasspathRef( Reference ref ) { - if ( this.compileClasspath == null ) { - this.compileClasspath = new Path( getProject()); + public void setClasspathRef(Reference ref) { + if (this.compileClasspath == null) { + this.compileClasspath = new Path(getProject()); } - this.compileClasspath.createPath().setRefid( ref ); + this.compileClasspath.createPath().setRefid(ref); } @@ -84,52 +103,52 @@ public class BytecodeCompilerTask extends Task { * * @param classpath an Ant Path object containing the compilation classpath. */ - public void addConfiguredClasspath( Path classpath ) { - setClasspath( classpath ); + public void addConfiguredClasspath(Path classpath) { + setClasspath(classpath); } @Override public void execute() { - final BytecodeCompiler compiler = new BytecodeCompiler(); - final String stdlibPath = ( this.stdlib != null ? getPath( this.stdlib ) : null ); - final String[] classpath = ( this.compileClasspath != null ? this.compileClasspath.list() : null ); + final BytecodeCompiler compiler = new BytecodeCompiler(); + final String stdlibPath = (this.stdlib != null ? getPath(this.stdlib) : null); + final String[] classpath = (this.compileClasspath != null ? this.compileClasspath.list() : null); - if ( this.src != null ) { + if (this.src != null) { - if (( this.output == null ) && ( this.jar == null )) { - throw new CompileEnvironmentException( "\"output\" or \"jar\" should be specified" ); + if ((this.output == null) && (this.jar == null)) { + throw new CompileEnvironmentException("\"output\" or \"jar\" should be specified"); } - String source = getPath( this.src ); - String destination = getPath( this.output != null ? this.output : this.jar ); + String source = getPath(this.src); + String destination = getPath(this.output != null ? this.output : this.jar); - log( String.format( "Compiling [%s] => [%s]", source, destination )); + log(String.format("Compiling [%s] => [%s]", source, destination)); - if ( this.output != null ) { - compiler.sourcesToDir( source, destination, stdlibPath, classpath ); + if (this.output != null) { + compiler.sourcesToDir(source, destination, stdlibPath, classpath); } else { - compiler.sourcesToJar( source, destination, this.includeRuntime, stdlibPath, classpath ); + compiler.sourcesToJar(source, destination, this.includeRuntime, stdlibPath, classpath); } } - else if ( this.module != null ) { + else if (this.module != null) { - if ( this.output != null ) { - throw new CompileEnvironmentException( "Module compilation is only supported for jar destination" ); + if (this.output != null) { + throw new CompileEnvironmentException("Module compilation is only supported for jar destination"); } - String modulePath = getPath( this.module ); - String jarPath = ( this.jar != null ? getPath( this.jar ) : null ); + String modulePath = getPath(this.module); + String jarPath = (this.jar != null ? getPath(this.jar) : null); - log( jarPath != null ? String.format( "Compiling [%s] => [%s]", modulePath, jarPath ) : - String.format( "Compiling [%s]", modulePath )); + log(jarPath != null ? String.format("Compiling [%s] => [%s]", modulePath, jarPath) : + String.format("Compiling [%s]", modulePath)); - compiler.moduleToJar( modulePath, jarPath, this.includeRuntime, stdlibPath, classpath ); + compiler.moduleToJar(modulePath, jarPath, this.includeRuntime, stdlibPath, classpath); } else { - throw new CompileEnvironmentException( "\"src\" or \"module\" should be specified" ); + throw new CompileEnvironmentException("\"src\" or \"module\" should be specified"); } } } diff --git a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/JavaScriptCompilerTask.java b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/JavaScriptCompilerTask.java index 3a44b8c8717..7f53984548a 100644 --- a/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/JavaScriptCompilerTask.java +++ b/build-tools/ant/src/org/jetbrains/jet/buildtools/ant/JavaScriptCompilerTask.java @@ -27,6 +27,6 @@ public class JavaScriptCompilerTask extends Task { @Override public void execute() { - log( "JavaScriptCompilerTask" ); + log("JavaScriptCompilerTask"); } } 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 6411b9936ef..a22bee7fbeb 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 @@ -20,9 +20,9 @@ import jet.modules.Module; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.cli.common.CompilerPlugin; +import org.jetbrains.jet.cli.common.messages.MessageCollector; import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys; import org.jetbrains.jet.cli.jvm.compiler.*; -import org.jetbrains.jet.cli.common.messages.MessageCollector; import org.jetbrains.jet.codegen.BuiltinToJavaTypesMapping; import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode; @@ -40,7 +40,7 @@ public class BytecodeCompiler { private Listnull or empty
*/
- public void sourcesToDir ( @NotNull String src, @NotNull String output, @Nullable String stdlib, @Nullable String[] classpath ) {
+ public void sourcesToDir(@NotNull String src, @NotNull String output, @Nullable String stdlib, @Nullable String[] classpath) {
try {
K2JVMCompileEnvironmentConfiguration configuration = env(stdlib, classpath);
configuration.getEnvironment().addSources(src);
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(configuration, null, new File(output), true);
- if ( ! success ) {
- throw new CompileEnvironmentException( errorMessage( src, false ));
+ if (!success) {
+ throw new CompileEnvironmentException(errorMessage(src, false));
}
}
- catch ( Exception e ) {
- throw new CompileEnvironmentException( errorMessage( src, true ), e );
+ catch (Exception e) {
+ throw new CompileEnvironmentException(errorMessage(src, true), e);
}
}
@@ -131,18 +129,22 @@ public class BytecodeCompiler {
* @param stdlib "kotlin-runtime.jar" path
* @param classpath compilation classpath, can be null or empty
*/
- public void sourcesToJar ( @NotNull String src, @NotNull String jar, boolean includeRuntime, @Nullable String stdlib, @Nullable String[] classpath ) {
+ public void sourcesToJar(@NotNull String src,
+ @NotNull String jar,
+ boolean includeRuntime,
+ @Nullable String stdlib,
+ @Nullable String[] classpath) {
try {
K2JVMCompileEnvironmentConfiguration configuration = env(stdlib, classpath);
configuration.getEnvironment().addSources(src);
boolean success = KotlinToJVMBytecodeCompiler.compileBunchOfSources(configuration, new File(jar), null, includeRuntime);
- if ( ! success ) {
- throw new CompileEnvironmentException( errorMessage( src, false ));
+ if (!success) {
+ throw new CompileEnvironmentException(errorMessage(src, false));
}
}
- catch ( Exception e ) {
- throw new CompileEnvironmentException( errorMessage( src, true ), e );
+ catch (Exception e) {
+ throw new CompileEnvironmentException(errorMessage(src, true), e);
}
}
@@ -156,18 +158,22 @@ public class BytecodeCompiler {
* @param stdlib "kotlin-runtime.jar" path
* @param classpath compilation classpath, can be null or empty
*/
- public void moduleToJar ( @NotNull String module, @NotNull String jar, boolean includeRuntime, @Nullable String stdlib, @Nullable String[] classpath ) {
+ public void moduleToJar(@NotNull String module,
+ @NotNull String jar,
+ boolean includeRuntime,
+ @Nullable String stdlib,
+ @Nullable String[] classpath) {
try {
K2JVMCompileEnvironmentConfiguration env = env(stdlib, classpath);
List