Reformatted Ant task code according to coding conventions.

This commit is contained in:
Evgeny Gerashchenko
2012-07-08 00:02:12 +04:00
parent ae92d435d6
commit d32d2c0bda
4 changed files with 103 additions and 78 deletions
@@ -16,7 +16,6 @@
package org.jetbrains.jet.buildtools.ant; 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.Task;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Reference;
@@ -25,10 +24,12 @@ import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
import java.io.File; import java.io.File;
import static org.jetbrains.jet.buildtools.core.Util.getPath;
/** /**
* Kotlin bytecode compiler Ant task. * Kotlin bytecode compiler Ant task.
* * <p/>
* See * See
* http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html * http://evgeny-goldin.org/javadoc/ant/tutorial-writing-tasks.html
* http://evgeny-goldin.org/javadoc/ant/develop.html * http://evgeny-goldin.org/javadoc/ant/develop.html
@@ -44,12 +45,29 @@ public class BytecodeCompilerTask extends Task {
private Path compileClasspath; private Path compileClasspath;
private boolean includeRuntime = true; private boolean includeRuntime = true;
public void setOutput ( File output ) { this.output = output; } public void setOutput(File output) {
public void setJar ( File jar ) { this.jar = jar; } this.output = output;
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 setJar(File jar) {
public void setIncludeRuntime ( boolean includeRuntime ) { this.includeRuntime = includeRuntime; } 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;
}
/** /**
@@ -69,6 +87,7 @@ public class BytecodeCompilerTask extends Task {
/** /**
* Adds a reference to a classpath defined elsewhere. * Adds a reference to a classpath defined elsewhere.
*
* @param ref a reference to a classpath. * @param ref a reference to a classpath.
*/ */
public void setClasspathRef(Reference ref) { public void setClasspathRef(Reference ref) {
@@ -20,9 +20,9 @@ import jet.modules.Module;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.cli.common.CompilerPlugin; 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.JVMConfigurationKeys;
import org.jetbrains.jet.cli.jvm.compiler.*; 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.codegen.BuiltinToJavaTypesMapping;
import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode; import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
@@ -49,7 +49,6 @@ public class BytecodeCompiler {
* *
* @param stdlib path to "kotlin-runtime.jar", only used if not null and not empty * @param stdlib path to "kotlin-runtime.jar", only used if not null and not empty
* @param classpath compilation classpath, only used if not null and not empty * @param classpath compilation classpath, only used if not null and not empty
*
* @return compile environment instance * @return compile environment instance
*/ */
private K2JVMCompileEnvironmentConfiguration env(String stdlib, String[] classpath) { private K2JVMCompileEnvironmentConfiguration env(String stdlib, String[] classpath) {
@@ -88,7 +87,6 @@ public class BytecodeCompiler {
* *
* @param source compilation source * @param source compilation source
* @param exceptionThrown whether compilation failed due to exception thrown * @param exceptionThrown whether compilation failed due to exception thrown
*
* @return compilation error message * @return compilation error message
*/ */
private static String errorMessage(@NotNull String source, boolean exceptionThrown) { private static String errorMessage(@NotNull String source, boolean exceptionThrown) {
@@ -131,7 +129,11 @@ public class BytecodeCompiler {
* @param stdlib "kotlin-runtime.jar" path * @param stdlib "kotlin-runtime.jar" path
* @param classpath compilation classpath, can be <code>null</code> or empty * @param classpath compilation classpath, can be <code>null</code> 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 { try {
K2JVMCompileEnvironmentConfiguration configuration = env(stdlib, classpath); K2JVMCompileEnvironmentConfiguration configuration = env(stdlib, classpath);
configuration.getEnvironment().addSources(src); configuration.getEnvironment().addSources(src);
@@ -156,7 +158,11 @@ public class BytecodeCompiler {
* @param stdlib "kotlin-runtime.jar" path * @param stdlib "kotlin-runtime.jar" path
* @param classpath compilation classpath, can be <code>null</code> or empty * @param classpath compilation classpath, can be <code>null</code> 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 { try {
K2JVMCompileEnvironmentConfiguration env = env(stdlib, classpath); K2JVMCompileEnvironmentConfiguration env = env(stdlib, classpath);
List<Module> modules = CompileEnvironmentUtil.loadModuleScript(module, env.getMessageCollector()); List<Module> modules = CompileEnvironmentUtil.loadModuleScript(module, env.getMessageCollector());
@@ -31,6 +31,7 @@ public final class Util {
/** /**
* {@code file.getCanonicalFile().getPath()} convenience wrapper. * {@code file.getCanonicalFile().getPath()} convenience wrapper.
*
* @param f file to get its canonical path. * @param f file to get its canonical path.
* @return file's canonical path * @return file's canonical path
*/ */
@@ -42,5 +43,4 @@ public final class Util {
throw new RuntimeException(String.format("Failed to resolve canonical file of [%s]: %s", f, e), e); throw new RuntimeException(String.format("Failed to resolve canonical file of [%s]: %s", f, e), e);
} }
} }
} }