Your email address will not be published. To raise new issues or bugs against Gradle, please use, https://github.com/gradle/gradle/blob/master/subprojects/osgi/src/main/groovy/org/gradle/api/internal/plugins/osgi/DefaultOsgiManifest.java#L90, https://github.com/jetztgradnet/gradle-web-bundle, jetztgradnet-gradle-web-bundle-4fce0ff.zip. This triggers downstream tasks … On closer inspection (after unpacking, debugging, even decompiling!) For my simple test case I can live with the workaround, as I don't need Bnd to calculate imports or exports, but for real web bundles, this is a problems that needs to be resolved. Manifest-Version is set to 1.0; Specification-Title and Implementation-Title are set to the Gradle rootProject.name; Specification-Version and Implementation-Version are set based on Git commit status (see git describe) IFF no version can be determined via a git describe, and a Gradle rootProject.version can be, this value will be used instead Gradle Kotlin DSL: set main class attribute for jar - build.gradle.kts Post was not sent - check your email addresses! Both Gradle 0.9.2 and 1.0-milestone-1 fail to build the war's MANIFEST.MF when called like this: Alrighty the solution was to update gradle on build.gradle of my project, not module // Top-level build file where you can add configuration options common to all sub-projects/modules. Next is Maven. When packaging the project we get a manifest that may look like this. (the Git commit hash for example). I'm building a web app as OSGi bundle (web bundle), so I use both the OSGi and war plugins. There’s a catch though, Gradle does not know a thing about SCM properties, you’ll have to add a plugin that exposes this information, such as … Required fields are marked *. We could write down said metadata to a properties file and add it to the package archive, or we could reuse an existing facility: the archive’s manifest. This site uses Akismet to reduce spam. What’s the SCM reference? An advantage of using Gradle is that attribute values may be computed on the spot, as you have access to a full programming language (either Groovy or Kotlin), useful when you may need to trim, modify, and/or format certain values. Both Gradle 0.9.2 and 1.0-milestone-1 fail to build the war's MANIFEST.MF when called like this: So basically it seems that a call to DefaultOsgiManifest#setClassesDir() is omitted, maybe because a web app's classes are located at a different location as a normal jar. It's also attached to this issue. Gradle let’s you customize archive manifest from the get go, you just have to add entries you desired to the manifest’s attributes. The only drawback I see with using Maven in this way is that it’s not possible to format values or create new ones on the spot. Click to share on Twitter (Opens in new window), Click to share on LinkedIn (Opens in new window), Click to share on Reddit (Opens in new window), Click to email this to a friend (Opens in new window). $ jar tvf build/libs/gs-gradle-0.1.0.jar 0 Fri May 30 16:02:32 CDT 2014 META-INF/ 25 Fri May 30 16:02:32 CDT 2014 META-INF/MANIFEST.MF 0 Fri May 30 16:02:32 CDT 2014 hello/ 369 Fri May 30 16:02:32 CDT 2014 hello/Greeter.class 988 Fri May 30 16:02:32 CDT 2014 hello/HelloWorld.class How many times have you looked at a bug report stating that the problem is caused by version X of a particular artifact but you are certain the bug was fixed in said release? In any case, both build tools provide you the means to add essential artifact metadata to the archive’s manifest. The following snippet shows the minimum configuration to setup the metadata that answers my previous questions: Packaging the artifact and inspecting the generated manifest (found already unpacked at build/tmp/jar/MANIFEST.MF) we may see something like this. I posted an example project at https://github.com/jetztgradnet/gradle-web-bundle. How many times have you found yourself in a situation where you can’t tell if the artifacts used by the application are the correct ones or not? It looks quite similar to the one generated by Gradle with just the timestamp and the creator having different values. Which JDK version was used to compile the classes? Sorry, your blog cannot share posts by email. Which operating system was used to built it. Perhaps you may be thinking in using the antrun plugin with a short embedded script to be able to get around this problem, well, if you need to bring a second build tool in order to fix the shortcomings of the first, isn’t the problem somewhere else? There’s a catch though, Gradle does not know a thing about SCM properties, you’ll have to add a plugin that exposes this information, such as the net.nemerosa.versioning plugin. Take a second to support aalmiray on Patreon! Try Jira - bug tracking software for your team. The OSGI plugin updates the MANIFEST.MF with a new Bnd-LastModified even if there is no other change, resulting in the jar task always executing. In this case we must also configure an external plugin in order to grab hold of SCM properties, we’ll use the maven-git-commit-id-plugin from Konrad (@ktosopl); we’ll also need to update the configuration of the core maven-jar-plugin as explained here. Your email address will not be published. Values must exist as standard project properties, System properties, or custom project properties, such as the ones exposed by the git-commit-id plugin or any other plugin. Gradle let’s you customize archive manifest from the get go, you just have to add entries you desired to the manifest’s attributes. Learn how your comment data is processed. Notify me of follow-up comments by email. jar { LinkedHashMap attributes = new LinkedHashMap() attributes.put('Build-Date', new Date().format("yyyy-MM-dd")) attributes.put('Build-Time', new Date().format("HH:mm:ssZ")) attributes.put('Code-Revision', '1.0') attributes.put( 'Class-Path', configurations.compile.collect { it.getName() }.join(' ')) manifest.mainAttributes(attributes) } you find that the artifact in production is not the right one even though the version appears to be the correct one. Just like in Gradle, the build file has access to all System properties we need (more information about project properties can be found at this link). Powered by a free Atlassian Jira open source license for Gradle Inc. Liked it? Please check the checkbox to ensure that you comply with the EU Laws. As you can see we get the expected result. Personally I’d like to find out the following information when inspecting the metadata for a particular artifact: Let’s start with Gradle as it’s the one that requires less setup.