diff --git a/Jenkinsfile b/Jenkinsfile
index 94a60234..3b5d318d 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -62,5 +62,5 @@ def collectBuildArtifacts() {
// printed to console by test. was since ever the case but they are now real maven warnings
excludeMessage('.*Uncaught exception in thread Thread.*'),
]
- recordIssues tools: [eclipse()], qualityGates: [[threshold: 1, type: 'TOTAL']]
+ recordIssues tools: [java()], qualityGates: [[threshold: 1, type: 'TOTAL']]
}
diff --git a/pom.xml b/pom.xml
index 04c0b7c3..0e5d1ebe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,6 +198,7 @@
3.13.0
${java.version}
+ true
diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineClassLoaderFactory.java b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineClassLoaderFactory.java
index 9bf8b2a2..246540cf 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineClassLoaderFactory.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineClassLoaderFactory.java
@@ -73,8 +73,10 @@ public EngineClassLoaderFactory(MavenContext mavenContext) {
public URLClassLoader createEngineClassLoader(File engineDirectory) throws IOException {
List osgiClasspath = getOsgiBootstrapClasspath(engineDirectory);
- addToClassPath(osgiClasspath, new File(engineDirectory, OsgiDir.PLUGINS),
- new WildcardFileFilter("org.eclipse.osgi_*.jar"));
+ var filter = WildcardFileFilter.builder()
+ .setWildcards("org.eclipse.osgi_*.jar")
+ .get();
+ addToClassPath(osgiClasspath, new File(engineDirectory, OsgiDir.PLUGINS), filter);
osgiClasspath.addAll(0, getSlf4jJars());
if (maven.log.isDebugEnabled()) {
maven.log.debug("Configuring OSGi engine classpath:");
@@ -130,11 +132,11 @@ private void writeEngineClasspathJar(List ivyEngineClassPathFiles) throws
}
private static URL[] toUrls(List ivyEngineClassPathFiles) throws MalformedURLException {
- List classPathUrls = new ArrayList<>();
+ var classPathUrls = new ArrayList();
for (File file : ivyEngineClassPathFiles) {
- classPathUrls.add(new URL(file.toURI().toASCIIString()));
+ classPathUrls.add(file.toURI().toURL());
}
- return classPathUrls.toArray(new URL[classPathUrls.size()]);
+ return classPathUrls.toArray(URL[]::new);
}
public static class MavenContext {
diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java
index aeb9ccf7..34440809 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/engine/EngineControl.java
@@ -83,7 +83,10 @@ public Executor start() throws Exception {
Executor executor = createEngineExecutor();
executor.setStreamHandler(createEngineLogStreamForwarder(logLine -> findStartEngineUrl(logLine)));
- executor.setWatchdog(new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT));
+ var watchdog = ExecuteWatchdog.builder()
+ .setTimeout(ExecuteWatchdog.INFINITE_TIMEOUT_DURATION)
+ .get();
+ executor.setWatchdog(watchdog);
executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
executor.execute(startCmd, asynchExecutionHandler());
waitForEngineStart(executor);
@@ -130,9 +133,9 @@ private CommandLine toEngineCommand(Command command) {
}
private Executor createEngineExecutor() {
- DefaultExecutor executor = new DefaultExecutor();
- executor.setWorkingDirectory(context.engineDirectory);
- return executor;
+ return DefaultExecutor.builder()
+ .setWorkingDirectory(context.engineDirectory)
+ .get();
}
private PumpStreamHandler createEngineLogStreamForwarder(Consumer logLineHandler)
diff --git a/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java b/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
index 71fbc720..b729ae10 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/engine/download/URLEngineDownloader.java
@@ -1,9 +1,10 @@
package ch.ivyteam.ivy.maven.engine.download;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -66,7 +67,7 @@ private URL findEngineDownloadUrlFromListPage() throws MojoExecutionException {
} finally {
Files.deleteIfExists(index);
}
- } catch (IOException ex) {
+ } catch (Exception ex) {
throw new MojoExecutionException("Failed to find engine download link in list page " + engineListPageUrl, ex);
}
}
@@ -128,7 +129,7 @@ public String getZipFileNameFromDownloadLocation() {
}
public URL findEngineDownloadUrl(InputStream htmlStream)
- throws MojoExecutionException, MalformedURLException {
+ throws MojoExecutionException, MalformedURLException, URISyntaxException {
String engineFileNameRegex = "AxonIvyEngine[^.]+?\\.[^.]+?\\.+[^_]*?_" + osArchitecture + "\\.zip";
Pattern enginePattern = Pattern.compile("href=[\"|'][^\"']*?" + engineFileNameRegex + "[\"|']");
try (Scanner scanner = new Scanner(htmlStream)) {
@@ -152,12 +153,11 @@ public URL findEngineDownloadUrl(InputStream htmlStream)
}
}
- private static URL toAbsoluteLink(URL baseUrl, String parsedEngineArchivLink) throws MalformedURLException {
+ private static URL toAbsoluteLink(URL baseUrl, String parsedEngineArchivLink) throws MalformedURLException, URISyntaxException {
boolean isAbsoluteLink = StringUtils.startsWithAny(parsedEngineArchivLink, "http://", "https://");
if (isAbsoluteLink) {
- return new URL(parsedEngineArchivLink);
+ return URI.create(parsedEngineArchivLink).toURL();
}
- return new URL(baseUrl, parsedEngineArchivLink);
+ return baseUrl.toURI().resolve(parsedEngineArchivLink).toURL();
}
-
}
diff --git a/src/main/java/ch/ivyteam/ivy/maven/util/MavenDependencies.java b/src/main/java/ch/ivyteam/ivy/maven/util/MavenDependencies.java
index c3e29bc8..ac67d055 100644
--- a/src/main/java/ch/ivyteam/ivy/maven/util/MavenDependencies.java
+++ b/src/main/java/ch/ivyteam/ivy/maven/util/MavenDependencies.java
@@ -81,13 +81,9 @@ private Optional findReactorProject(Artifact artifact) {
if (session == null) {
return Optional.empty();
}
- var projects = session.getProjectMap();
- if (projects == null) {
- return Optional.empty();
- }
- String artifactKey = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
- MavenProject reactorProject = projects.get(artifactKey);
- return Optional.ofNullable(reactorProject);
+ return session.getAllProjects().stream()
+ .filter(p -> p.getArtifact().equals(artifact))
+ .findAny();
}
}
diff --git a/src/test/java/ch/ivyteam/ivy/maven/BaseEngineProjectMojoTest.java b/src/test/java/ch/ivyteam/ivy/maven/BaseEngineProjectMojoTest.java
index 88938346..a05d7379 100644
--- a/src/test/java/ch/ivyteam/ivy/maven/BaseEngineProjectMojoTest.java
+++ b/src/test/java/ch/ivyteam/ivy/maven/BaseEngineProjectMojoTest.java
@@ -18,7 +18,7 @@
import java.io.File;
import java.io.IOException;
-import java.net.URL;
+import java.net.URI;
import java.nio.file.Files;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Calendar;
@@ -96,7 +96,7 @@ protected void before() throws Throwable {
String alternateEngineListPageUrl = System.getProperty(InstallEngineMojo.ENGINE_LIST_URL_PROPERTY);
if (alternateEngineListPageUrl != null) {
- getMojo().engineListPageUrl = new URL(alternateEngineListPageUrl);
+ getMojo().engineListPageUrl = URI.create(alternateEngineListPageUrl).toURL();
}
getMojo().engineCacheDirectory = new File(CACHE_DIR);
getMojo().ivyVersion = ENGINE_VERSION_TO_TEST;
diff --git a/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java b/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
index 28d4cec4..8bc523fc 100644
--- a/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
+++ b/src/test/java/ch/ivyteam/ivy/maven/TestInstallEngineMojo.java
@@ -24,6 +24,8 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -75,7 +77,7 @@ public void stopHttp() {
}
private URL mockEngineZip() throws MalformedURLException {
- return new URL(mockBaseUrl+"/fakeEngine.zip");
+ return URI.create(mockBaseUrl + "/fakeEngine.zip").toURL();
}
@Test
@@ -89,7 +91,7 @@ public void testEngineDownload_defaultBehaviour() throws Exception {
// test setup can not expand expression ${settings.localRepository}: so we
// setup an explicit temp dir!
mojo.engineCacheDirectory = Files.createTempDirectory("tmpRepo").toFile();
- mojo.engineListPageUrl = new URL(mockBaseUrl + "/listPageUrl.html");
+ mojo.engineListPageUrl = URI.create(mockBaseUrl + "/listPageUrl.html").toURL();
File defaultEngineDir = new File(mojo.engineCacheDirectory, DEFAULT_VERSION);
assertThat(defaultEngineDir).doesNotExist();
@@ -149,7 +151,7 @@ public void testEngineDownload_alreadyInstalledVersionWithinRange() throws Excep
mojo.ivyVersion = "[7.0.0,800.0.0)";
mojo.autoInstallEngine = true;
- mojo.engineDownloadUrl = new URL("http://localhost/fakeUri");
+ mojo.engineDownloadUrl = URI.create("http://localhost/fakeUri").toURL();
mojo.execute();
assertThat(mojo.engineDirectory.listFiles()).isNotEmpty();
@@ -231,7 +233,7 @@ public void testEngineDownload_overProxy() throws Exception {
mojo.autoInstallEngine = true;
mockServer.setMockHttpServerResponses(createFakeZipResponse(createFakeEngineZip(DEFAULT_VERSION)));
- mojo.engineDownloadUrl = new URL("http://localhost:7123/fakeEngine.zip"); // not reachable: but proxy knows how :)
+ mojo.engineDownloadUrl = URI.create("http://localhost:7123/fakeEngine.zip").toURL(); // not reachable: but proxy knows how :)
var downloader = (URLEngineDownloader) mojo.getDownloader();
try {
downloader.downloadEngine();
@@ -307,7 +309,7 @@ public void testEngineLinkFinder_relative() throws Exception {
mojo.ivyVersion = "[7.0.0,7.1.0]";
mojo.restrictVersionToMinimalCompatible = false;
mojo.osArchitecture = "Windows_x86";
- mojo.engineListPageUrl = new URL("http://localhost/");
+ mojo.engineListPageUrl = URI.create("http://localhost/").toURL();
assertThat(findLink("the latest engine"))
.isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Windows_x86.zip");
}
@@ -354,7 +356,7 @@ public void testEngineLinkFinder_multipleLinks() throws Exception {
mojo.ivyVersion = "[7.0.0,7.1.0]";
mojo.restrictVersionToMinimalCompatible = false;
mojo.osArchitecture = "Linux_x86";
- mojo.engineListPageUrl = new URL("http://localhost/");
+ mojo.engineListPageUrl = URI.create("http://localhost/").toURL();
assertThat(findLink(
"the latest engine" // windows
@@ -362,7 +364,7 @@ public void testEngineLinkFinder_multipleLinks() throws Exception {
.isEqualTo("http://localhost/7.0.0/AxonIvyEngine7.0.0.46949_Linux_x86.zip");
}
- private String findLink(String html) throws MojoExecutionException, MalformedURLException {
+ private String findLink(String html) throws MojoExecutionException, MalformedURLException, URISyntaxException {
return getUrlDownloader().findEngineDownloadUrl(IOUtils.toInputStream(html, StandardCharsets.UTF_8)).toExternalForm();
}