From 9eb56ef566ff6457f48825bbbaf219638bc11d6e Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Fri, 9 Feb 2024 21:53:13 +0100 Subject: [PATCH] Port to maven-plugin-annotations from Javadoc tags --- ...plugin-annotations-from-Javadoc-tags.patch | 390 ++++++++++++++++++ replacer.spec | 8 +- 2 files changed, 397 insertions(+), 1 deletion(-) create mode 100644 0001-Port-to-maven-plugin-annotations-from-Javadoc-tags.patch diff --git a/0001-Port-to-maven-plugin-annotations-from-Javadoc-tags.patch b/0001-Port-to-maven-plugin-annotations-from-Javadoc-tags.patch new file mode 100644 index 0000000..ab947a6 --- /dev/null +++ b/0001-Port-to-maven-plugin-annotations-from-Javadoc-tags.patch @@ -0,0 +1,390 @@ +From 6959fc7950013a2e94cb30aa008e78f01a03ed63 Mon Sep 17 00:00:00 2001 +From: Mikolaj Izdebski +Date: Fri, 9 Feb 2024 21:52:37 +0100 +Subject: [PATCH] Port to maven-plugin-annotations from Javadoc tags + +--- + pom.xml | 6 + + .../maven_replacer_plugin/ReplacerMojo.java | 111 ++++++------------ + 2 files changed, 43 insertions(+), 74 deletions(-) + +diff --git a/pom.xml b/pom.xml +index 9d2de74..4a2efed 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -156,6 +156,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI + 3.0.3 + compile + ++ ++ org.apache.maven.plugin-tools ++ maven-plugin-annotations ++ 3.11.0 ++ provided ++ + + org.apache.ant + ant +diff --git a/src/main/java/com/google/code/maven_replacer_plugin/ReplacerMojo.java b/src/main/java/com/google/code/maven_replacer_plugin/ReplacerMojo.java +index ac165a9..de4fdc3 100644 +--- a/src/main/java/com/google/code/maven_replacer_plugin/ReplacerMojo.java ++++ b/src/main/java/com/google/code/maven_replacer_plugin/ReplacerMojo.java +@@ -14,18 +14,14 @@ import java.util.regex.PatternSyntaxException; + + import org.apache.maven.plugin.AbstractMojo; + import org.apache.maven.plugin.MojoExecutionException; +- ++import org.apache.maven.plugins.annotations.LifecyclePhase; ++import org.apache.maven.plugins.annotations.Mojo; ++import org.apache.maven.plugins.annotations.Parameter; + + /** + * Goal replaces token with value inside file +- * +- * @goal replace +- * +- * @phase compile +- * +- * @threadSafe +- * + */ ++@Mojo(name="replace", defaultPhase=LifecyclePhase.COMPILE, threadSafe=true) + public class ReplacerMojo extends AbstractMojo { + private static final String INVALID_IGNORE_MISSING_FILE_MESSAGE = " only useable with "; + private static final String REGEX_PATTERN_WITH_DELIMITERS_MESSAGE = "Error: %s. " + +@@ -47,27 +43,24 @@ public class ReplacerMojo extends AbstractMojo { + * Path to single file to replace tokens in. + * The file must be text (ascii). + * Based on current execution path. +- * +- * @parameter + */ ++ @Parameter + private String file; + + /** + * List of files to include for multiple (or single) replacement. + * In Ant format (*\/directory/**.properties) + * Cannot use with outputFile. +- * +- * @parameter + */ ++ @Parameter + private List includes = new ArrayList(); + + /** + * List of files to exclude for multiple (or single) replacement. + * In Ant format (*\/directory/**.properties) + * Cannot use with outputFile. +- * +- * @parameter + */ ++ @Parameter + private List excludes = new ArrayList(); + + /** +@@ -75,9 +68,8 @@ public class ReplacerMojo extends AbstractMojo { + * This is split up and used the same way a array of includes would be. + * In Ant format (*\/directory/**.properties). + * Files not found are ignored by default. +- * +- * @parameter + */ ++ @Parameter + private String filesToInclude; + + /** +@@ -85,27 +77,24 @@ public class ReplacerMojo extends AbstractMojo { + * This is split up and used the same way a array of excludes would be. + * In Ant format (**\/directory/do-not-replace.properties). + * The files replaced will be derived from the list of includes and excludes. +- * +- * @parameter + */ ++ @Parameter + private String filesToExclude; + + /** + * Token to replace. + * The text to replace within the given file. + * This may or may not be a regular expression (see regex notes above). +- * +- * @parameter + */ ++ @Parameter + private String token; + + /** + * Token file containing a token to be replaced in the target file/s. + * May be multiple words or lines. + * This is useful if you do not wish to expose the token within your pom or the token is long. +- * +- * @parameter + */ ++ @Parameter + private String tokenFile; + + /** +@@ -113,9 +102,8 @@ public class ReplacerMojo extends AbstractMojo { + * Use only with file configuration (not includes etc). + * Set to true to not fail build if the file is not found. + * First checks if file exists and exits without attempting to replace anything. +- * +- * @parameter + */ ++ @Parameter + private boolean ignoreMissingFile; + + /** +@@ -123,26 +111,23 @@ public class ReplacerMojo extends AbstractMojo { + * The text to be written over any found tokens. + * If no value is given, the tokens found are replaced with an empty string (effectively removing any tokens found). + * You can also reference grouped regex matches made in the token here by $1, $2, etc. +- * +- * @parameter + */ ++ @Parameter + private String value; + + /** + * A file containing a value to replace the given token with. + * May be multiple words or lines. + * This is useful if you do not wish to expose the value within your pom or the value is long. +- * +- * @parameter + */ ++ @Parameter + private String valueFile; + + /** + * Indicates if the token should be located with regular expressions. + * This should be set to false if the token contains regex characters which may miss the desired tokens or even replace the wrong tokens. +- * +- * @parameter + */ ++ @Parameter + private boolean regex = true; + + /** +@@ -151,18 +136,16 @@ public class ReplacerMojo extends AbstractMojo { + * The path and file are created if it does not exist. + * If it does exist, the contents are overwritten. + * You should not use outputFile when using a list of includes. +- * +- * @parameter + */ ++ @Parameter + private String outputFile; + + /** + * Output to another dir. + * Destination directory relative to the execution directory for all replaced files to be written to. + * Use with outputDir to have files written to a specific base location. +- * +- * @parameter + */ ++ @Parameter + private String outputDir; + + /** +@@ -171,9 +154,8 @@ public class ReplacerMojo extends AbstractMojo { + * This file may contain multiple entries to support a single file containing different tokens to have replaced. + * Each token/value pair should be in the format: "token=value" (without quotations). + * If your token contains ='s you must escape the = character to \=. e.g. tok\=en=value +- * +- * @parameter + */ ++ @Parameter + private String tokenValueMap; + + /** +@@ -181,9 +163,8 @@ public class ReplacerMojo extends AbstractMojo { + * Path to base relative files for replacements from. + * This feature is useful for multi-module projects. + * Default "." which is the default Maven basedir. +- * +- * @parameter default-value="." + */ ++ @Parameter(defaultValue = ".") + private String basedir = "."; + + /** +@@ -197,18 +178,16 @@ public class ReplacerMojo extends AbstractMojo { + * * MULTILINE + * * UNICODE_CASE + * * UNIX_LINES +- * +- * @parameter + */ ++ @Parameter + private List regexFlags; + + /** + * List of replacements with token/value pairs. + * Each replacement element to contain sub-elements as token/value pairs. + * Each token within the given file will be replaced by it's respective value. +- * +- * @parameter + */ ++ @Parameter + private List replacements; + + /** +@@ -216,52 +195,46 @@ public class ReplacerMojo extends AbstractMojo { + * Comment lines start with '#'. + * If your token starts with an '#' then you must supply the commentsEnabled parameter and with a value of false. + * Default is true. +- * +- * @parameter default-value="true" + */ ++ @Parameter(defaultValue = "true") + private boolean commentsEnabled = true; + + /** + * Skip running this plugin. + * Default is false. +- * +- * @parameter default-value="false" + */ ++ @Parameter(defaultValue = "false") + private boolean skip = false; + + /** + * Base directory (appended) to use for outputDir. + * Having this existing but blank will cause the outputDir + * to be based on the execution directory. +- * +- * @parameter + */ ++ @Parameter + private String outputBasedir; + + /** + * Parent directory is preserved when replacing files found from includes and + * being written to an outputDir. + * Default is true. +- * +- * @parameter default-value="true" + */ ++ @Parameter(defaultValue = "true") + private boolean preserveDir = true; + + /** + * Stops printing a summary of files that have had replacements performed upon them when true. + * Default is false. +- * +- * @parameter default-value="false" + */ ++ @Parameter(defaultValue = "false") + private boolean quiet = false; + + /** + * Unescape tokens and values to Java format. + * e.g. token\n is unescaped to token(carriage return). + * Default is false. +- * +- * @parameter default-value="false" + */ ++ @Parameter(defaultValue = "false") + private boolean unescape; + + /** +@@ -269,9 +242,8 @@ public class ReplacerMojo extends AbstractMojo { + * You may also use the '' character to place the token in the desired location for matching. + * e.g. @ would match @token@. + * e.g. ${} would match ${token}. +- * +- * @parameter + */ ++ @Parameter + private List delimiters = new ArrayList(); + + /** +@@ -280,9 +252,8 @@ public class ReplacerMojo extends AbstractMojo { + * This parameter may contain multiple entries to support a single file containing different tokens to have replaced. + * Format is comma separated. e.g. token=value,token2=value2 + * Comments are not supported. +- * +- * @parameter + */ ++ @Parameter + private String variableTokenValueMap; + + /** +@@ -293,34 +264,30 @@ public class ReplacerMojo extends AbstractMojo { + * Only usable with file parameter. + * + * Default is false. +- * +- * @parameter default-value="false" + */ ++ @Parameter(defaultValue = "false") + private boolean ignoreErrors; + + /** + * X-Path expression for locating node's whose content you wish to replace. + * This is useful if you have the same token appearing in many nodes but + * wish to only replace the contents of one or more of them. +- * +- * @parameter + */ ++ @Parameter + private String xpath; + + /** + * File encoding used when reading and writing files. + * Default system encoding used when not specified. +- * +- * @parameter default-value="${project.build.sourceEncoding}" + */ ++ @Parameter(defaultValue = "${project.build.sourceEncoding}") + private String encoding; + + /** + * Regular expression is run on an input file's name to create the output file with. + * Must be used in conjunction with outputFilePattern. +- * +- * @parameter + */ ++ @Parameter + private String inputFilePattern; + + /** +@@ -328,30 +295,26 @@ public class ReplacerMojo extends AbstractMojo { + * Must be used in conjunction with inputFilePattern. + * + * The parameter outputFile is ignored when outputFilePattern is used. +- * +- * @parameter + */ ++ @Parameter + private String outputFilePattern; + + /** + * Set a maximum number of files which can be replaced per execution. +- * +- * @parameter + */ ++ @Parameter + private Integer maxReplacements = Integer.MAX_VALUE; + + /** + * list files +- * +- * @parameter + */ ++ @Parameter + private List files = new ArrayList(); + + /** + * list out put file +- * +- * @parameter + */ ++ @Parameter + private List outputFiles = new ArrayList(); + + public ReplacerMojo() { +-- +2.41.0 + diff --git a/replacer.spec b/replacer.spec index 0af6113..5061e78 100644 --- a/replacer.spec +++ b/replacer.spec @@ -1,17 +1,19 @@ Name: replacer Version: 1.6 -Release: 28%{?dist} +Release: 29%{?dist} Summary: Replacer Maven Mojo License: MIT URL: https://github.com/beiliubei/maven-replacer-plugin # http://code.google.com/p/maven-replacer-plugin/ Source0: https://github.com/beiliubei/maven-replacer-plugin/archive/%{version}.tar.gz +Patch0: 0001-Port-to-maven-plugin-annotations-from-Javadoc-tags.patch BuildRequires: maven-local BuildRequires: mvn(commons-io:commons-io) BuildRequires: mvn(org.apache.ant:ant) BuildRequires: mvn(org.apache.commons:commons-lang3) BuildRequires: mvn(org.apache.maven:maven-plugin-api) +BuildRequires: mvn(org.apache.maven.plugin-tools:maven-plugin-annotations) BuildRequires: mvn(org.apache.maven.plugins:maven-plugin-plugin) BuildRequires: mvn(xerces:xercesImpl) @@ -32,6 +34,7 @@ This package contains javadoc for %{name}. %prep %setup -q -n maven-replacer-plugin-%{version} +%patch0 -p1 # remove unnecessary dependency on parent POM %pom_remove_parent @@ -70,6 +73,9 @@ done %license LICENSE %changelog +* Fri Feb 09 2024 Mikolaj Izdebski - 1.6-29 +- Port to maven-plugin-annotations from Javadoc tags + * Fri Jan 26 2024 Fedora Release Engineering - 1.6-28 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild