I think I found the reason. Some subprojects do not contain production code and no META-INF/MANIFEST.MF
file. That causes the genManifest
task to be skipped since it has no sources: https://scans.gradle.com/s/xx6qgy5dahkpk/timeline?task=5l52ywrbdjnpa&taskFilter=:org.eclipse.xtend.lib.tests
Now the jar task will generate the manifest in build/tmp/jar/MANIFEST.MF
, but that happens after the genManifest
task executed. I think you should change the destination dir of the genManifest
task to a different directory than to the default tmp dir of the jar task.
You see the problem when re-running assemble
: https://scans.gradle.com/s/63aumrpecf7lq/timeline?task=7cazsglzhmre4
All the genManifest
tasks run again, since the copied manifest has been replaced by the manifest generated by Gradle.
The jar
task in not skipped, since it always has the manifest (generated by Gradle) to package up.
The three deprecations I saw in the build have been caused by this issue: https://scans.gradle.com/s/xx6qgy5dahkpk/deprecations?openUsages=WzBd
The inputs.file()
declaration is also superfluous, since the manifest file (content) is already added as an input to the jar
task automatically when using manifest.from
. If it isn’t, then this would be a bug.
I changed the code in manifest-gen.gradle
to make it work:
File manifestFile = project.file("$buildDir/tmp/genManifest/MANIFEST.MF")
task genManifest(type: Copy) {
inputs.property('qualifiedVersion', qualifiedVersion)
from "META-INF/MANIFEST.MF"
into "$buildDir/tmp/genManifest/"
doLast {
def f = manifestFile
def modifiedText = f.text.replace(baseVersion + '.qualifier', qualifiedVersion)
def writer = new PrintWriter(f)
writer.print(modifiedText)
writer.close()
}
}
jar {
dependsOn genManifest
manifest {
if (manifestFile.isFile()) {
from manifestFile
}
}
}
//------------------------------------------------------
// Generate a manifest for the source bundle
def sourcesManifestFile = "$buildDir/tmp/genSourcesManifest/MANIFEST.MF"
task genSourcesManifest {
outputs.file(sourcesManifestFile)
inputs.property('qualifiedVersion', qualifiedVersion)
inputs.property('projectName', project.name)
inputs.property('projectTitle', project.findProperty('title')).optional(true)
doLast {
def f = new File(sourcesManifestFile)
f.parentFile.mkdirs()
def writer = new PrintWriter(f)
writer.println("Manifest-Version: 1.0")
writer.println("Bundle-ManifestVersion: 2")
writer.println("Bundle-SymbolicName: ${project.name}.source")
writer.println("Bundle-Version: ${qualifiedVersion}")
if (project.hasProperty('title'))
writer.println("Bundle-Name: ${project.title} Sources")
else
writer.println("Bundle-Name: Sources")
writer.println("Bundle-Vendor: Eclipse Xtext")
writer.println("Eclipse-SourceBundle: ${project.name};version=\"${qualifiedVersion}\"")
writer.close()
}
}
sourcesJar {
dependsOn genSourcesManifest
manifest {
from sourcesManifestFile
}
}
Note that the tasks are still not up-to-date on a re-run in different minutes, since the manifest contains the build time: https://scans.gradle.com/s/lwgiusildbxss/timeline?task=7cazsglzhmre4
Hope that helps,
Cheers,
Stefan