Skip to content
Open
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
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
<maven.unix.debug>true</maven.unix.debug>
<gpg.homedir>${project.build.testOutputDirectory}/gnupg</gpg.homedir>
</properties>
<setupIncludes>
<setupInclude>sample-lib/pom.xml</setupInclude>
</setupIncludes>
<!-- <pomIncludes> <pomInclude>rpm-sign*/pom.xml</pomInclude> </pomIncludes> -->
<goals>
<goal>clean</goal>
Expand Down
16 changes: 16 additions & 0 deletions src/it/rpm-filter-scriptlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</executions>
<configuration>
<group>Application/Collectors</group>
<escapeString>\</escapeString>
<preinstallScriptlet>
<script>echo "installing ${project.artifactId}"</script>
</preinstallScriptlet>
Expand All @@ -40,6 +41,14 @@
<fileEncoding>utf-8</fileEncoding>
<filter>true</filter>
</postinstallScriptlet>
<preremoveScriptlet>
<scriptFile>classpath:preremove.sh</scriptFile>
<filter>true</filter>
</preremoveScriptlet>
<postremoveScriptlet>
<scriptFile>../sample-lib/src/scripts/postremove.sh</scriptFile>
<filter>true</filter>
</postremoveScriptlet>
<triggers>
<installTrigger>
<script>echo "a filtered install trigger for ${project.artifactId}"</script>
Expand All @@ -50,6 +59,13 @@
</installTrigger>
</triggers>
</configuration>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>sample-lib</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
8 changes: 8 additions & 0 deletions src/it/rpm-filter-scriptlet/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ assert specFile.text.contains("echo \"installing rpm-filter-scriptlet\"")
// Test if the post install <scriptFile> was filtered
assert specFile.text.contains("PROJECT_NAME=rpm-filter-scriptlet")

// Test if the pre remove <scriptFile> was filtered
assert specFile.text.contains("echo \"Erasing version 1.0\"")
assert specFile.text.contains("echo \"Erasing version (escaped) \${project.version}\"")

// Test if the post remove <scriptFile> was found and filtered (located in a relative path)
assert specFile.text.contains("echo \"Done erasing version 1.0\"")
assert specFile.text.contains("echo \"Done erasing version (escaped) \${project.version}\"")

// Test if the trigger script was filtered
assert specFile.text.contains("echo \"a filtered install trigger for rpm-filter-scriptlet\"")

Expand Down
11 changes: 11 additions & 0 deletions src/it/sample-lib/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>test</groupId>
<artifactId>sample-lib</artifactId>
<version>1.0</version>

</project>
4 changes: 4 additions & 0 deletions src/it/sample-lib/src/main/resources/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "Erasing version ${project.version}"
echo "Erasing version (escaped) \${project.version}"
4 changes: 4 additions & 0 deletions src/it/sample-lib/src/scripts/postremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "Done erasing version ${project.version}"
echo "Done erasing version (escaped) \${project.version}"
88 changes: 50 additions & 38 deletions src/main/java/org/codehaus/mojo/rpm/AbstractRPMMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class AbstractRPMMojo
/**
* The stage to build. Default to '-bb' but let users specify for instance '-ba' if they want source rpms as well.
*/
@Parameter( alias = "rpmbuildStage", property = "rpm.rpmbuild.stage", defaultValue = "-bb")
@Parameter( alias = "rpmbuildStage", property = "rpm.rpmbuild.stage", defaultValue = "-bb" )
private String rpmbuildStage;


Expand Down Expand Up @@ -619,7 +619,7 @@ abstract class AbstractRPMMojo
* Option to copy the created RPM to another location
* @since 2.1.
*/
@Parameter(property="rpm.copyTo")
@Parameter( property = "rpm.copyTo" )
private File copyTo;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -652,7 +652,7 @@ abstract class AbstractRPMMojo
* execution in projects with packaging "pom".
* @since 2.1.6
*/
@Parameter(defaultValue = "false")
@Parameter( defaultValue = "false" )
private boolean skipPOMs;

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -707,7 +707,7 @@ public final void execute()
{
if ( skipPOMs && isPOM() )
{
getLog().info("skipping because artifact is a pom (skipPOMs)");
getLog().info( "skipping because artifact is a pom (skipPOMs)" );
return;
}

Expand All @@ -730,7 +730,7 @@ public final void execute()
{
this.prefixes = new ArrayList<String>();
}
this.prefixes.add(prefix);
this.prefixes.add( prefix );
}

