简体   繁体   中英

Maven artifact plugin buildinfo remove unwanted buildinfo information

On using

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-artifact-plugin</artifactId>
      <version>3.3.0</version>
    </plugin>

I am able to get buildinfo file generated as following as per https://reproducible-builds.org/docs/jvm/

#### Work In Progress ####
buildinfo.version=1.0-SNAPSHOT

name=name  
group-id=groupId  
artifact-id=artifact id   
version=version  

**source information**  
no scm configured in pom.xml  

**build instructions**  
build-tool=mvn

**effective build environment information**  
java.version=11
java.vendor=Oracle corporation
os.name=Linux

**Maven rebuild instructions and effective environment:**  
mvn.version=Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)


**output**  
outputs.0.filename=pom file name
outputs.0.length=<1234
outputs.0.checksums.sha512=abcd

Apart from name,group-id,artifact-id and version, i don't want other properties to be generated in that file. how can i configure that using maven-artifact-plugin

I have checked the doc https://maven.apache.org/plugins/maven-artifact-plugin/plugin-info.html , couldn't find example of removing unwanted information from getting generated in that file.

You may achieve something similar using maven-resources-plugin and optionally copy-rename-maven-plugin (if you need to get particular name of buildinfo file)

contents of.buildinfo:

name=${project.name}
group-id=${project.groupId}
artifact-id=${project.artifactId}
version=${project.version}

maven configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.2.0</version>
    <executions>
        <execution>
            <id>build-info</id>
            <goals>
                <goal>resources</goal>
            </goals>
            <configuration>
                <resources>
                    <resource>
                        <directory>${project.basedir}</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>.buildinfo</include>
                        </includes>
                    </resource>
                </resources>
                <outputDirectory>${project.build.directory}</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>com.coderplus.maven.plugins</groupId>
    <artifactId>copy-rename-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <id>copy-and-rename-file</id>
            <phase>process-resources</phase>
            <goals>
                <goal>rename</goal>
            </goals>
            <configuration>
                <sourceFile>${project.build.directory}/.buildinfo</sourceFile>
                <destinationFile>${project.build.directory}/${project.artifactId}-${project.version}.buildinfo</destinationFile>
            </configuration>
        </execution>
    </executions>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM