Is there a canonical way to declare a license as part of Gradle build files, in a similar way how I can add a <licenses> tag to maven POMs? In particular, I’m looking for a solution that is independent of any Gradle plugins (like POM export), and that can be queried programmatically e.g. via the tooling API.
Of course, I could simply add a LICENSE net to my root build.gradle file. I was just wondering whether there is also some dedicated meta-data field for this, to e.g. put the concise SPDX identifier in, instead of having to parse the LICENSE file.
What do you want to do with this metadata? The simplest thing is to just add a property in your project’s gradle.properties or just put the license in a well-known file.
It would be much more convenient if there was a Gradle built-in property / API that is supposed to hold the SPDX identifier for the declared license that could be queried programmatically.
I always add licenses to my projects which I publish on Maven Central as that’s mandatory… See how I do it here: https://github.com/renatoathaydes/rawhttp/blob/master/rawhttp-core/build.gradle#L72 for example. I believe this config is added by the Maven plugin, and the generated pom.xml will contain the expected licenses tag Maven repos expect.
The pom.xml looks correct with the maven plugin, but with maven-publish, last I tried, it looked broken and missed stuff. Is there any reason maven-publish should be used instead? I haven’t had problems with maven so far.