Commit bde98def authored by Andy Wilkinson's avatar Andy Wilkinson

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.
parent a4c0733d
......@@ -46,18 +46,20 @@ public class Repackage extends DefaultTask {
project.getTasks().withType(Jar.class, new Action<Jar>() {
@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);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment