When I build my project using the Spring Boot Maven Plugin I get two jar files: foo.jar
and foo.jar.original
. I understand that I can use fileName
to call the repackaged one something else, but what I want to do is rename the original file. I want foo.jar
(repackaged) and original-foo.jar
(original) because I want it to be clear which one is the original, but I need the file to be .jar to work with a pipeline tool. How can I do this?
The .original
suffix is hard-coded in org.springframework.boot.loader.tools.Repackager.getBackupFile()
method so you won't be able to replace it with a original-
prefix unless you fork your own version of Spring Boot Maven Plugin:
/**
* Return the {@link File} to use to backup the original source.
* @return the file to use to backup the original source
*/
public final File getBackupFile() {
return new File(this.source.getParentFile(), this.source.getName() + ".original");
}
Hi you can use other maven plugin to achieve that, I am using maven-antrun-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<copy file="${project.build.directory}/${project.build.finalName}.jar.original"
tofile="${project.build.directory}/${project.build.finalName}.bazzz" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Then it will copy the original file into other name
-rw-r--r-- 1 ming staff 140317 May 15 16:40 test-0.0.1-SNAPSHOT.bazzz
-rw-r--r-- 1 ming staff 140317 May 15 16:40 test-0.0.1-SNAPSHOT.jar.original
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.