From 970213c0dea17ba4f32457ce9b6df41fd1467a54 Mon Sep 17 00:00:00 2001 From: Christopher Tubbs Date: Fri, 20 Oct 2023 03:24:07 -0400 Subject: [PATCH] Cleanup the POM * keep versions in sync with plugin IT * use properties for versions * bump versions of dependencies, parent, and plugins * remove unneeded versions already specified in parent * remove unnecessary junit/failsafe from main project * remove plexus-utils dependency * add dependency analysis --- pom.xml | 112 +++++++++--------- src/it/plugin-test/pom.xml | 16 +-- .../maven/plugin/AbstractZooKeeperMojo.java | 24 ++++ .../maven/plugin/StartZooKeeperMojo.java | 15 +-- 4 files changed, 89 insertions(+), 78 deletions(-) diff --git a/pom.xml b/pom.xml index d330003..5c9a5f1 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ org.apache apache - 29 + 30 net.revelc.code zookeeper-maven-plugin @@ -46,7 +46,7 @@ - ${maven.min-version} + ${minimalMavenBuildVersion} scm:git:https://github.com/revelc/zookeeper-maven-plugin.git @@ -79,38 +79,46 @@ 8 1.8 1.8 - 3.6.0 true - 3.9.1 + + .+-SNAPSHOT,(?i).*(alpha|beta)[0-9.-]*,(?i).*[.-](m|rc)[0-9]+ 11 - 3.5.0 + 3.6.0 2021-08-03T00:00:00Z UTF-8 UTF-8 - 2.0.9 - 3.0.0-M6 + + 10.12.4 + 4.2.21 + 2.15.3 + 9.4.53.v20231009 + 4.13.2 + 1.12.0 + 2.0.9 + 1.1.10.5 + 3.9.1 com.fasterxml.jackson jackson-bom - 2.15.2 + ${version.jackson} pom import org.eclipse.jetty jetty-bom - 9.4.52.v20230823 + ${version.jetty} pom import io.dropwizard.metrics metrics-core - 4.2.20 + ${version.dropwizard} org.slf4j @@ -119,29 +127,29 @@ - junit - junit - 4.13.2 + org.apache.maven + maven-artifact + ${version.maven-plugin-tools} org.apache.maven maven-core - ${maven.tools-version} + ${version.maven-plugin-tools} org.apache.maven maven-plugin-api - ${maven.tools-version} + ${version.maven-plugin-tools} org.apache.maven.plugin-tools maven-plugin-annotations - 3.8.2 + ${version.maven-plugin-tools} org.apache.zookeeper zookeeper - 3.8.1 + ${version.zookeeper} ch.qos.logback @@ -149,25 +157,20 @@ - - org.codehaus.plexus - plexus-utils - 3.5.1 - org.slf4j slf4j-api - ${slf4j.version} + ${version.slf4j} org.slf4j slf4j-simple - ${slf4j.version} + ${version.slf4j} org.xerial.snappy snappy-java - 1.1.10.5 + ${version.snappy} @@ -176,14 +179,15 @@ org.apache.zookeeper zookeeper - - org.codehaus.plexus - plexus-utils - org.slf4j slf4j-api + + org.apache.maven + maven-artifact + provided + org.apache.maven maven-core @@ -229,11 +233,6 @@ snappy-java runtime - - junit - junit - test - @@ -251,7 +250,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.2.2 + 3.3.0 com.github.spotbugs @@ -308,7 +307,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 true true @@ -323,7 +321,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 true all,-missing @@ -332,7 +329,6 @@ org.apache.maven.plugins maven-release-plugin - 3.0.0 false false @@ -342,19 +338,34 @@ org.apache.maven.plugins maven-site-plugin - 4.0.0-M7 org.apache.maven.skins maven-fluido-skin - 2.0.0-M6 + ${version.maven-fluido-skin} + + org.apache.maven.plugins + maven-dependency-plugin + + + analyze + + analyze-only + + + true + true + + + + com.github.ekryd.sortpom sortpom-maven-plugin @@ -392,19 +403,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - run-integration-tests - - integration-test - verify - - - - org.apache.rat apache-rat-plugin @@ -435,7 +433,7 @@ com.puppycrawl.tools checkstyle - 10.12.3 + ${version.checkstyle} @@ -506,13 +504,13 @@ org.apache.maven.plugins - maven-plugin-plugin - 3.8.2 + maven-plugin-report-plugin + ${version.maven-plugin-tools} org.apache.maven.plugins maven-project-info-reports-plugin - 3.4.3 + ${version.maven-project-info-reports-plugin} diff --git a/src/it/plugin-test/pom.xml b/src/it/plugin-test/pom.xml index 229899c..a16e906 100644 --- a/src/it/plugin-test/pom.xml +++ b/src/it/plugin-test/pom.xml @@ -19,17 +19,17 @@ @project.version@ A simple IT verifying the basic use case. - 8 - 1.8 - 1.8 - UTF-8 - UTF-8 + @maven.compiler.release@ + @maven.compiler.source@ + @maven.compiler.target@ + @project.build.sourceEncoding@ + @project.reporting.outputEncoding@ org.apache.zookeeper zookeeper - 3.6.2 + @version.zookeeper@ org.slf4j @@ -44,7 +44,7 @@ junit junit - 4.13.1 + @version.junit@ test @@ -71,7 +71,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0-M5 + @version.maven-surefire@ run-integration-tests diff --git a/src/main/java/net/revelc/code/zookeeper/maven/plugin/AbstractZooKeeperMojo.java b/src/main/java/net/revelc/code/zookeeper/maven/plugin/AbstractZooKeeperMojo.java index 888a5c2..20e9978 100644 --- a/src/main/java/net/revelc/code/zookeeper/maven/plugin/AbstractZooKeeperMojo.java +++ b/src/main/java/net/revelc/code/zookeeper/maven/plugin/AbstractZooKeeperMojo.java @@ -14,6 +14,11 @@ package net.revelc.code.zookeeper.maven.plugin; +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.util.Comparator; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -124,4 +129,23 @@ boolean shouldSkip() { return false; } + + static void deleteDirectory(File baseDir, String dirType) throws MojoExecutionException { + if (!baseDir.exists()) { + return; + } + try { + Files.walk(baseDir.toPath()).sorted(Comparator.reverseOrder()).forEach(path -> { + try { + Files.deleteIfExists(path); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + } catch (IOException | UncheckedIOException e) { + throw new MojoExecutionException( + "Can't clean " + dirType + " directory: " + baseDir.getAbsolutePath(), e); + } + } + } diff --git a/src/main/java/net/revelc/code/zookeeper/maven/plugin/StartZooKeeperMojo.java b/src/main/java/net/revelc/code/zookeeper/maven/plugin/StartZooKeeperMojo.java index d22f3a5..b22eb08 100644 --- a/src/main/java/net/revelc/code/zookeeper/maven/plugin/StartZooKeeperMojo.java +++ b/src/main/java/net/revelc/code/zookeeper/maven/plugin/StartZooKeeperMojo.java @@ -33,7 +33,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; -import org.codehaus.plexus.util.FileUtils; /** * Starts a service which runs the ZooKeeper server. @@ -223,12 +222,7 @@ private void parseConfig() throws MojoExecutionException { } baseDir = new File(zmpDir, clientPortAddress + "_" + clientPort); if (!keepPreviousState) { - try { - FileUtils.deleteDirectory(baseDir); - } catch (IOException e) { - throw new MojoExecutionException( - "Can't clean " + "plugin directory: " + baseDir.getAbsolutePath()); - } + deleteDirectory(baseDir, "plugin"); } if (!baseDir.mkdirs() && !baseDir.isDirectory()) { throw new MojoExecutionException( @@ -236,12 +230,7 @@ private void parseConfig() throws MojoExecutionException { } dataDir = new File(baseDir, "data"); if (!keepPreviousState) { - try { - FileUtils.deleteDirectory(dataDir); - } catch (IOException e) { - throw new MojoExecutionException( - "Can't clean data directory: " + baseDir.getAbsolutePath()); - } + deleteDirectory(dataDir, "data"); } }