KT-10028 Support parallel builds in maven

mark all the mojos as not thread safe so Maven should never run them in parallel
This commit is contained in:
Sergey Mashkov
2017-03-23 13:05:02 +03:00
parent 307fdd1024
commit 40a5e646c6
9 changed files with 13 additions and 9 deletions
@@ -76,7 +76,7 @@ import java.util.List;
* mojo.getLog().info("kotlin build script accessing build info of ${mojo.project.artifactId} project") * mojo.getLog().info("kotlin build script accessing build info of ${mojo.project.artifactId} project")
* </code></pre> * </code></pre>
*/ */
@Mojo(name = "script", requiresDependencyResolution = ResolutionScope.COMPILE) @Mojo(name = "script", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
public class ExecuteKotlinScriptMojo extends AbstractMojo { public class ExecuteKotlinScriptMojo extends AbstractMojo {
/** /**
* The Kotlin script file to be executed. * The Kotlin script file to be executed.
@@ -45,7 +45,7 @@ import java.util.concurrent.locks.ReentrantLock;
* *
* @noinspection UnusedDeclaration * @noinspection UnusedDeclaration
*/ */
@Mojo(name = "js", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) @Mojo(name = "js", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArguments> { public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArguments> {
private static final String OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME = "outputDirectoriesCollector"; private static final String OUTPUT_DIRECTORIES_COLLECTOR_PROPERTY_NAME = "outputDirectoriesCollector";
@@ -40,7 +40,7 @@ import static org.jetbrains.kotlin.maven.Util.filterClassPath;
* *
* @noinspection UnusedDeclaration * @noinspection UnusedDeclaration
*/ */
@Mojo(name = "compile", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE) @Mojo(name = "compile", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArguments> { public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArguments> {
/** /**
* Project classpath. * Project classpath.
@@ -41,7 +41,8 @@ import java.util.List;
@Mojo(name = "test-compile", @Mojo(name = "test-compile",
defaultPhase = LifecyclePhase.TEST_COMPILE, defaultPhase = LifecyclePhase.TEST_COMPILE,
requiresDependencyResolution = ResolutionScope.TEST requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = false
) )
public class KotlinTestCompileMojo extends K2JVMCompileMojo { public class KotlinTestCompileMojo extends K2JVMCompileMojo {
/** /**
@@ -36,7 +36,8 @@ import java.util.List;
*/ */
@Mojo(name = "test-js", @Mojo(name = "test-js",
defaultPhase = LifecyclePhase.TEST_COMPILE, defaultPhase = LifecyclePhase.TEST_COMPILE,
requiresDependencyResolution = ResolutionScope.TEST requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
) )
public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo { public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo {
@@ -18,7 +18,7 @@ import java.util.List;
import static com.intellij.openapi.util.text.StringUtil.join; import static com.intellij.openapi.util.text.StringUtil.join;
import static org.jetbrains.kotlin.maven.Util.filterClassPath; import static org.jetbrains.kotlin.maven.Util.filterClassPath;
@Mojo(name = "metadata", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE) @Mojo(name = "metadata", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
public class MetadataMojo extends KotlinCompileMojoBase<K2MetadataCompilerArguments> { public class MetadataMojo extends KotlinCompileMojoBase<K2MetadataCompilerArguments> {
@Parameter(defaultValue = "${project.compileClasspathElements}", required = true, readonly = true) @Parameter(defaultValue = "${project.compileClasspathElements}", required = true, readonly = true)
public List<String> classpath; public List<String> classpath;
@@ -12,7 +12,9 @@ import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@Mojo(name = "test-metadata", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST) @Mojo(name = "test-metadata", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = false
)
public class TestMetadataMojo extends MetadataMojo { public class TestMetadataMojo extends MetadataMojo {
@Parameter(property = "maven.test.skip", defaultValue = "false") @Parameter(property = "maven.test.skip", defaultValue = "false")
private boolean skip; private boolean skip;
@@ -20,7 +20,7 @@ import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getGen
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getStubsDirectory; import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.getStubsDirectory;
/** @noinspection UnusedDeclaration */ /** @noinspection UnusedDeclaration */
@Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE) @Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = false)
public class KaptJVMCompilerMojo extends K2JVMCompileMojo { public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
@Parameter @Parameter
private String[] annotationProcessors; private String[] annotationProcessors;
@@ -17,7 +17,7 @@ import java.util.List;
* *
* @noinspection UnusedDeclaration * @noinspection UnusedDeclaration
*/ */
@Mojo(name = "test-kapt", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST) @Mojo(name = "test-kapt", defaultPhase = LifecyclePhase.PROCESS_TEST_SOURCES, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = false)
public class KaptTestJvmCompilerMojo extends KaptJVMCompilerMojo { public class KaptTestJvmCompilerMojo extends KaptJVMCompilerMojo {
/** /**
* Flag to allow test compilation to be skipped. * Flag to allow test compilation to be skipped.