Skip to content

Commit

Permalink
Fix missing jars in classpath of generared in jar MANIFEST (#477)
Browse files Browse the repository at this point in the history
fixes #476 

Classpath in jar MANIFEST  now contains the project jars and is consistent with the classpath generated in launcher script.
  • Loading branch information
joncelay authored and bulldozer-bot[bot] committed Mar 28, 2019
1 parent 790de03 commit e5068c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit e5068c6

Please sign in to comment.