diff --git a/README.md b/README.md
index 1ddf29e..b7d7acc 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# RPM builder plugin [![Build status](https://api.travis-ci.org/ctron/rpm-builder.svg)](https://travis-ci.org/ctron/rpm-builder) ![Maven Central](https://img.shields.io/maven-central/v/de.dentrassi.maven/rpm.svg "Maven Central Status")
+# RPM builder plugin ![Maven Central](https://img.shields.io/maven-central/v/com.github.fracpete/rpm-maven-plugin.svg "Maven Central Status")
This is a Maven Plugin which can build RPM files using plain Java.
It does not require the `rpmbuild` command line tool.
@@ -7,7 +7,7 @@ It does not require the `rpmbuild` command line tool.
## Usage
For more information about how to use this plugin see
-[the documentation](https://ctron.github.io/rpm-builder).
+[the documentation](https://fracpete.github.io/rpm-builder).
## License
diff --git a/RELEASE.md b/RELEASE.md
index 5d830d2..c7284ec 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -8,7 +8,16 @@ Ensure that `.m2/settings.xml` contains the GitHub credentials:
github
-
+
+
+
+
+And also your Sonatype account:
+
+
+ ossrh
+
+
diff --git a/pom.xml b/pom.xml
index 5cce37e..2b058c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,16 +1,17 @@
4.0.0
- de.dentrassi.maven
- rpm
- 1.3.1-SNAPSHOT
+ com.github.fracpete
+ rpm-maven-plugin
+ 1.4.1-SNAPSHOT
maven-plugin
Java RPM builder
- Build RPM packages using plain Java on any platform
+ Build RPM packages using plain Java on any platform.
+ Fork of https://github.com/ctron/rpm-builder
- https://ctron.github.io/rpm-builder
+ https://fracpete.github.io/rpm-builder
2016
@@ -24,14 +25,14 @@
- https://github.com/ctron/rpm-builder
- scm:git:git://github.com/ctron/rpm-builder.git
- scm:git:git@github.com:ctron/rpm-builder.git
- HEAD
+ https://github.com/fracpete/rpm-builder
+ scm:git:git://github.com/fracpete/rpm-builder.git
+ scm:git:git@github.com:fracpete/rpm-builder.git
+ rpm-maven-plugin-1.4.0
- https://github.com/ctron/rpm-builder/issues
+ https://github.com/fracpete/rpm-builder/issues
GitHub
@@ -39,6 +40,8 @@
UTF-8
UTF-8
8
+ 1.8
+ 1.8
3.3.9
@@ -122,6 +125,12 @@
1.12
+
+ com.github.fracpete
+ simple-maven-file-filtering
+ 0.0.2
+
+
@@ -143,6 +152,8 @@
maven-compiler-plugin
3.8.0
+
+ ${maven.compiler.target}
8
@@ -405,7 +416,7 @@
install
- integration-test
+
verify
diff --git a/src/main/java/de/dentrassi/rpm/builder/PackageEntry.java b/src/main/java/de/dentrassi/rpm/builder/PackageEntry.java
index ccfeef5..f727b02 100644
--- a/src/main/java/de/dentrassi/rpm/builder/PackageEntry.java
+++ b/src/main/java/de/dentrassi/rpm/builder/PackageEntry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 IBH SYSTEMS GmbH and others.
+ * Copyright (c) 2016,2019 IBH SYSTEMS GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBH SYSTEMS GmbH - initial API and implementation
+ * University of Waikato - added filterFile flag
*******************************************************************************/
package de.dentrassi.rpm.builder;
@@ -95,6 +96,8 @@ public String toString ()
private String ruleset;
+ private boolean filterFile;
+
public String getName ()
{
return this.name;
@@ -155,6 +158,16 @@ public String getRuleset ()
return this.ruleset;
}
+ public void setFilterFile( final boolean filterFile )
+ {
+ this.filterFile = filterFile;
+ }
+
+ public boolean getFilterFile()
+ {
+ return this.filterFile;
+ }
+
@Override
public void validate ()
{
diff --git a/src/main/java/de/dentrassi/rpm/builder/RpmMojo.java b/src/main/java/de/dentrassi/rpm/builder/RpmMojo.java
index 19a15c7..abab0f1 100644
--- a/src/main/java/de/dentrassi/rpm/builder/RpmMojo.java
+++ b/src/main/java/de/dentrassi/rpm/builder/RpmMojo.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2018 IBH SYSTEMS GmbH and others.
+ * Copyright (c) 2016, 2018, 2019 IBH SYSTEMS GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,32 +13,15 @@
* Lucian Burja - Added setting for creating relocatable RPM packages
* Peter Wilkinson - add skip entry flag
* Daniel Singhal - Added primary artifact support
+ * University of Waikato - applying the filterFile flag in fillFromEntryFile
*******************************************************************************/
package de.dentrassi.rpm.builder;
-import static java.nio.charset.StandardCharsets.US_ASCII;
-import static java.nio.file.Files.readAllLines;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.file.FileAlreadyExistsException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.format.DateTimeFormatter;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
+import com.github.fracpete.simplemavenfilefiltering.FilterUtils;
+import com.google.common.base.Strings;
+import com.google.common.io.CharSource;
+import de.dentrassi.rpm.builder.Naming.Case;
+import de.dentrassi.rpm.builder.PackageEntry.Collector;
import org.apache.maven.model.License;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -65,11 +48,30 @@
import org.eclipse.packager.rpm.signature.RsaHeaderSignatureProcessor;
import org.eclipse.packager.rpm.signature.SignatureProcessor;
-import com.google.common.base.Strings;
-import com.google.common.io.CharSource;
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.file.FileAlreadyExistsException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
-import de.dentrassi.rpm.builder.Naming.Case;
-import de.dentrassi.rpm.builder.PackageEntry.Collector;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static java.nio.file.Files.readAllLines;
/**
* Build an RPM file
@@ -1027,17 +1029,48 @@ private void fillFromEntryDirectory ( final BuilderContext ctx, final PackageEnt
ctx.addDirectory ( entry.getName (), makeProvider ( entry, " - " ) );
}
+ private Map getAdditionalVars()
+ {
+ HashMap additional = new HashMap<>();
+ additional.put("packageName", packageName);
+ additional.put("packager", packager);
+ additional.put("description", description);
+ additional.put("distribution", distribution);
+ additional.put("group", group);
+ additional.put("sourcePackage", sourcePackage);
+ additional.put("vendor", vendor);
+ additional.put("version", version);
+ return additional;
+ }
+
private void fillFromEntryFile ( final BuilderContext ctx, final PackageEntry entry ) throws IOException
{
this.logger.debug ( " as file:" );
final Path source = entry.getFile ().toPath ().toAbsolutePath ();
this.logger.debug ( " - source: %s", source );
- ctx.addFile ( entry.getName (), source, makeProvider ( entry, " - " ) );
+ if (entry.getFilterFile())
+ {
+ File tmpFile = new File( System.getProperty( "java.io.tmpdir" ) + File.separator + "rpm-" + System.currentTimeMillis() + "-" + entry.getFile().getName() );
+ tmpFile.deleteOnExit();
+ final Path filtered = tmpFile.toPath();
+ FilterUtils.filterFile( getLog(), source, filtered, project.getModel(), getAdditionalVars() );
+ this.logger.debug ( " - filtered: %s", filtered );
+ ctx.addFile ( entry.getName (), filtered, makeProvider ( entry, " - " ) );
+ }
+ else
+ {
+ ctx.addFile ( entry.getName (), source, makeProvider ( entry, " - " ) );
+ }
}
private void fillFromEntryLinkTo ( final BuilderContext ctx, final PackageEntry entry ) throws IOException
{
+ if (entry.getFilterFile())
+ {
+ getLog().error( "Cannot filter symbolic link: " + entry.getLinkTo() );
+ }
+
this.logger.debug ( " as symbolic link:" );
this.logger.debug ( " - linkTo: %s", entry.getLinkTo () );
ctx.addSymbolicLink ( entry.getName (), entry.getLinkTo (), makeProvider ( entry, " - " ) );
@@ -1045,6 +1078,12 @@ private void fillFromEntryLinkTo ( final BuilderContext ctx, final PackageEntry
private void fillFromEntryCollect ( final BuilderContext ctx, final PackageEntry entry ) throws IOException
{
+
+ if (entry.getFilterFile())
+ {
+ getLog().error( "Cannot filter from collect: " + entry.getName() );
+ }
+
this.logger.debug ( " as collector:" );
final Collector collector = entry.getCollect ();
@@ -1110,7 +1149,6 @@ private void fillFromEntryCollect ( final BuilderContext ctx, final PackageEntry
{
RpmMojo.this.logger.debug ( "%s%s (file)", padding, file );
RpmMojo.this.logger.debug ( "%s - target: %s", padding, targetName );
-
ctx.addFile ( targetName, file, provider );
}
}
diff --git a/src/site/markdown/entry.md b/src/site/markdown/entry.md
index 5c8d64b..2aa3fb2 100644
--- a/src/site/markdown/entry.md
+++ b/src/site/markdown/entry.md
@@ -40,6 +40,29 @@ There is no need for additional source information.
Adding a single file is done by: `path/to/file`. The path to the file is relative
to the Maven project.
+Since version `1.3.1`, you can add `true`,
+if you want the file content to be filtered before being added to the RPM.
+This allows you to place variables (`${varname}`) in the file and have them
+expanded on-the-fly.
+
+In terms of what variables are supported, there are two types:
+The *first* type being POM related ones, that start with `project.` like
+`project.name` or `project.version`. Sub-properties from properties
+in the POM that allow multiple values, like `licenses` can access these
+via `[index]`, with the index being 0-based. The *second* type are
+ones specific to this plugin. Here is a list of supported variables:
+
+```
+description
+distribution
+group
+packageName
+packager
+sourcePackage
+vendor
+version
+```
+
### Symbolic link
Adding a single file is done by: `link/target`. The path where the