Skip to content

Commit

Permalink
Merge pull request #195 from Ladicek/maven-plugin-single-index
Browse files Browse the repository at this point in the history
Make the Maven plugin generate a single index per execution
  • Loading branch information
Ladicek authored May 11, 2022
2 parents facf74a + a6f7e97 commit 66ef264
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 88 deletions.
3 changes: 2 additions & 1 deletion maven-plugin/src/it/defaultFileset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin-filesets</artifactId>
<artifactId>jandex-maven-plugin-defaultFileset</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
Expand Down Expand Up @@ -53,6 +53,7 @@
</goals>
<configuration>
<processDefaultFileSet>false</processDefaultFileSet>
<indexDir>${project.build.directory}/dependency</indexDir>
<fileSets>
<fileSet>
<directory>${project.build.directory}/dependency</directory>
Expand Down
13 changes: 3 additions & 10 deletions maven-plugin/src/it/defaultFileset/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import org.jboss.jandex.IndexReader

def jandexFile = new File(basedir, 'target/classes/META-INF/jandex.idx')
assert !jandexFile.exists() : "File ${jandexFile} does exist"

// ---

// this assumes that each fileSet gets its own index, which is current behavior
// not sure this is _correct_ behavior though!

jandexFile = new File(basedir, 'target/dependency/META-INF/jandex.idx')
// index dir explicitly configured
def jandexFile = new File(basedir, 'target/dependency/jandex.idx')
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} doesn't contain exactly 1 class"
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} does not contain exactly 1 class"
15 changes: 2 additions & 13 deletions maven-plugin/src/it/filesets/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
import org.jboss.jandex.IndexReader

// 2 file sets in 1 index
def jandexFile = new File(basedir, 'target/classes/META-INF/jandex.idx')
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

def index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} doesn't contain exactly 1 class"

// ---

// this assumes that each fileSet gets its own index, which is current behavior
// not sure this is _correct_ behavior though!

jandexFile = new File(basedir, 'target/dependency/META-INF/jandex.idx')
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} doesn't contain exactly 1 class"
assert index.getKnownClasses().size() == 2 : "Index ${jandexFile} does not contain exactly 2 classes"
80 changes: 80 additions & 0 deletions maven-plugin/src/it/multipleIndices/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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>

<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-build-parent</artifactId>
<version>31</version>
</parent>

<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin-multipleIndices</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>unpack-dependency</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>2.4.0.Final</version>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/dependency</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>

<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>
<execution>
<id>make-second-index</id>
<goals>
<goal>jandex</goal>
</goals>
<configuration>
<indexDir>${project.build.directory}/dependency</indexDir>
<processDefaultFileSet>false</processDefaultFileSet>
<fileSets>
<fileSet>
<directory>${project.build.directory}/dependency</directory>
<includes>
<include>org/jboss/jandex/MethodParameter*.class</include>
</includes>
<excludes>
<exclude>org/jboss/jandex/MethodParameterTypeTarget.class</exclude>
</excludes>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.jboss.jandex.maven.multipleIndices;

public class SomeClass {

}
17 changes: 17 additions & 0 deletions maven-plugin/src/it/multipleIndices/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import org.jboss.jandex.IndexReader

// 1st execution
def jandexFile = new File(basedir, 'target/classes/META-INF/jandex.idx')
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

def index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} does not contain exactly 1 class"

// 2nd execution
jandexFile = new File(basedir, 'target/dependency/jandex.idx')
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} does not contain exactly 1 class"
2 changes: 1 addition & 1 deletion maven-plugin/src/it/noFileset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin-filesets</artifactId>
<artifactId>jandex-maven-plugin-noFilesets</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
Expand Down
8 changes: 7 additions & 1 deletion maven-plugin/src/it/noFileset/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
import org.jboss.jandex.IndexReader

def jandexFile = new File(basedir, 'target/classes/META-INF/jandex.idx')
assert !jandexFile.exists() : "File ${jandexFile} does exist"
assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

def index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().isEmpty() : "Index ${jandexFile} is not empty"
2 changes: 1 addition & 1 deletion maven-plugin/src/it/smoketest/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ assert jandexFile.exists() : "File ${jandexFile} does not exist"
assert jandexFile.length() > 0 : "File ${jandexFile} is empty"

def index = new IndexReader(jandexFile.newInputStream()).read()
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} doesn't contain exactly 1 class"
assert index.getKnownClasses().size() == 1 : "Index ${jandexFile} does not contain exactly 1 class"
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,23 @@ public List<String> getExcludes() {
return excludes;
}

public void setDirectory(final File directory) {
public void setDirectory(File directory) {
this.directory = directory;
}

public void setIncludes(final List<String> includes) {
public void setIncludes(List<String> includes) {
this.includes = includes;
}

public void setExcludes(final List<String> excludes) {
public void setExcludes(List<String> excludes) {
this.excludes = excludes;
}

public boolean isUseDefaultExcludes() {
return useDefaultExcludes;
}

public void setUseDefaultExcludes(final boolean useDefaultExcludes) {
public void setUseDefaultExcludes(boolean useDefaultExcludes) {
this.useDefaultExcludes = useDefaultExcludes;
}

}
Loading

0 comments on commit 66ef264

Please # to comment.