0

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?

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Barry McNamara
  • 689
  • 9
  • 18

2 Answers2

1

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");
}
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • I was afraid that might be the case. I ended up using finalName to have the repackaged file called standalone-foo.jar which left the original one as foo.jar -- this makes the distinction clear while preserving the files types which is what I wanted. – Barry McNamara Aug 16 '18 at 15:47
0

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
sendon1982
  • 9,982
  • 61
  • 44