From bde98defa54d63aef073deb516210596b3a793a9 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 25 Oct 2013 16:28:50 +0100 Subject: [PATCH] Update Gradle plugin to only repackage main jar Previously, Repackage would attempt to repackage every jar in the project. This would cause it to incorrectly attempt to repackage source and javadoc jars. This commit updates Repackage so that it ignores any jar with a classifier. Hopefully this is a reasonable approximation for ignoring 'special' jars that should not be repackaged such as sources and javadoc. --- .../boot/gradle/task/Repackage.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/Repackage.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/Repackage.java index 521a936e184..d827d9c4b53 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/Repackage.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/Repackage.java @@ -46,18 +46,20 @@ public class Repackage extends DefaultTask { project.getTasks().withType(Jar.class, new Action() { @Override public void execute(Jar archive) { - File file = archive.getArchivePath(); - if (file.exists()) { - Repackager repackager = new Repackager(file); - repackager.setMainClass(extension.getMainClass()); - if (extension.convertLayout() != null) { - repackager.setLayout(extension.convertLayout()); - } - repackager.setBackupSource(extension.isBackupSource()); - try { - repackager.repackage(libraries); - } catch (IOException ex) { - throw new IllegalStateException(ex.getMessage(), ex); + if ("".equals(archive.getClassifier())) { + File file = archive.getArchivePath(); + if (file.exists()) { + Repackager repackager = new Repackager(file); + repackager.setMainClass(extension.getMainClass()); + if (extension.convertLayout() != null) { + repackager.setLayout(extension.convertLayout()); + } + repackager.setBackupSource(extension.isBackupSource()); + try { + repackager.repackage(libraries); + } catch (IOException ex) { + throw new IllegalStateException(ex.getMessage(), ex); + } } } }