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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ POM_DESCRIPTION=Gradle plugin to create fat/uber JARs, apply file transforms, an
POM_INCEPTION_YEAR=2024
POM_URL=https://github.com/GradleUp/shadow

POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_NAME=Apache-2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

Expand All @@ -27,4 +27,4 @@ POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/GradleUp/shadow.git

POM_DEVELOPER_ID=gradleup
POM_DEVELOPER_NAME=GradleUp developers
POM_DEVELOPER_URL=https://github.com/GradleUp
POM_DEVELOPER_URL=https://github.com/GradleUp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,41 @@ class ShadowPluginSpec extends PluginSpecification {
assert result.output.contains('TestApp: Hello World! (foo)')
}

@Issue("https://github.com/GradleUp/shadow/pull/459")
def 'exclude gradleApi() by default'() {
given:
buildFile.text = getDefaultBuildScript('java-gradle-plugin')
buildFile << """
dependencies {
compileOnly gradleApi()
}
""".stripIndent()

file('src/main/java/my/plugin/MyPlugin.java') << """
package my.plugin;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
public class MyPlugin implements Plugin<Project> {
public void apply(Project project) {
System.out.println("MyPlugin: Hello World!");
}
}
""".stripIndent()
file('src/main/resources/META-INF/gradle-plugins/my.plugin.properties') << """
implementation-class=my.plugin.MyPlugin
""".stripIndent()

when:
run('shadowJar')

then:
assert output.exists()

and:
JarFile jar = new JarFile(output)
assert jar.entries().collect().findAll { it.name.endsWith('.class') }.size() == 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see, Gradle APIs are included in the current jar:

https://scans.gradle.com/s/w4ng474mk6moe/tests/task/:test/details/com.github.jengelman.gradle.plugins.shadow.ShadowPluginSpec/exclude%20gradleApi()%20by%20default?top-execution=1

my/plugin/MyPlugin.class, 
org/gradle/process/internal/worker/GradleWorkerMain.class, 
org/gradle/process/internal/worker/WorkerJvmMemoryInfoSerializer$1.class, 
org/gradle/process/internal/worker/WorkerJvmMemoryInfoSerializer$JvmMemoryStatusSerializer.class, 
org/gradle/process/internal/worker/WorkerJvmMemoryInfoSerializer.class, 
org/gradle/process/internal/worker/WorkerLoggingSerializer.class,
…	

}

private String escapedPath(File file) {
file.path.replaceAll('\\\\', '\\\\\\\\')
}
Expand Down