Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
</distributionManagement>

<dependencies>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
</dependency>


<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/ivyteam/ivy/maven/CleanupMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @since 13.2.0
*/
@Mojo(name = CleanupMojo.GOAL)
@Mojo(name = CleanupMojo.GOAL, threadSafe = true)
public class CleanupMojo extends AbstractMojo {

public static final String GOAL = "ivy-cleanup";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/ivyteam/ivy/maven/IarPackagingMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author Reguel Wermelinger
* @since 6.0.0
*/
@Mojo(name = IarPackagingMojo.GOAL)
@Mojo(name = IarPackagingMojo.GOAL, threadSafe = true)
public class IarPackagingMojo extends AbstractMojo {
public static final String GOAL = "pack-iar";

Expand Down
74 changes: 37 additions & 37 deletions src/main/java/ch/ivyteam/ivy/maven/InstallEngineMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* @author Reguel Wermelinger
* @since 6.0.0
*/
@Mojo(name = InstallEngineMojo.GOAL, requiresProject = false)
@Mojo(name = InstallEngineMojo.GOAL, requiresProject = false, threadSafe = true)
public class InstallEngineMojo extends AbstractEngineMojo {
public static final String GOAL = "installEngine";
public static final String ENGINE_LIST_URL_PROPERTY = "ivy.engine.list.url";
Expand Down Expand Up @@ -191,50 +191,50 @@ private void handleWrongIvyVersion(ArtifactVersion installedEngineVersion) throw
}

private void downloadAndInstallEngine(boolean cleanEngineDir) throws MojoExecutionException {
if (autoInstallEngine) {
getLog().info("Will automatically download Engine now.");
final EngineDownloader engineDownloader = getDownloader();
var downloadZip = engineDownloader.downloadEngine();
if (!autoInstallEngine) {
throw new MojoExecutionException("Aborting build as no valid ivy Engine is available! "
+ "Use the 'autoInstallEngine' parameter for an automatic installation.");
}
getLog().info("Will automatically download Engine now.");
final EngineDownloader engineDownloader = getDownloader();
var downloadZip = engineDownloader.downloadEngine();

if (cleanEngineDir) {
removeOldEngineContent();
}
if (cleanEngineDir) {
removeOldEngineContent();
}

if (!isEngineDirectoryIdentified()) {
String engineZipFileName = engineDownloader.getZipFileNameFromDownloadLocation();
engineDirectory = engineCacheDirectory.resolve(ivyEngineVersionOfZip(engineZipFileName));
try {
Files.createDirectories(engineDirectory);
} catch (IOException ex) {
throw new MojoExecutionException("Could not create directories " + engineDirectory, ex);
}
if (!isEngineDirectoryIdentified()) {
String engineZipFileName = engineDownloader.getZipFileNameFromDownloadLocation();
engineDirectory = engineCacheDirectory.resolve(ivyEngineVersionOfZip(engineZipFileName));
try {
Files.createDirectories(engineDirectory);
} catch (IOException ex) {
throw new MojoExecutionException("Could not create directories " + engineDirectory, ex);
}
}

unpackEngine(downloadZip);
unpackEngine(downloadZip);

if (!downloadUsingMaven) {
try {
Files.delete(downloadZip);
} catch (IOException ex) {
throw new MojoExecutionException("Could not delete file " + downloadZip.toAbsolutePath(), ex);
}
if (!downloadUsingMaven) {
try {
Files.delete(downloadZip);
} catch (IOException ex) {
throw new MojoExecutionException("Could not delete file " + downloadZip.toAbsolutePath(), ex);
}
}

ArtifactVersion installedEngineVersion = getInstalledEngineVersion(getRawEngineDirectory());
if (installedEngineVersion == null) {
throw new MojoExecutionException(
"Can not determine installed engine version in directory '" + getRawEngineDirectory() + "'. "
+ "Possibly a non-OSGi engine.");
}
if (!getIvyVersionRange().containsVersion(installedEngineVersion)) {
throw new MojoExecutionException("Automatic installation of an ivyEngine failed. "
+ "Downloaded version is '" + installedEngineVersion + "' but expecting '" + ivyVersion
+ "'.");
}
} else {
throw new MojoExecutionException("Aborting class generation as no valid ivy Engine is available! "
+ "Use the 'autoInstallEngine' parameter for an automatic installation.");
ArtifactVersion installedEngineVersion = getInstalledEngineVersion(getRawEngineDirectory());
if (installedEngineVersion == null) {
throw new MojoExecutionException(
"Can not determine installed engine version in directory '" + getRawEngineDirectory() + "'. "
+ "Possibly a non-OSGi engine.");
}
if (!getIvyVersionRange().containsVersion(installedEngineVersion)) {
throw new MojoExecutionException("Automatic installation of an ivyEngine failed. "
+ "Downloaded version is '" + installedEngineVersion + "' but expecting '" + ivyVersion
+ "'.");
}

}

public EngineDownloader getDownloader() throws MojoExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @since 9.2.0
*/
@Mojo(name = MavenDependencyMojo.GOAL, requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM)
@Mojo(name = MavenDependencyMojo.GOAL, requiresDependencyResolution = ResolutionScope.RUNTIME_PLUS_SYSTEM, threadSafe = true)
public class MavenDependencyMojo extends AbstractMojo {
public static final String GOAL = "maven-dependency";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
*
* @since 9.4.0
*/
@Mojo(name = SetupIvyResourcesPropertiesMojo.GOAL, requiresDependencyResolution = ResolutionScope.COMPILE)
@Mojo(name = SetupIvyResourcesPropertiesMojo.GOAL,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE)
public class SetupIvyResourcesPropertiesMojo extends AbstractMojo {
public static final String GOAL = "ivy-resources-properties";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author Reguel Wermelinger
* @since 6.0.0
*/
@Mojo(name = CompileProjectMojo.GOAL, requiresDependencyResolution = ResolutionScope.COMPILE)
@Mojo(name = CompileProjectMojo.GOAL, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true)
public class CompileProjectMojo extends AbstractProjectCompileMojo {
public static final String GOAL = "compileProject";

Expand All @@ -56,9 +56,12 @@ public class CompileProjectMojo extends AbstractProjectCompileMojo {
@Parameter(property = "ivy.script.validation.skip", defaultValue = "false")
boolean skipScriptValidation;

@Parameter(property = "ivy.compiler.use.default", defaultValue = "false")
boolean useDefaultCompiler;

@Override
protected void engineExec(MavenProjectBuilderProxy projectBuilder) throws Exception {
if (skipCompilation) {
if (skipCompilation || useDefaultCompiler) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @author Reguel Wermelinger
* @since 6.1.0
*/
@Mojo(name = CompileTestProjectMojo.GOAL, requiresDependencyResolution = ResolutionScope.TEST)
@Mojo(name = CompileTestProjectMojo.GOAL, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class CompileTestProjectMojo extends AbstractProjectCompileMojo {
public static final String GOAL = "test-compile";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package ch.ivyteam.ivy.maven.compile;

import java.util.List;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.compiler.CompilationFailureException;
import org.apache.maven.plugin.compiler.CompilerMojo;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;

@Mojo(
name = "default-compile",
defaultPhase = LifecyclePhase.COMPILE,
threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE)
public class DefaultCompilerMojo extends CompilerMojo {

@Parameter(defaultValue = "${project.compileSourceRoots}", readonly = false, required = true)
private List<String> compileSourceRoots;

@Parameter(property = "project", required = true, readonly = true)
MavenProject project;

@Parameter(property = "ivy.compiler.skip", defaultValue = "false")
boolean skipCompilation;

@Parameter(property = "ivy.compiler.use.default", defaultValue = "false")
boolean useDefaultCompiler;

@Override
protected List<String> getCompileSourceRoots() {
getLog().info("Compile source roots: " + compileSourceRoots);
return compileSourceRoots;
}

@Override
public void execute() throws MojoExecutionException, CompilationFailureException {
if (skipCompilation || !useDefaultCompiler) {
return;
}
super.execute();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @since 13.2.0
*/
@Mojo(name = GenerateDataClassSourcesMojo.GOAL)
@Mojo(name = GenerateDataClassSourcesMojo.GOAL, threadSafe = true)
public class GenerateDataClassSourcesMojo extends AbstractEngineInstanceMojo {
public static final String GOAL = "generate-data-class-sources";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @since 13.2.0
*/
@Mojo(name = GenerateDialogFormSourcesMojo.GOAL)
@Mojo(name = GenerateDialogFormSourcesMojo.GOAL, threadSafe = true)
public class GenerateDialogFormSourcesMojo extends AbstractEngineInstanceMojo {
public static final String GOAL = "generate-dialog-form-sources";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* @since 13.2.0
*/
@Mojo(name = GenerateWebServiceSourcesMojo.GOAL)
@Mojo(name = GenerateWebServiceSourcesMojo.GOAL, threadSafe = true)
public class GenerateWebServiceSourcesMojo extends AbstractEngineInstanceMojo {
public static final String GOAL = "generate-web-service-sources";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @since 13.2.0
*/
@Mojo(name = UnpackLibsMojo.GOAL)
@Mojo(name = UnpackLibsMojo.GOAL, threadSafe = true)
public class UnpackLibsMojo extends AbstractMojo {

public static final String GOAL = "unpack-libs";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @author Reguel Wermelinger
* @since 6.0.2
*/
@Mojo(name = SetupIvyTestPropertiesMojo.GOAL, requiresDependencyResolution = ResolutionScope.TEST)
@Mojo(name = SetupIvyTestPropertiesMojo.GOAL, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class SetupIvyTestPropertiesMojo extends AbstractEngineMojo {
public static final String GOAL = "ivy-test-properties";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
*
* @since 12.0.1
*/
@Mojo(name = ValidateMojo.GOAL, requiresProject = true)
@Mojo(name = ValidateMojo.GOAL, requiresProject = true, threadSafe = true)
public class ValidateMojo extends AbstractMojo {

public static final String GOAL = "validate";
private static final String EXECUTED_PROPERTY = ValidateMojo.class.getSimpleName() + ".executed";
protected static final String PLUGIN_GROUPID = "com.axonivy.ivy.ci";
protected static final String PLUGIN_ARTIFACTID = "project-build-plugin";

Expand All @@ -36,6 +37,10 @@ public class ValidateMojo extends AbstractMojo {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (session.getUserProperties().putIfAbsent(EXECUTED_PROPERTY, true) != null) {
getLog().debug("Skipping validation as it was already executed in this session.");
return;
}
validateConsistentPluginVersion(session.getAllProjects());
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/META-INF/plexus/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
com.axonivy.ivy.ci:project-build-plugin:ivy-resources-properties,
org.apache.maven.plugins:maven-resources-plugin:resources
</process-resources>
<compile>com.axonivy.ivy.ci:project-build-plugin:compileProject</compile>
<compile>
com.axonivy.ivy.ci:project-build-plugin:default-compile
com.axonivy.ivy.ci:project-build-plugin:compileProject
</compile>
<test-compile>com.axonivy.ivy.ci:project-build-plugin:test-compile</test-compile>
<test>
com.axonivy.ivy.ci:project-build-plugin:ivy-test-properties,
Expand Down
Loading