paths = new TreeSet<>();
- for (String module : modules) {
- File file = new File(project.getBasedir(), module);
- paths.add(file.getCanonicalPath());
- }
- return paths;
- }
-}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/TimestampPropertyMojo.java b/src/main/java/org/codehaus/mojo/buildhelper/TimestampPropertyMojo.java
index fdefc479..e931169d 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/TimestampPropertyMojo.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/TimestampPropertyMojo.java
@@ -32,12 +32,11 @@
import java.util.Locale;
import java.util.TimeZone;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.di.Inject;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
/**
* Sets a property based on the current date and time.
@@ -45,7 +44,7 @@
* @author Stephen Connolly
* @since 1.7
*/
-@Mojo(name = "timestamp-property", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true)
+@Mojo(name = "timestamp-property", defaultPhase = "validate")
public class TimestampPropertyMojo extends AbstractDefinePropertyMojo {
/**
@@ -111,13 +110,13 @@ public class TimestampPropertyMojo extends AbstractDefinePropertyMojo {
*
* @since 3.2.0
*/
- @Parameter(readonly = true, defaultValue = "${session}")
- private MavenSession mavenSession;
+ @Inject
+ private Session session;
/**
* {@inheritDoc}
*/
- public void execute() throws MojoExecutionException, MojoFailureException {
+ public void execute() throws MojoException, MojoException {
Locale locale;
if (this.locale != null) {
String[] bits = this.locale.split("[,_]");
@@ -128,7 +127,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
} else if (bits.length == 3) {
locale = new Locale(bits[0].trim(), bits[1].trim(), bits[2].trim());
} else {
- throw new MojoExecutionException("expecting language,country,variant but got more than three parts");
+ throw new MojoException("expecting language,country,variant but got more than three parts");
}
} else {
locale = Locale.getDefault();
@@ -143,7 +142,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
try {
format = new SimpleDateFormat(pattern, locale);
} catch (IllegalArgumentException e) {
- throw new MojoExecutionException(e.getMessage(), e);
+ throw new MojoException(e.getMessage(), e);
}
}
@@ -182,7 +181,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
format.setTimeZone(timeZone);
if ("build".equals(timeSource)) {
- defineProperty(name, format.format(mavenSession.getStartTime()));
+ defineProperty(name, format.format(new Date(session.getStartTime().toEpochMilli())));
} else {
defineProperty(name, format.format(calendar.getTime()));
}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertiesMojo.java
index cafd4be5..44ef29e0 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertiesMojo.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertiesMojo.java
@@ -26,11 +26,9 @@
import java.util.List;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
/**
* Sets multiple properties according to whether multiple sets of source and target resources are respectively up to
@@ -39,7 +37,7 @@
* @author Adrian Price demonfiddler@virginmedia.com
* @since 1.12
*/
-@Mojo(name = "uptodate-properties", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true)
+@Mojo(name = "uptodate-properties", defaultPhase = "validate")
public class UpToDatePropertiesMojo extends AbstractUpToDatePropertyMojo {
/**
* List of UpToDatePropertySetting
s to apply.
@@ -55,7 +53,7 @@ public class UpToDatePropertiesMojo extends AbstractUpToDatePropertyMojo {
/** {@inheritDoc} */
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ public void execute() throws MojoException, MojoException {
if (skip) {
getLog().info("uptodate-properties is skipped.");
return;
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertyMojo.java b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertyMojo.java
index 5d855975..db098a8c 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertyMojo.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertyMojo.java
@@ -24,11 +24,9 @@
* SOFTWARE.
*/
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.api.plugin.MojoException;
+import org.apache.maven.api.plugin.annotations.Mojo;
+import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.shared.model.fileset.FileSet;
/**
@@ -37,7 +35,7 @@
* @author Adrian Price demonfiddler@virginmedia.com
* @since 1.12
*/
-@Mojo(name = "uptodate-property", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true)
+@Mojo(name = "uptodate-property", defaultPhase = "validate")
public class UpToDatePropertyMojo extends AbstractUpToDatePropertyMojo {
/**
* The name of the property to set.
@@ -71,7 +69,7 @@ public class UpToDatePropertyMojo extends AbstractUpToDatePropertyMojo {
/** {@inheritDoc} */
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ public void execute() throws MojoException, MojoException {
if (skip) {
getLog().info("uptodate-property is skipped.");
return;
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertySetting.java b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertySetting.java
index f1e23e0a..b10b775a 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertySetting.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/UpToDatePropertySetting.java
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
-import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.shared.model.fileset.FileSet;
import org.codehaus.plexus.util.StringUtils;
@@ -93,7 +93,7 @@ public void setElse(String elseValue) {
this.elseValue = elseValue;
}
- void validate() {
+ public void validate() {
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException("name required");
}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/Artifact.java b/src/main/java/org/codehaus/mojo/buildhelper/utils/Artifact.java
similarity index 89%
rename from src/main/java/org/codehaus/mojo/buildhelper/Artifact.java
rename to src/main/java/org/codehaus/mojo/buildhelper/utils/Artifact.java
index 45c179ef..82d99c21 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/Artifact.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/utils/Artifact.java
@@ -1,4 +1,4 @@
-package org.codehaus.mojo.buildhelper;
+package org.codehaus.mojo.buildhelper.utils;
/*
* The MIT License
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
-import java.io.File;
+import java.nio.file.Path;
/**
*
@@ -34,7 +34,7 @@
* @author dtran
*/
public class Artifact {
- private File file;
+ private Path path;
private String type = "jar";
@@ -47,8 +47,8 @@ public class Artifact {
*
* @param localFile a {@link java.io.File} object.
*/
- public void setFile(File localFile) {
- this.file = localFile;
+ public void setPath(Path localFile) {
+ this.path = localFile;
}
/**
@@ -56,10 +56,10 @@ public void setFile(File localFile) {
* Getter for the field file
.
*
*
- * @return a {@link java.io.File} object.
+ * @return a {@link java.nio.file.Path} object.
*/
- public File getFile() {
- return this.file;
+ public Path getPath() {
+ return this.path;
}
/**
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/versioning/VersionInformation.java b/src/main/java/org/codehaus/mojo/buildhelper/utils/ParsedVersion.java
similarity index 81%
rename from src/main/java/org/codehaus/mojo/buildhelper/versioning/VersionInformation.java
rename to src/main/java/org/codehaus/mojo/buildhelper/utils/ParsedVersion.java
index a0e3dc9d..6bd772ac 100644
--- a/src/main/java/org/codehaus/mojo/buildhelper/versioning/VersionInformation.java
+++ b/src/main/java/org/codehaus/mojo/buildhelper/utils/ParsedVersion.java
@@ -1,4 +1,4 @@
-package org.codehaus.mojo.buildhelper.versioning;
+package org.codehaus.mojo.buildhelper.utils;
/*
* The MIT License
@@ -33,7 +33,7 @@
* @author Karl Heinz Marbaise khmarbaise@apache.org
*
*/
-public class VersionInformation {
+public class ParsedVersion {
private static final String MAJOR_MINOR_PATCH_PATTERN = "^((\\d+)(\\.(\\d+)(\\.(\\d+))?)?)";
private static final Pattern MAJOR_MINOR_PATCH = Pattern.compile(MAJOR_MINOR_PATCH_PATTERN);
@@ -42,6 +42,8 @@ public class VersionInformation {
private static final Pattern BUILD_NUMBER = Pattern.compile("(((\\-)(\\d+)(.*))?)|(\\.(.*))|(\\-(.*))|(.*)$");
+ private String version;
+
private int major;
private int minor;
@@ -100,7 +102,8 @@ private void parseMajorMinorPatchVersion(String version) {
}
}
- public VersionInformation(String version) {
+ public ParsedVersion(String version) {
+ this.version = version;
Matcher matcherDigits = DIGITS.matcher(version);
if (matcherDigits.matches()) {
parseMajorMinorPatchVersion(matcherDigits.group(1));
@@ -149,4 +152,31 @@ public String getQualifier() {
public void setQualifier(String qualifier) {
this.qualifier = qualifier;
}
+
+ public String getAsOSGiVersion() {
+ StringBuilder osgiVersion = new StringBuilder();
+ osgiVersion.append(this.getMajor());
+ osgiVersion.append("." + this.getMinor());
+ osgiVersion.append("." + this.getPatch());
+
+ if (this.getQualifier() != null || this.getBuildNumber() != 0) {
+ osgiVersion.append(".");
+
+ if (this.getBuildNumber() != 0) {
+ osgiVersion.append(this.getBuildNumber());
+ }
+ if (this.getQualifier() != null) {
+ // Do not allow having "." in it cause it's not allowed in OSGi.
+ String qualifier = this.getQualifier().replaceAll("\\.", "_");
+ osgiVersion.append(qualifier);
+ }
+ }
+
+ return osgiVersion.toString();
+ }
+
+ @Override
+ public String toString() {
+ return version;
+ }
}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/utils/Resource.java b/src/main/java/org/codehaus/mojo/buildhelper/utils/Resource.java
new file mode 100644
index 00000000..8f70ab17
--- /dev/null
+++ b/src/main/java/org/codehaus/mojo/buildhelper/utils/Resource.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.codehaus.mojo.buildhelper.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @since 4.0
+ */
+public class Resource {
+
+ List includes;
+ List excludes;
+ String directory;
+ String targetPath;
+ boolean filtering;
+ String mergeId;
+
+ public Resource() {}
+
+ public List getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(List includes) {
+ this.includes = includes;
+ }
+
+ public List getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(List excludes) {
+ this.excludes = excludes;
+ }
+
+ public String getDirectory() {
+ return directory;
+ }
+
+ public void setDirectory(String directory) {
+ this.directory = directory;
+ }
+
+ public String getTargetPath() {
+ return targetPath;
+ }
+
+ public void setTargetPath(String targetPath) {
+ this.targetPath = targetPath;
+ }
+
+ public boolean isFiltering() {
+ return filtering;
+ }
+
+ public void setFiltering(boolean filtering) {
+ this.filtering = filtering;
+ }
+
+ public String getMergeId() {
+ return mergeId;
+ }
+
+ public void setMergeId(String mergeId) {
+ this.mergeId = mergeId;
+ }
+
+ public void addInclude(String include) {
+ if (includes == null) {
+ includes = new ArrayList<>();
+ }
+ includes.add(include);
+ }
+
+ public void addExclude(String exclude) {
+ if (excludes == null) {
+ excludes = new ArrayList<>();
+ }
+ excludes.add(exclude);
+ }
+}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java b/src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java
deleted file mode 100644
index d0f953ca..00000000
--- a/src/main/java/org/codehaus/mojo/buildhelper/versioning/DefaultVersioning.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.codehaus.mojo.buildhelper.versioning;
-
-/**
- * @author Karl Heinz Marbaise khmarbaise@apache.org
- */
-public class DefaultVersioning implements Versioning {
-
- private VersionInformation vi;
-
- private String version;
-
- public DefaultVersioning(String version) {
- this.version = version;
- this.vi = new VersionInformation(version);
- }
-
- public String getVersion() {
- return this.version;
- }
-
- @Override
- public int getMajor() {
- return this.vi.getMajor();
- }
-
- @Override
- public int getMinor() {
- return this.vi.getMinor();
- }
-
- @Override
- public int getPatch() {
- return this.vi.getPatch();
- }
-
- @Override
- public String getAsOSGiVersion() {
- StringBuffer osgiVersion = new StringBuffer();
- osgiVersion.append(this.getMajor());
- osgiVersion.append("." + this.getMinor());
- osgiVersion.append("." + this.getPatch());
-
- if (this.getQualifier() != null || this.getBuildNumber() != 0) {
- osgiVersion.append(".");
-
- if (this.getBuildNumber() != 0) {
- osgiVersion.append(this.getBuildNumber());
- }
- if (this.getQualifier() != null) {
- // Do not allow having "." in it cause it's not allowed in OSGi.
- String qualifier = this.getQualifier().replaceAll("\\.", "_");
- osgiVersion.append(qualifier);
- }
- }
-
- return osgiVersion.toString();
- }
-
- @Override
- public long getBuildNumber() {
- return this.vi.getBuildNumber();
- }
-
- @Override
- public String getQualifier() {
- return this.vi.getQualifier();
- }
-}
diff --git a/src/main/java/org/codehaus/mojo/buildhelper/versioning/Versioning.java b/src/main/java/org/codehaus/mojo/buildhelper/versioning/Versioning.java
deleted file mode 100644
index 056e038d..00000000
--- a/src/main/java/org/codehaus/mojo/buildhelper/versioning/Versioning.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.codehaus.mojo.buildhelper.versioning;
-
-public interface Versioning {
-
- int getMajor();
-
- int getMinor();
-
- int getPatch();
-
- String getAsOSGiVersion();
-
- long getBuildNumber();
-
- String getQualifier();
-}
diff --git a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
index 3cf57ff9..89c267fe 100644
--- a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
+++ b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
@@ -24,8 +24,10 @@
* SOFTWARE.
*/
+import java.lang.reflect.Proxy;
import java.util.Properties;
+import org.apache.maven.api.plugin.Log;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -38,6 +40,13 @@ static class TestParseVersionMojo extends ParseVersionMojo {
TestParseVersionMojo(Properties properties) {
this.properties = properties;
+ this.log = (Log)
+ Proxy.newProxyInstance(getClass().getClassLoader(), new Class>[] {Log.class}, (o, m, params) -> {
+ if (params.length == 1 && params[0] instanceof CharSequence) {
+ System.out.println("[" + m.getName() + "] " + params[0]);
+ }
+ return null;
+ });
}
@Override
diff --git a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java b/src/test/java/org/codehaus/mojo/buildhelper/versioning/ParsedVersionTest.java
similarity index 93%
rename from src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java
rename to src/test/java/org/codehaus/mojo/buildhelper/versioning/ParsedVersionTest.java
index fa04a48f..285f017b 100644
--- a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java
+++ b/src/test/java/org/codehaus/mojo/buildhelper/versioning/ParsedVersionTest.java
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.codehaus.mojo.buildhelper.utils.ParsedVersion;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -29,7 +30,7 @@
/**
* @author Karl Heinz Marbaise khmarbaise@apache.org
*/
-class VersionInformationTest {
+class ParsedVersionTest {
// @formatter:off
private static Object[][] createVersions() {
return new Object[][] {
@@ -72,7 +73,7 @@ private static Object[][] createVersions() {
@ParameterizedTest
@MethodSource("createVersions")
void checkVersions(String version, int major, int minor, int patch, long buildNumber, String qualifier) {
- VersionInformation vi = new VersionInformation(version);
+ ParsedVersion vi = new ParsedVersion(version);
assertEquals(vi.getMajor(), major);
assertEquals(vi.getMinor(), minor);
assertEquals(vi.getPatch(), patch);
@@ -82,6 +83,6 @@ void checkVersions(String version, int major, int minor, int patch, long buildNu
@Test
void shouldFaileWithNumberFormatException() {
- assertThrows(NumberFormatException.class, () -> new VersionInformation("999999999999.12345678.12.beta_5"));
+ assertThrows(NumberFormatException.class, () -> new ParsedVersion("999999999999.12345678.12.beta_5"));
}
}