Skip to content

Commit

Permalink
Merge pull request #356 from Ladicek/maven-plugin-skip-for-pom-packaging
Browse files Browse the repository at this point in the history
skip Jandex Maven plugin execution for POM packaging
  • Loading branch information
Ladicek authored May 13, 2024
2 parents 913dc3c + 6d46069 commit fdad231
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
33 changes: 33 additions & 0 deletions maven-plugin/src/it/skipForPom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>

<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin-skipForPom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2 changes: 2 additions & 0 deletions maven-plugin/src/it/skipForPom/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def jandexFile = new File(basedir, 'target/classes/META-INF/jandex.idx')
assert !jandexFile.exists()
10 changes: 10 additions & 0 deletions maven-plugin/src/main/java/org/jboss/jandex/maven/JandexGoal.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,21 @@ public class JandexGoal extends AbstractMojo {
@Parameter(property = "jandex.skip", defaultValue = "false")
private boolean skip;

/**
* Skip execution if set and if the module's packaging is POM.
*/
@Parameter(defaultValue = "true")
private boolean skipForPomPackaging;

public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Jandex execution skipped");
return;
}
if ("pom".equals(mavenProject.getPackaging()) && skipForPomPackaging) {
getLog().info("Jandex execution skipped for POM packaging");
return;
}

if (fileSets == null) {
fileSets = new ArrayList<>();
Expand Down

0 comments on commit fdad231

Please sign in to comment.