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

Fix GH-204: 'create' mojo does not set buildIsTainted property #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 src/main/java/org/codehaus/mojo/build/CreateMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ private void buildNumberAndTimeStampForReactorProjects( Date now, String tainted
getLog().info( "Storing scmBranch: " + scmBranch );
project.getProperties().put( scmBranchPropertyName, scmBranch );

getLog().info( "Storing buildIsTainted: " + taintedValue );
project.getProperties().put( buildTaintedPropertyName, taintedValue );

// Add the revision and timestamp properties to each project in the reactor
if ( getRevisionOnlyOnce && reactorProjects != null )
{
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/org/codehaus/mojo/build/it/BuildNumberMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,54 @@ public void basicItGitTest()
Assert.assertEquals( "6d36c746e82f00c5913954f9178f40224497b2f3", scmRev );
}

@Test
public void buildIsTaintedGitPristineTest()
throws Exception
{
File projDir = resources.getBasedir( "buildIsTainted-git-pristine-it" );

MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectoryStructure( new File( testDir, "dotGitDir" ), new File( testDir, ".git" ) );
result = mavenExec.execute( "clean", "verify" );
result.assertLogText( "Storing buildNumber: 9ff09c02fdf660bcf33beb6a89bc91765e81b367" );
result.assertLogText( "Storing scmBranch: master" );
result.assertLogText( "Storing buildIsTainted: ok" );

File artifact = new File( testDir, "target/buildnumber-maven-plugin-buildIsTainted-git-pristine-it-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String scmRev = manifest.getValue( "Build-Is-Tainted" );
Assert.assertEquals( "ok", scmRev );
}

@Test
public void buildIsTaintedGitTaintedTest()
throws Exception
{
File projDir = resources.getBasedir( "buildIsTainted-git-tainted-it" );

MavenExecution mavenExec = maven.forProject( projDir );
MavenExecutionResult result = mavenExec.execute( "clean" );
result.assertErrorFreeLog();
File testDir = result.getBasedir();
FileUtils.copyDirectoryStructure( new File( testDir, "dotGitDir" ), new File( testDir, ".git" ) );
result = mavenExec.execute( "clean", "verify" );
result.assertLogText( "Storing buildNumber: 1049d0dc796ae4c1e2cfc343555ad8667bfc64bb" );
result.assertLogText( "Storing scmBranch: master" );
result.assertLogText( "Storing buildIsTainted: tainted" );

File artifact = new File( testDir, "target/buildnumber-maven-plugin-buildIsTainted-git-tainted-it-1.0-SNAPSHOT.jar" );
JarFile jarFile = new JarFile( artifact );
Attributes manifest = jarFile.getManifest().getMainAttributes();
jarFile.close();
String scmRev = manifest.getValue( "Build-Is-Tainted" );
Assert.assertEquals( "tainted", scmRev );
}

@Test
public void basicItClearcaseScmTest()
throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref: refs/heads/master
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x­ÎA‚0@Q×=Åì‰ÍL©eHŒÑ£”vjI)‰Þ^6ÞÀí[üüSš+ƒ§ZDÀ³/‘Ex‡€#uÒwâÂà­Æ6õh•ßë” l>ž×,®dCC­k~vß7)›~å"ëòÑϹNû CN7 ×w¦e² DuèñQåEõˆÖœô;-ê ¢²G7
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9ff09c02fdf660bcf33beb6a89bc91765e81b367
51 changes: 51 additions & 0 deletions src/test/projects/buildIsTainted-git-pristine-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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>org.codehaus.mojo.it</groupId>
<artifactId>buildnumber-maven-plugin-buildIsTainted-git-pristine-it</artifactId>
<version>1.0-SNAPSHOT</version>

<scm>
<developerConnection>scm:git:https://git.organization.example/example-project/example-repository.git</developerConnection>
</scm>

<build>

<defaultGoal>package</defaultGoal>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>${it-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<failTheBuild>false</failTheBuild>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Build-Is-Tainted>${buildIsTainted}</Build-Is-Tainted>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>

</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref: refs/heads/master
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1049d0dc796ae4c1e2cfc343555ad8667bfc64bb
56 changes: 56 additions & 0 deletions src/test/projects/buildIsTainted-git-tainted-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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>org.codehaus.mojo.it</groupId>
<artifactId>buildnumber-maven-plugin-buildIsTainted-git-tainted-it</artifactId>
<version>1.0-SNAPSHOT</version>

<scm>
<developerConnection>scm:git:https://git.organization.example/example-project/example-repository.git</developerConnection>
</scm>

<!--
This comment has been added to POM but not committed into Git
in order to force the "tainted" value for the "buildIsTainted" property.
-->

<build>

<defaultGoal>package</defaultGoal>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>${it-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>true</doCheck>
<failTheBuild>false</failTheBuild>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Build-Is-Tainted>${buildIsTainted}</Build-Is-Tainted>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>

</build>

</project>
Loading