Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpm package primary #40

Merged
merged 5 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions src/it/test14-primaryname/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.dentrassi.maven.rpm.test</groupId>
<artifactId>test14-primaryname</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>rpm</packaging>

<name>Test Package #14</name>
<description>
Test primary name
</description>

<url>http://dentrassi.de</url>

<organization>
<name>Jens Reimann</name>
<url>http://dentrassi.de</url>
</organization>

<licenses>
<license>
<name>Eclipse Public License - v 1.0</name>
<distribution>repo</distribution>
<url>https://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skipSigning>true</skipSigning>
<rpm.skipSigning>true</rpm.skipSigning>
</properties>

<build>

<plugins>
<plugin>
<groupId>de.dentrassi.maven</groupId>
<artifactId>rpm</artifactId>
<extensions>true</extensions>
<version>@project.version@</version>
<executions>
<execution>
<configuration>
<group>Application/Misc</group>

<forceRelease>false</forceRelease>
<version>1.0.0</version>

<signature>
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>sign</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skipSigning>false</skipSigning>
</properties>
</profile>
</profiles>

</project>
10 changes: 10 additions & 0 deletions src/it/test14-primaryname/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import java.io.File

myfile=null
basedir.eachDirRecurse{dir ->
dir.eachFileMatch(~/.*test14-primaryname-1.0.0-0.\d+.noarch.rpm.*/) { file ->
myfile=file
}
}

myfile != null
16 changes: 13 additions & 3 deletions src/main/java/de/dentrassi/rpm/builder/RpmMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Oliver Richter - Made packageName & defaultScriptInterpreter configurable
* Lucian Burja - Added setting for creating relocatable RPM packages
* Peter Wilkinson - add skip entry flag
* Daniel Singhal - Added primary artifact support
*******************************************************************************/
package de.dentrassi.rpm.builder;

Expand Down Expand Up @@ -740,7 +741,13 @@ public void execute () throws MojoExecutionException, MojoFailureException

if ( this.attach )
{
this.projectHelper.attachArtifact ( this.project, "rpm", this.classifier, builder.getTargetFile ().toFile () );
this.logger.info ( "attaching %s", this.classifier);
if ( "rpm".equals( project.getPackaging() ) ){
project.getArtifact().setFile( builder.getTargetFile().toFile() );
singhald marked this conversation as resolved.
Show resolved Hide resolved
} else {
this.projectHelper.attachArtifact ( this.project, "rpm", this.classifier, builder.getTargetFile ().toFile () );
}

}
}
catch ( final IOException e )
Expand All @@ -749,8 +756,7 @@ public void execute () throws MojoExecutionException, MojoFailureException
}
}

private Path makeTargetFile ( final Path targetDir )
{
private String makeTargetFilename() {
String outputFileName = this.outputFileName;

if ( outputFileName == null || outputFileName.isEmpty () )
Expand All @@ -766,7 +772,11 @@ private Path makeTargetFile ( final Path targetDir )
}
this.logger.debug ( "Using generated file name - %s", outputFileName, outputFileName );
}
return outputFileName;
}

private Path makeTargetFile ( final Path targetDir ) {
String outputFileName = makeTargetFilename();
final Path targetFile = targetDir.resolve ( outputFileName );;
this.logger.debug ( "Resolved output file name - fileName: %s, fullName: %s", this.outputFileName, targetFile );
return targetFile;
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/META-INF/plexus/components.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>rpm</role-hint>
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
<configuration>
<phases>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
<package>de.dentrassi.maven:rpm:rpm</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</configuration>
</component>
</components>
</component-set>

178 changes: 178 additions & 0 deletions src/site/apt/example-primary.apt.vm
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
------
RPM Builder Plugin - Example Primary Artifact
------
Daniel Singhal
------
2019-07-22
-----

Example configuration #2

This is an example configuration showing how to use the plugin to create an RPM as the primary project artifact

+----+
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.dentrassi.maven.rpm.test</groupId>
<artifactId>emptyTest1</artifactId> <!-- used as package name -->
<version>1.0.0-SNAPSHOT</version> <!-- used as version -->
<packaging>rpm</packaging> <!-- Primary Artifact Configuration -->

<name>Test Package #2 -- Primary</name> <!-- used for "summary" field -->

<!-- used for "description" field -->
<description>
This is some long long text about foo bar and all the rest.
</description>

<url>http://dentrassi.de</url> <!-- used for URL field -->

<!--
Packager: Jens Reimann <http:/dentrassi.de>
Vendor: Jens Reimann
-->
<organization>
<name>Jens Reimann</name>
<url>http://dentrassi.de</url>
</organization>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- For managing PGP Signing of RPM -->
<rpm.skipSigning>true</rpm.skipSigning> <!-- Primary Artifact Configuration(s) -->
</properties>

<build>

<plugins>
<plugin>
<groupId>de.dentrassi.maven</groupId>
<artifactId>rpm</artifactId>
<version>${project.version}</version>
<!-- Tell MVN that the plugin has a packaging option -->
<extensions>true</extensions> <!-- Primary Artifact Configuration -->
<executions>
<execution>

<goals>
<goal>rpm</goal>
</goals>

<configuration>
<attach>false</attach> <!-- don't attach RPM as a secondary artifact -->
<group>Application/Misc</group> <!-- set RPM group -->

<!-- rule sets -->

<rulesets>
<ruleset>
<id>my-default</id>
<rules>
<rule>
<when>
<type>directory</type>
</when>
<mode>0750</mode>
</rule>
<rule>
<when>
<prefix>/etc/</prefix>
</when>
<configuration>true</configuration>
</rule>
<file>
<when>
<prefix>/usr/shar/doc/</prefix>
</when>
<documentation>true</documentation>
</file>
<file>
<when>
<suffix>README.txt</suffix>
</when>
<readme>true</readme>
</file>
<rule>
<when>
<type>file</type>
<prefix>/usr/lib/foobar/lib/dir1</prefix>
</when>
<user>foo</user>
<group>bar</group>
</rule>
</rules>
</ruleset>
</rulesets>

<entries>

<!-- add explicit directory -->

<entry>
<name>/etc/foo</name>
<directory>true</directory>
<user>root</user>
<group>root</group>
<mode>0755</mode>

<!-- will use the default ruleset -->

</entry>

<!-- add single file -->

<entry>
<name>/etc/foo/bar.txt</name>
<file>src/main/resources/bar.txt</file>
<user>root</user>
<group>root</group>
<mode>0600</mode>
<ruleset>my-default</ruleset>
</entry>

<!-- collect all files from : target/classes -->

<entry>
<name>/usr/lib/foobar</name>
<collect>
<from>target/classes</from>
</collect>
<ruleset>my-default</ruleset>
</entry>

<!-- collect all files from : src/main/resources/etc -->

<entry>
<name>/etc</name>
<collect>
<from>src/main/resources/etc</from>
<directories>false</directories> <!-- make implicit directories -->
</collect>
<ruleset>my-default</ruleset>
</entry>

<!-- collect all files from : src/main/resources/lib -->

<entry>
<name>/usr/lib</name>
<collect>
<from>src/main/resources/lib</from>
<directories>true</directories> <!-- make explicit directories -->
</collect>
<ruleset>my-default</ruleset>
</entry>

</entries>

</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
+----+