Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing jars in classpath of generared in jar MANIFEST #477

Merged
merged 4 commits into from
Mar 28, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.gradle.api.InvalidUserCodeException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.file.FileCollection;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.JavaExec;
Expand Down Expand Up @@ -85,8 +86,13 @@ public void apply(Project project) {
task.setAppendix("manifest-classpath");

task.doFirst(t -> {
String classPath = project.getConfigurations().getByName("runtimeClasspath")
.getFiles()

FileCollection runtimeClasspath = project.getConfigurations().getByName("runtimeClasspath");

FileCollection jarOutputs = project.getTasks().withType(Jar.class)
.getByName(JavaPlugin.JAR_TASK_NAME).getOutputs().getFiles();

String classPath = runtimeClasspath.plus(jarOutputs).getFiles()
.stream()
.map(File::getName)
.collect(Collectors.joining(" "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,12 @@ class ServiceDistributionPluginTests extends GradleIntegrationSpec {
def classpathJar = file('dist/service-name-0.0.1/service/lib/').listFiles()
.find({ it.name.endsWith("-manifest-classpath-0.0.1.jar") })
classpathJar.exists()
readFromZip(classpathJar, "META-INF/MANIFEST.MF")
.contains('Class-Path: guava-19.0.jar root-project-manifest-') // etc

def zipManifest = readFromZip(classpathJar, "META-INF/MANIFEST.MF").replace('\r\n ','')
zipManifest.contains('Class-Path: ')
zipManifest.contains('guava-19.0.jar')
zipManifest.contains('root-project-manifest-classpath-0.0.1.jar')
zipManifest.contains('root-project-0.0.1.jar')
}

def 'does not produce manifest-classpath jar when disabled in extension'() {
Expand Down