Add the support suppressWarnings, verbose and version in build tools.
This commit is contained in:
@@ -116,14 +116,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
errStream.print(messageRenderer.renderPreamble());
|
||||
|
||||
printVersionIfNeeded(errStream, arguments, messageRenderer);
|
||||
|
||||
MessageCollector collector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
||||
|
||||
if (arguments.suppressWarnings) {
|
||||
collector = new FilteringMessageCollector(collector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||
}
|
||||
|
||||
try {
|
||||
return exec(collector, services, arguments);
|
||||
}
|
||||
@@ -134,6 +128,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
|
||||
@NotNull
|
||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
||||
printVersionIfNeeded(messageCollector, arguments);
|
||||
|
||||
if (arguments.suppressWarnings) {
|
||||
messageCollector = new FilteringMessageCollector(messageCollector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
|
||||
}
|
||||
|
||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||
try {
|
||||
Disposable rootDisposable = Disposer.newDisposable();
|
||||
@@ -164,17 +164,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
@NotNull Disposable rootDisposable
|
||||
);
|
||||
|
||||
protected void printVersionIfNeeded(
|
||||
@NotNull PrintStream errStream,
|
||||
@NotNull A arguments,
|
||||
@NotNull MessageRenderer messageRenderer
|
||||
) {
|
||||
if (arguments.version) {
|
||||
String versionMessage = messageRenderer.render(CompilerMessageSeverity.INFO,
|
||||
"Kotlin Compiler version " + KotlinVersion.VERSION,
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
errStream.println(versionMessage);
|
||||
}
|
||||
protected void printVersionIfNeeded(@NotNull MessageCollector messageCollector, @NotNull A arguments) {
|
||||
if (!arguments.version) return;
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.INFO,
|
||||
"Kotlin Compiler version " + KotlinVersion.VERSION,
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
<orderEntry type="module" module-name="compiler-tests" />
|
||||
<orderEntry type="module" module-name="js.tests" scope="TEST" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="cli-common" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
@@ -102,6 +102,21 @@ public class AntTaskJsTest extends AntTaskBaseTest {
|
||||
doJsAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressWarnings() throws Exception {
|
||||
doJsAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verbose() throws Exception {
|
||||
doJsAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void version() throws Exception {
|
||||
doJsAntTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void noSrcParam() throws Exception {
|
||||
|
||||
@@ -76,6 +76,21 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressWarnings() throws Exception {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verbose() throws Exception {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void version() throws Exception {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void javacCompiler() throws Exception {
|
||||
doJvmAntTest("-cp", getClassPathForAnt(),
|
||||
|
||||
@@ -31,6 +31,7 @@ import kotlin.KotlinPackage;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.common.KotlinVersion;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.jet.test.Tmpdir;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
@@ -95,6 +96,8 @@ public abstract class KotlinIntegrationTestBase {
|
||||
content = normalizePath(content, getTestDataDir(), "[TestData]");
|
||||
content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]");
|
||||
content = normalizePath(content, getCompilerLib(), "[CompilerLib]");
|
||||
content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]");
|
||||
content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]");
|
||||
content = StringUtil.convertLineSeparators(content);
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" nowarn="true"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,14 @@
|
||||
package foo
|
||||
|
||||
import kotlin.Any
|
||||
import kotlin.Any
|
||||
|
||||
fun foo(p: Int??) {
|
||||
|
||||
}
|
||||
|
||||
trait T {
|
||||
abstract fun foo()
|
||||
}
|
||||
|
||||
fun box(): String = "OK"
|
||||
@@ -0,0 +1,15 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||
[kotlin2js] LOGGING: Compiling source files: [TestData]/root1/foo.kt
|
||||
[kotlin2js] OUTPUT: Output:
|
||||
[kotlin2js] [Temp]/out.js
|
||||
[kotlin2js] Sources:
|
||||
[kotlin2js] [TestData]/root1/foo.kt
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" verbose="true"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
fun box(): String = "OK"
|
||||
@@ -0,0 +1,11 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
|
||||
[kotlin2js] INFO: Kotlin Compiler version [KotlinVersion]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" printVersion="true"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,3 @@
|
||||
package foo
|
||||
|
||||
fun box(): String = "OK"
|
||||
@@ -0,0 +1,10 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" nowarn="true" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package hello
|
||||
|
||||
fun foo(p: Int??) {
|
||||
|
||||
}
|
||||
|
||||
trait T {
|
||||
abstract fun foo()
|
||||
}
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println("Hi!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hi!
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,12 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
[kotlinc] LOGGING: Using Kotlin home directory [KotlinProjectHome]/dist/kotlinc
|
||||
[kotlinc] LOGGING: Configuring the compilation environment
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" verbose="true" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
package hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println("Hi!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hi!
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,11 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
[kotlinc] INFO: Kotlin Compiler version [KotlinVersion]
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" printVersion="true" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -0,0 +1,5 @@
|
||||
package hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
println("Yo!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Yo!
|
||||
|
||||
Return code: 0
|
||||
Reference in New Issue
Block a user