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

feat: new configuration to skip a plugin execution #40

Merged
merged 2 commits into from
Apr 16, 2024
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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,35 @@ Additional arguments to can go in the `<extra-args>` configuration section.
</extra-args>
```

## Skipping an execution

If you need to skip an execution, you can set `<skip>true</skip>` in the
`<configuration>` block of the `<execution>` of the plugin.

```xml
<skip>true</skip> <!-- or `false`, the default value. -->
```

This is probably most useful when driven from a property.

```xml
<skip>${skipRustBuild}</skip>
```

The property can be defaulted in the `<properties>` section of the `pom.xml` file.

```xml
<properties>
<skipRustBuild>false</skipRustBuild>
</properties>
```

And then overridden on the command line with `-DskipRustBuild=true`.

```shell
$ mvn package -DskipRustBuild=true
```

## Overriding Environment Variables

The plugin can be configured to override environment variables during the build.
Expand Down
2 changes: 1 addition & 1 deletion jar-jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.questdb</groupId>
<artifactId>jar-jni</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>JAR JNI Loader</name>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<groupId>org.questdb</groupId>
<artifactId>rust-maven</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion rust-maven-jna-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>org.questdb</groupId>
<artifactId>rust-maven-jna-example</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Rust Maven Plugin JNA Usage Example</name>
Expand Down
18 changes: 16 additions & 2 deletions rust-maven-jni-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->

<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">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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>

<groupId>org.questdb</groupId>
<artifactId>rust-maven-jni-example</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Rust Maven Plugin Usage Example</name>
Expand Down Expand Up @@ -169,6 +169,20 @@
</environmentVariables>
</configuration>
</execution>
<execution>
<!--
This is an example of how to skip an execution.
You can use this to skip both "build" and "test" executions.
-->
<id>dummy</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<skip>true</skip>
<path>required, but not evaluated if skipped</path>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion rust-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>org.questdb</groupId>
<artifactId>rust-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Rust Maven Plugin</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public class CargoBuildMojo extends CargoMojoBase {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping build");
return;
}
final Crate crate = new Crate(
getCrateRoot(),
getTargetRootDir(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public abstract class CargoMojoBase extends AbstractMojo {
@Parameter(property = "project", readonly = true)
protected MavenProject project;

/**
* Skip this configured execution.
*/
@Parameter(property = "skip", defaultValue = "false")
protected boolean skip;

/**
* Additional environment variables set when running `cargo`.
*/
@Parameter(property = "environmentVariables")
private HashMap<String, String> environmentVariables;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CargoTestMojo extends CargoMojoBase {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skipTests) {
if (skip || skipTests) {
getLog().info("Skipping tests");
return;
}
Expand Down
Loading