helper = new RPMHelper( this );
Expand Down Expand Up @@ -764,16 +764,19 @@ public final void execute()

afterExecution();

if ( this.copyTo != null ) {
makeSecondCopy();
if ( this.copyTo != null )
{
makeSecondCopy();
}
}

/**
* @return The Maven project used by this MOJO
*/
private MavenProject getProject() {
if (project.getExecutionProject() != null) {
MavenProject getProject()
{
if ( project.getExecutionProject() != null )
{
return project.getExecutionProject();
}

Expand All @@ -783,18 +786,22 @@ private MavenProject getProject() {
/**
* @return Whether the artifact is a POM or not
*/
private boolean isPOM() {
return "pom".equalsIgnoreCase(getProject().getArtifact().getType());
private boolean isPOM()
{
return "pom".equalsIgnoreCase( getProject().getArtifact().getType() );
}

private void makeSecondCopy() throws MojoFailureException {
try {
this.getLog().info( "Copy " + this.getRPMFile() + " to " + copyTo );
FileUtils.copyFile( this.getRPMFile(), copyTo );
}
catch ( IOException e ) {
throw new MojoFailureException( "Unable to copy file" );
}
private void makeSecondCopy() throws MojoFailureException
{
try
{
this.getLog().info( "Copy " + this.getRPMFile() + " to " + copyTo );
FileUtils.copyFile( this.getRPMFile(), copyTo );
}
catch ( IOException e )
{
throw new MojoFailureException( "Unable to copy file" );
}
}

/**
Expand Down Expand Up @@ -843,13 +850,16 @@ private void setDefaultWrappers()
throws MojoExecutionException
{
final MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
mavenResourcesExecution.setMavenProject( project );
mavenResourcesExecution.setFilters( filters );
mavenResourcesExecution.setEscapedBackslashesInFilePath( false );
mavenResourcesExecution.setMavenSession( session );
mavenResourcesExecution.setEscapeString( escapeString );

try
{
defaultFilterWrappers =
mavenFileFilter.getDefaultFilterWrappers( project, filters, false, this.session,
mavenResourcesExecution );
mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
Expand Down Expand Up @@ -925,20 +935,22 @@ private void checkParams( RPMHelper helper )
Log log = getLog();

// Retrieve any versions set by the VersionMojo
if ( versionProperty != null ) {
String projversion = this.project.getProperties().getProperty( versionProperty );
if ( projversion != null )
{
this.projversion = projversion;
}
}
if ( releaseProperty != null ) {
String release = this.project.getProperties().getProperty( releaseProperty );
if ( release != null )
{
this.release = release;
}
}
if ( versionProperty != null )
{
String projversion = this.project.getProperties().getProperty( versionProperty );
if ( projversion != null )
{
this.projversion = projversion;
}
}
if ( releaseProperty != null )
{
String release = this.project.getProperties().getProperty( releaseProperty );
if ( release != null )
{
this.release = release;
}
}

// calculate versions if neccessary, check for existing maven modifier and split them accordingly
if ( this.projversion == null || this.release == null || this.projversion.contains( "-" ) )
Expand Down Expand Up @@ -1631,15 +1643,15 @@ final List<FilterWrapper> getFilterWrappers()
/**
* @return the rpmbuildStage
*/
final public String getRpmbuildStage()
public final String getRpmbuildStage()
{
return rpmbuildStage;
}

/**
* @param rpmRpmbuildStage the rpmRpmbuildStage to set
* @param rpmbuildStage the rpmRpmbuildStage to set
*/
final public void setRpmbuildStage( String rpmbuildStage )
public final void setRpmbuildStage( String rpmbuildStage )
{
this.rpmbuildStage = rpmbuildStage;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/codehaus/mojo/rpm/AttachedRPMMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
* @author Brett Okken, Cerner Corp.
* @since 2.0-beta-2
*/
@Mojo( name = "attached-rpm", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true )
@Mojo( name = "attached-rpm", defaultPhase = LifecyclePhase.PACKAGE,
requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true )
public class AttachedRPMMojo
extends AbstractRPMMojo
{
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/org/codehaus/mojo/rpm/BaseTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* under the License.
*/

import org.apache.maven.shared.utils.io.FileUtils;

import java.io.IOException;
import java.io.PrintWriter;
Expand Down Expand Up @@ -90,16 +89,16 @@ protected String buildScriptletLine( String directive )
}

/**
* Writes the complete trigger directive. Use instead of {@link #write(PrintWriter, String)}.
* Writes the complete trigger directive.
*
* @param writer {@code PrintWriter} to write the trigger directive to.
* @param filterWrappers The filter wrappers to be applied when writing the content.
* @param mojo the {@code AbstractRPMMojo} which contains any resources needed when writing the trigger.
* @throws IOException
*/
protected void writeTrigger( PrintWriter writer, final List<FileUtils.FilterWrapper> filterWrappers )
protected void writeTrigger( PrintWriter writer, final AbstractRPMMojo mojo )
throws IOException
{
write( writer, getDirective(), filterWrappers );
write( writer, getDirective(), mojo );
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/codehaus/mojo/rpm/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ private List<Artifact> parseList( List<String> in )

for ( String s : in )
{
String[] parts = s.split(":");
String[] parts = s.split( ":" );
// Make sure we have group and artifact
if(parts.length == 0)
if ( parts.length == 0 )
{
throw new MojoExecutionException( "Include and exclude must include both group and artifact IDs." );
}
Expand All @@ -176,15 +176,15 @@ private List<Artifact> parseList( List<String> in )
String classifier = "";
VersionRange vr = null;

if(parts.length > 2)
if ( parts.length > 2 )
{
versionStr = parts[2];
if(parts.length > 3)
if ( parts.length > 3 )
{
type = parts[3];
}

if(parts.length > 4)
if ( parts.length > 4 )
{
classifier = parts[4];
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/codehaus/mojo/rpm/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -549,20 +549,20 @@ private boolean depMatcher( Artifact dep, List<Artifact> list )
if ( item.getVersionRange().containsVersion( dep.getSelectedVersion() ) )
{
log.debug( "... Version matches" );
if( item.getType().isEmpty() )
if ( item.getType().isEmpty() )
{
log.debug( "... Type is empty" );
return true;
}
else if( item.getType().equals( dep.getType() ))
else if ( item.getType().equals( dep.getType() ) )
{
log.debug( "... Type matches" );
if( item.getClassifier().isEmpty() )
if ( item.getClassifier().isEmpty() )
{
log.debug( "... Classifier is empty" );
return true;
}
else if( item.getClassifier().equals( dep.getClassifier() ))
else if ( item.getClassifier().equals( dep.getClassifier() ) )
{
log.debug( "... Classifier matches" );
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/codehaus/mojo/rpm/LogStreamConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ public void consumeLine( String line )
case DEBUG:
log.debug( line );
break;
case INFO:
log.info( line );
break;
case WARN:
log.warn( line );
break;
case ERROR:
log.error( line );
break;
case INFO:
default:
log.info( line );
}
}
}
6 changes: 5 additions & 1 deletion src/main/java/org/codehaus/mojo/rpm/RPMHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,15 @@ public String getArch()
try
{
if ( mojo.getLog().isDebugEnabled() )
{
mojo.getLog().debug( "About to execute \'" + cl.toString() + "\'" );
}
final int result = CommandLineUtils.executeCommandLine( cl, stdConsumer, errConsumer );
if ( result != 0 )
{
throw new MojoExecutionException( "rpm -E %{_arch} returned: \'" + result + "\' executing \'"
+ cl.toString() + "\'" );
+ cl.toString() + "\'" );
}
}
catch ( CommandLineException e )
{
Expand Down
Loading