Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #3271 - Add support for skipping using skip property to Piranha Maven plugin #3272

Merged
merged 3 commits into from
Mar 2, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public abstract class BaseMojo extends AbstractMojo {
*/
@Parameter(defaultValue = "${project.build.directory}/piranha", property = "piranha.runtimeDirectory", required = true)
protected String runtimeDirectory;

/**
* Stores the skip property.
*/
@Parameter(defaultValue= "false", property="piranha.skip")
protected boolean skip;

/**
* Stores the version of the Piranha runtime to use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ public class RunMojo extends BaseMojo {

@Override
public void execute() throws MojoExecutionException {
try {
determineVersionToUse();
downloadDistribution();
extractDistribution();
copyWarFile();
startPiranhaAndWait();
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
if (!skip) {
try {
determineVersionToUse();
downloadDistribution();
extractDistribution();
copyWarFile();
startPiranhaAndWait();
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
}
}
}


/**
* Start Piranha using a JAR distribution.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ public class StartMojo extends BaseMojo {

@Override
public void execute() throws MojoExecutionException {
try {
determineVersionToUse();
downloadDistribution();
extractDistribution();
copyWarFile();
startPiranha();
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
if (!skip) {
try {
determineVersionToUse();
downloadDistribution();
extractDistribution();
copyWarFile();
startPiranha();
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
}
}
}

Expand Down Expand Up @@ -126,7 +128,7 @@ private void startPiranha() throws IOException {
startJarPiranha();
case "zip" ->
startZipPiranha();
default ->
default ->
throw new IOException("Unable to determine distribution");
}
File pidFile = new File(runtimeDirectory + "/tmp/piranha.pid");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,32 @@ public class StopMojo extends AbstractMojo {
*/
@Parameter(defaultValue = "${project.build.directory}/piranha", required = true)
private String runtimeDirectory;


/**
* Stores the skip property.
*/
@Parameter(defaultValue= "false", property="piranha.skip")
private boolean skip;

@Override
public void execute() throws MojoExecutionException {
try {
if (!Files.deleteIfExists(new File(
runtimeDirectory, "tmp/piranha.pid").toPath())) {
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
if (Files.deleteIfExists(new File(
runtimeDirectory, "tmp/piranha.pid").toPath())) {
System.err.println("Unable to delete PID file");
if (!skip) {
try {
if (!Files.deleteIfExists(new File(
runtimeDirectory, "tmp/piranha.pid").toPath())) {
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
if (Files.deleteIfExists(new File(
runtimeDirectory, "tmp/piranha.pid").toPath())) {
System.err.println("Unable to delete PID file");
}
}
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
}
} catch (IOException ioe) {
throw new MojoExecutionException(ioe);
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<inputEncoding>UTF-8</inputEncoding>
<linkXRef>false</linkXRef>
<excludes>**/module-info.java</excludes>
<checkstyleRules>
Expand Down
1 change: 1 addition & 0 deletions test/embedded/springboot-virtualthreads/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<jvmArguments>
--enable-preview --add-modules=jdk.incubator.concurrent
Expand Down
1 change: 1 addition & 0 deletions test/embedded/springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<!--
<jvmArguments>
Expand Down