I am the mantainer of the Java 8 java.time JSP tags library. I have little experience publishing libraries on my own. For the publication of this library I did some research and ended with a gradle build script that you can check in GitHub. The process is a bit clunky but it works in the end.
There seem to be a general understanding that the jcenter()
repository is gaining a lot of attention. Probably because of android. Anyway I saw an encouraging blog post and decided to give it a try and migrate that library to JCenter publishing insted of Maven Central. Should be easy.
It is not, for me at least. Probably my fault as my knowledge of Maven, artifacts and all that stuff is poor. Anyway I gave it some hours of research and come up with a new gradle build to publish to my Bintray maven repository. Which, if I'm not wrong, is the first step towards publishing to JCenter.
This is what I have so far:
plugins {
id "com.jfrog.bintray" version "1.6"
}
apply plugin: 'java'
apply plugin: 'maven-publish'
group = 'net.sargue'
version = '1.1.2'
sourceCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
repositories {
jcenter()
}
configurations {
testCompile.extendsFrom compileOnly
}
dependencies {
compileOnly 'javax.servlet:javax.servlet-api:3.0.1'
compileOnly 'javax.servlet.jsp:javax.servlet.jsp-api:2.2.1'
compileOnly 'javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:1.2.1'
testCompile 'junit:junit:4.12'
testCompile 'org.springframework:spring-test:4.1.7.RELEASE'
}
jar {
manifest {
attributes 'Implementation-Title': 'Java 8 java.time JSP tags',
'Implementation-Version': version
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifactId 'java-time-jsptags'
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'Java 8 java.time JSP tags'
description 'JSP tag support for Java 8 java.time (JSR-310)'
url 'https://github.com/sargue/java-time-jsptags'
scm {
connection 'scm:git:[email protected]:sargue/java-time-jsptags.git'
developerConnection 'scm:git:[email protected]:sargue/java-time-jsptags.git'
url '[email protected]:sargue/java-time-jsptags.git'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'sargue'
name 'Sergi Baila'
email '[email protected]'
}
}
}
}
}
}
}
bintray {
user = BINTRAY_USER
key = BINTRAY_KEY
publications = ['MyPublication']
pkg {
repo = 'maven'
name = 'java-time-jsptags'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/sargue/java-time-jsptags.git'
version {
name = project.version
desc = 'Java 8 java.time JSP tags'
gpg {
sign = true
passphrase = BINTRAY_GPG
}
}
}
}
You can find the result of the latest publication on my public Bintray maven repository. You can compare it to the files for the same version currently available on Maven Central.
Congratulations if you are reading this so far, because I haven't formulated ANY question yet. Sorry about that.
My questions:
Is the gradle build script correct and the proper/canonical way? Given that the library is quite simple I found the build script huge and clunky. It is supposed to be easier and it even has a gradle plugin. But the new script is longer than the maven central one.
What about the *.md5
and *.sha1
files? Will be generated by JCenter, Maven Central, the sync proces... or should I do it?
There is some way of testing all these without publishing an actual version of the library given that there is no unpublish capabilities on the repositories? (and for a good reason, eh? leftpad anyone?).