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

CreateMojo does not set buildIsTainted property if getRevisionOnlyOnce is set to false #204

Open
sad-poet opened this issue Oct 13, 2023 · 0 comments · May be fixed by #205
Open

CreateMojo does not set buildIsTainted property if getRevisionOnlyOnce is set to false #204

sad-poet opened this issue Oct 13, 2023 · 0 comments · May be fixed by #205

Comments

@sad-poet
Copy link

Steps to reproduce

  1. Create a Maven project which runs the create goal of buildnumber-maven-plugin and uses the generated buildIsTainted property:
    • by cloning the reproducer project, or
    • by running git init in an empty folder and writing a pom.xml file with settings shown below:
<packaging>jar</packaging>

<scm>
    <developerConnection>scm:git:https://git.organisation.example/namespace/project.git</developerConnection>
</scm>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <doCheck>true</doCheck>
                <getRevisionOnlyOnce>false</getRevisionOnlyOnce>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.3.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <Implementation-Build-Number>${buildNumber}</Implementation-Build-Number>
                        <Implementation-SCM-Branch>${scmBranch}</Implementation-SCM-Branch>
                        <Implementation-Build-Is-Tainted>${buildIsTainted}</Implementation-Build-Is-Tainted>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>
  1. Run mvn clean package.
  2. Unpack the produced JAR file in target/ directory.
  3. See the contents of META-INF/MANIFEST.MF.

Expected

A line is present in MANIFEST.MF which reads:

  1. Build-Is-Tainted: ok, if the working tree is clean, or
  2. Build-Is-Tainted: tainted otherwise.

Actual

The following line is present in MANIFEST.MF:

Build-Is-Tainted: 

which ends with a single space character.

Possible cause

The method CreateMojo#buildNumberAndTimeStampForReactorProjects does not add the buildIsTainted property to reactor projects, unless getRevisionOnlyOnce is set to true: https://github.com/mojohaus/buildnumber-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/build/CreateMojo.java#L448-L475

sad-poet added a commit to sad-poet/buildnumber-maven-plugin that referenced this issue Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant