Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
- Fix skipStringConstants per-relocator behavior in mapName. ([#1968](https://github.com/GradleUp/shadow/pull/1968))
- Fix excluding dependencies whose versions contain `+`. ([#1597](https://github.com/GradleUp/shadow/pull/1597))
- Fix relocation exclusion for file patterns like `kotlin/kotlin.kotlin_builtins`. ([#1313](https://github.com/GradleUp/shadow/pull/1313))
- Fix formatting and copyright handling in `ApacheNoticeResourceTransformer`. ([#1623](https://github.com/GradleUp/shadow/pull/1623), [#1627](https://github.com/GradleUp/shadow/pull/1627), [#1628](https://github.com/GradleUp/shadow/pull/1628))
- Fix ShadowJar not being re-executed after includes or excludes are changed. ([#1200](https://github.com/GradleUp/shadow/pull/1200))
- Respect `executableDir` in application extension when configuring start scripts and distribution. ([#1738](https://github.com/GradleUp/shadow/pull/1738))


**Deprecated**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class ShadowApplicationPlugin implements Plugin<Project> {
project.tasks.named(SHADOW_INSTALL_TASK_NAME, Sync).configure { task ->
task.doFirst {
if (task.destinationDir.directory) {
if (task.destinationDir.listFiles().size() != 0 && (!new File(task.destinationDir, 'lib').directory || !new File(task.destinationDir, 'bin').directory)) {
if (task.destinationDir.listFiles().size() != 0 && (!new File(task.destinationDir, 'lib').directory || !new File(task.destinationDir, javaApplication.executableDir).directory)) {
throw new GradleException("The specified installation directory '${task.destinationDir}' is neither empty nor does it contain an installation for '${javaApplication.applicationName}'.\n" +
"If you really want to install to this directory, delete it and run the install task again.\n" +
"Alternatively, choose a different installation directory."
Expand All @@ -104,7 +104,7 @@ class ShadowApplicationPlugin implements Plugin<Project> {
}
task.doLast {
task.eachFile {
if (it.path == "bin/${javaApplication.applicationName}") {
if (it.path == "${javaApplication.executableDir}/${javaApplication.applicationName}") {
it.mode = 0x755
}
}
Expand All @@ -122,7 +122,7 @@ class ShadowApplicationPlugin implements Plugin<Project> {
from(jar)
from(project.configurations.shadow)
}
into("bin") {
into({ javaApplication.executableDir }) {
from(startScripts)
filePermissions { it.unix(493) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

@CacheableTask
public abstract class ShadowJar extends Jar implements ShadowSpec {

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 51 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

private List<Transformer> transformers;
private List<Relocator> relocators;
Expand All @@ -71,7 +72,7 @@
}
});

public ShadowJar() {

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 75 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
super();
setDuplicatesStrategy(DuplicatesStrategy.INCLUDE); //shadow filters out files later. This was the default behavior in Gradle < 6.x
dependencyFilter = new DefaultDependencyFilter(getProject());
Expand All @@ -81,6 +82,9 @@
relocators = new ArrayList<>();
configurations = new ArrayList<>();

this.getInputs().property("minimize", (Callable<Boolean>) () -> minimizeJar);
this.getInputs().property("includes", (Callable<Set<String>>) () -> getIncludes());
this.getInputs().property("excludes", (Callable<Set<String>>) () -> getExcludes());
this.getOutputs().doNotCacheIf("Has one or more transforms or relocators that are not cacheable", task -> {
for (Transformer transformer : transformers) {
if (!isCacheableTransform(transformer.getClass())) {
Expand Down Expand Up @@ -171,7 +175,7 @@
}

@Internal
protected ZipCompressor getInternalCompressor() {

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 178 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return GradleVersionUtil.getInternalCompressor(getEntryCompression(), this);
}

Expand All @@ -193,7 +197,7 @@
}

@Classpath
public FileCollection getIncludedDependencies() {

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 200 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return includedDependencies;
}

Expand Down Expand Up @@ -431,7 +435,7 @@
}

@Nested
public List<Relocator> getRelocators() {

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 438 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return this.relocators;
}

Expand All @@ -441,7 +445,7 @@

@Classpath
@Optional
public List<FileCollection> getConfigurations() {

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 448 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return this.configurations;
}

Expand All @@ -450,7 +454,7 @@
}

@Internal
public DependencyFilter getDependencyFilter() {

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 457 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return this.dependencyFilter;
}

Expand All @@ -468,7 +472,7 @@
}

@Input
public String getRelocationPrefix() {

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no comment

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no comment

Check warning on line 475 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no comment
return relocationPrefix;
}

Expand All @@ -482,7 +486,7 @@
*/
@Deprecated
@Input
public boolean getMinimizeJar() {

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

Check warning on line 489 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

return minimizeJar;
}

Expand All @@ -491,7 +495,7 @@
* setting {@code false} is equivalent to not calling {@code minimize()}.
*/
@Deprecated
public void setMinimizeJar(boolean minimizeJar) {

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no @PARAM for minimizeJar

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no @PARAM for minimizeJar

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no @PARAM for minimizeJar

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=current

no @PARAM for minimizeJar

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=25, Gradle=current

no @PARAM for minimizeJar

Check warning on line 498 in src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java

View workflow job for this annotation

GitHub Actions / OS=ubuntu-24.04-arm, Java=17, Gradle=8.3

no @PARAM for minimizeJar
this.minimizeJar = minimizeJar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class ApacheNoticeResourceTransformer implements Transformer {
@Input
String copyright

private String fallbackCopyright

/**
* The file encoding of the <code>NOTICE</code> file.
*/
Expand Down Expand Up @@ -148,7 +150,7 @@ class ApacheNoticeResourceTransformer implements Transformer {
} else {
String ent = sb.toString()
if (ent.startsWith(projectName) && ent.indexOf("Copyright ") != -1) {
copyright = ent
fallbackCopyright = ent
}
if (currentOrg == null) {
entries.add(ent)
Expand Down Expand Up @@ -183,42 +185,40 @@ class ApacheNoticeResourceTransformer implements Transformer {
zipEntry.time = TransformerContext.getEntryTimestamp(preserveFileTimestamps, zipEntry.time)
os.putNextEntry(zipEntry)

Writer pow
if (StringUtils.isNotEmpty(encoding)) {
pow = new OutputStreamWriter(os, encoding)
} else {
pow = new OutputStreamWriter(os)
}
PrintWriter writer = new PrintWriter(pow)
String actualCopyright = copyright ?: fallbackCopyright

StringBuilder sb = new StringBuilder()
int count = 0
for (String line : entries) {
++count
if (line == copyright && count != 2) {
if (line == actualCopyright && count != 2) {
continue
}

if (count == 2 && copyright != null) {
writer.print(copyright)
writer.print('\n')
if (count == 2 && actualCopyright != null) {
sb.append(actualCopyright).append('\n')
} else {
writer.print(line)
writer.print('\n')
sb.append(line).append('\n')
}
if (count == 3) {
//do org stuff
for (Map.Entry<String, Set<String>> entry : organizationEntries.entrySet()) {
writer.print(entry.getKey())
writer.print('\n')
sb.append(entry.getKey()).append('\n')
for (String l : entry.getValue()) {
writer.print(l)
sb.append(l)
}
writer.print('\n')
sb.append('\n')
}
}
}

writer.flush()
byte[] bytes
if (StringUtils.isNotEmpty(encoding)) {
bytes = sb.toString().stripTrailing().getBytes(encoding)
} else {
bytes = sb.toString().stripTrailing().getBytes()
}
Comment thread
Goooler marked this conversation as resolved.
Comment thread
Goooler marked this conversation as resolved.
os.write(bytes)

entries.clear()
}
Expand Down