Maven plugin: support additional arguments, drop inline/optimize

This commit is contained in:
Alexander Udalov
2014-08-01 20:45:06 -05:00
parent fbc8361211
commit 6da95e2cea
10 changed files with 17 additions and 166 deletions
@@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>test-inlineDisabled</artifactId>
<artifactId>test-extraArguments</artifactId>
<dependencies>
<dependency>
@@ -69,7 +69,12 @@
</execution>
</executions>
<configuration>
<inline>false</inline>
<args>
<arg>-Xno-inline</arg>
<arg>-Xno-optimize</arg>
<arg>-Xno-call-assertions</arg>
<arg>-Xno-param-assertions</arg>
</args>
</configuration>
</plugin>
</plugins>
@@ -1,6 +1,6 @@
import java.io.*;
File file = new File(basedir, "target/test-inlineDisabled-0.1-SNAPSHOT.jar");
File file = new File(basedir, "target/test-extraArguments-0.1-SNAPSHOT.jar");
if (!file.exists() || !file.isFile()) {
throw new FileNotFoundException("Could not find generated JAR: " + file);
}
@@ -1,9 +0,0 @@
package org.jetbrains
fun main(args : Array<String>) {
System.out?.println(getGreeting())
}
fun getGreeting() : String {
return "Hello, World!"
}
@@ -1,78 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-project</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>test-optimizationDisabled</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${project.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<optimize>false</optimize>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -1,13 +0,0 @@
package org.jetbrains;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class HelloWorldJavaTest {
@Test
public void greeting() {
assertEquals("Hello, World!", org.jetbrains.JetbrainsPackage.getGreeting());
}
}
@@ -1,6 +0,0 @@
import java.io.*;
File file = new File(basedir, "target/test-optimizationDisabled-0.1-SNAPSHOT.jar");
if (!file.exists() || !file.isFile()) {
throw new FileNotFoundException("Could not find generated JAR: " + file);
}
@@ -17,6 +17,8 @@
package org.jetbrains.kotlin.maven;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.sampullara.cli.Args;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -28,7 +30,6 @@ import org.jetbrains.jet.cli.common.CLICompiler;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.common.KotlinVersion;
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
@@ -145,18 +146,11 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
public String testModule;
/**
* Switch method inlining on/off: possible values are "on" and "off".
* Additional command line arguments for Kotlin compiler.
*
* @parameter
*/
public String inline;
/**
* Switch method optimization on/off: possible values are "on" and "off".
*
* @parameter
*/
public String optimize;
public List<String> args;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -313,15 +307,12 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
arguments.noJdkAnnotations = true;
arguments.annotations = getFullAnnotationsPath(log, annotationPaths);
log.info("Using kotlin annotations from " + arguments.annotations);
arguments.noInline = !CompilerArgumentsUtil.optionToBooleanFlag(inline, true);
arguments.noOptimize = !CompilerArgumentsUtil.optionToBooleanFlag(optimize, true);
if (!CompilerArgumentsUtil.checkOption(inline)) {
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", inline));
try {
Args.parse(arguments, ArrayUtil.toStringArray(args));
}
if (!CompilerArgumentsUtil.checkOption(optimize)) {
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", optimize));
catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage());
}
if (arguments.noInline) {