0

When i run the generateMetadataFileFormMavenPublication task, i get a json at build/publications/maven/module.json which is missing these fields: name, description, minimumCoreVersion, title, version, author. IntelliJ prompts me to add them back in. The author (developer) is present in the generated pom file. What am i missing to also add this (and the other required fields) to the module.json file?

It seems like an oversight from gradle, because from their examples (and from my own experience) its sufficient to just add this to publish a jar:

publishing { publications { maven(MavenPublication) {
  groupId project.group; artifactId project.name; version project.version
  from components.java;
} } }

Here is the groovy code i am working with:

publishing {
    publications {
        maven(MavenPublication) {
            pom {
                name = project.name
                description = (project.name + ' description')
                developers {
                    developer {
                        id = 'daveankin'
                        name = 'Dave Ankin'
                        email = 'daveankin@gmail.com'
                        organizationUrl = 'https://example.com'
                    }
                }
            }
            groupId project.group
            artifactId project.name
            version project.version

            from components.java
            withBuildIdentifier()
        }
    }
}
Dave Ankin
  • 1,060
  • 2
  • 9
  • 20

1 Answers1

0

Probably you need an Manifest file to specify author. I am using task like this:

jar {
  manifest {
    attributes(
            "Class-Path": sourceSets.main.compileClasspath.asPath,
            "Main-Class": "MainClass",
            "Implementation-Title": project.name,
            "Implementation-Version": archiveVersion,
            "Implementation-Vendor": "Specify Author here",
            "Build-Jdk": org.gradle.internal.jvm.Jvm.current(),
            "Gradle-Version":GradleVersion.current().toString()
    )
  }
  duplicatesStrategy = DuplicatesStrategy.EXCLUDE
  from {
    configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
  }

}

I hope that it will help you. Also you can look at the Oracle specification: https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#JARManifest

If you will use similar task like above then actor's name will be stored in MANIFEST file. Manifest file will be added to result JAR archive

Alekse
  • 1
  • 2
  • my question was pertaining not to the `META-INF/MANIFEST.MF` file but the gradle file. I would be surprised if affects the output of the gradle `module.json` file, but if I try it I will report back here. – Dave Ankin Nov 14 '22 at 12:45
  • @DaveAnkin I think it will not affect module.json file... Looks like I didn't follow your problem well – Alekse Nov 14 '22 at 20:30