Skip to content

Commit

Permalink
Add missing plugin dependency (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
shitikanth authored Sep 25, 2024
1 parent e025ed7 commit 37c5935
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</scm>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mavenVersion>3.8.1</mavenVersion>
<!-- plugin versions -->
Expand All @@ -50,6 +50,7 @@
<maven-site-plugin.version>3.20.0</maven-site-plugin.version>
<maven-source-plugin.version>2.4</maven-source-plugin.version>
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>
<sisu-maven-plugin.version>0.9.0.M3</sisu-maven-plugin.version>
<central-publishing-maven-plugin.version>0.6.0</central-publishing-maven-plugin.version>

<!-- Dependency versions -->
Expand Down Expand Up @@ -194,6 +195,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>${sisu-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-index</id>
<goals>
<goal>main-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -210,6 +224,7 @@
<artifactId>maven-invoker-plugin</artifactId>
<version>${maven-invoker-plugin.version}</version>
<configuration>
<debug>true</debug>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<showErrors>true</showErrors>
<settingsFile>src/it/settings.xml</settingsFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -49,10 +50,11 @@ public BanEmptyJavaFiles(MavenSession session) {
void shutdownExecutor() {
if (executor != null) {
for (Runnable task : this.executor.shutdownNow()) {
if (task instanceof Future<?> future) {
if (task instanceof Future<?>) {
Future<?> future = (Future<?>) task;
future.cancel(true);
}
};
}
}
}

Expand All @@ -61,8 +63,16 @@ public void execute() throws EnforcerRuleException {
MavenProject project = session.getCurrentProject();
int threads = session.getRequest().getDegreeOfConcurrency();
LOGGER.info("threads: {}", threads);
List<Path> compileSourceRoots = project.getCompileSourceRoots().stream().map(Paths::get).toList();
List<Path> testCompileSourceRoots = project.getTestCompileSourceRoots().stream().map(Paths::get).toList();
List<Path> compileSourceRoots = new ArrayList<>();
List<Path> testCompileSourceRoots = new ArrayList<>();
for (String s : project.getCompileSourceRoots()) {
Path path = Paths.get(s);
compileSourceRoots.add(path);
}
for (String s : project.getTestCompileSourceRoots()) {
Path path = Paths.get(s);
testCompileSourceRoots.add(path);
}
analyzeSourceRoots(compileSourceRoots);
analyzeSourceRoots(testCompileSourceRoots);
}
Expand Down Expand Up @@ -119,8 +129,41 @@ private void analyzeSourceRoots(List<Path> sourceRoots) throws EnforcerRuleExcep
}
}

record AnalysisResult(
Path path,
boolean isEmpty
) {}
static final class AnalysisResult {
private final Path path;
private final boolean isEmpty;

AnalysisResult(
Path path,
boolean isEmpty
) {
this.path = path;
this.isEmpty = isEmpty;
}

public Path path() {return path;}

public boolean isEmpty() {return isEmpty;}

@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != this.getClass()) return false;
var that = (AnalysisResult) obj;
return Objects.equals(this.path, that.path) &&
this.isEmpty == that.isEmpty;
}

@Override
public int hashCode() {
return Objects.hash(path, isEmpty);
}

@Override
public String toString() {
return "AnalysisResult[" +
"path=" + path + ", " +
"isEmpty=" + isEmpty + ']';
}
}
}

0 comments on commit 37c5935

Please sign in to comment.