Skip to content

Commit

Permalink
Align bnd mojos with maven-surefire / maven-compiler plugin
Browse files Browse the repository at this point in the history
In maven-compiler and maven-surefire there are some ways skip
compile/execution of tests. Even though it is not recommended to to so
it is quite convenient on occasion.

This now adds analogous parameters to the bnd mojos so these can be used
in a similar fashion.

(cherry picked from commit 6d105c6)
  • Loading branch information
laeubi committed Feb 12, 2025
1 parent e96fcff commit c09e624
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

@Mojo(name = "initialize", defaultPhase = LifecyclePhase.INITIALIZE)
@Mojo(name = "initialize", defaultPhase = LifecyclePhase.INITIALIZE, threadSafe = true)
public class BndInitMojo extends AbstractBndMojo {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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 aQute.bnd.build.Project;
Expand All @@ -22,8 +23,32 @@
@Mojo(name = "integration-test", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class BndIntegrationTestMojo extends AbstractBndProjectMojo {

/**
* Set this to <code>true</code> to bypass unit tests entirely. Its use is
* <b>NOT RECOMMENDED</b>, especially if you enable it using the
* "maven.test.skip" property, because maven.test.skip disables both running the
* tests and compiling the tests. Consider using the <code>skipTests</code>
* parameter instead that only skip the <i>execution</i> of tests.
*/
@Parameter(property = "maven.test.skip")
private boolean skip;

/**
* Set this to "true" to skip running tests, but still compile them. Its use is
* NOT RECOMMENDED, but quite convenient on occasion.
*/
@Parameter(property = "skipTests")
private boolean skipTests;

@Override
protected void execute(Project project) throws Exception {
if (skip) {
return;
}
if (skipTests) {
getLog().warn("Tests execution is skipped!");
return;
}
String testcases = project.getProperty(Constants.TESTCASES);
if (testcases == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@

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 aQute.bnd.build.Project;

@Mojo(name = "test-compile", defaultPhase = LifecyclePhase.TEST_COMPILE, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class BndTestCompileMojo extends AbstractBndProjectMojo {

/**
* Set this to <code>true</code> to bypass compilation of test sources. Its use
* is <b>NOT RECOMMENDED</b>, but quite convenient on occasion.
*/
@Parameter(property = "maven.test.skip")
private boolean skip;

@Override
protected void execute(Project project) throws Exception {
if (skip) {
return;
}
project.compile(true);
}

Expand Down

0 comments on commit c09e624

Please sign in to comment.