我是Java 8 java.time JSP tags图书馆的傻瓜。我自己出版图书馆的经验很少。对于这个库的发布,我做了一些研究,并以gradle构建脚本that you can check in GitHub结束。这个过程有点笨拙,但最终有效。
似乎普遍认为jcenter()
存储库正在引起很多关注。可能是因为android。无论如何,我看到了an encouraging blog post,并决定尝试将该库迁移到Maven Central的JCenter发布版。应该很容易。
至少对我来说不是这样。可能是我的错,因为我对Maven的知识,文物和所有这些东西都很差。无论如何,我给了它几个小时的研究,并提出了一个新的gradle构建,以发布到我的Bintray maven存储库。如果我没错,那就是向JCenter发布的第一步。
这是我到目前为止所做的:
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:git@github.com:sargue/java-time-jsptags.git'
developerConnection 'scm:git:git@github.com:sargue/java-time-jsptags.git'
url 'git@github.com: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 'sargue@gmail.com'
}
}
}
}
}
}
}
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
}
}
}
}
您可以在my public Bintray maven repository上找到最新出版物的结果。您可以将其与the same version currently available on Maven Central的文件进行比较。
恭喜你,到目前为止你正在读这篇文章,因为我还没有提出任何问题。对不起。
我的问题:
gradle构建脚本是否正确且正确/规范?鉴于该库非常简单,我发现构建脚本庞大而笨重。它应该更容易,它甚至有一个gradle插件。但新剧本
*.md5
和*.sha1
文件怎么样?将由JCenter,Maven Central生成,同步过程......还是我应该这样做?
鉴于存储库中没有取消发布功能,有一些方法可以测试所有这些而不发布库的实际版本吗? (并且有充分的理由,呃?左撇子有人吗?)。
答案 0 :(得分:1)
首先,很好的解决问题。它看起来不错,效果很好。
它比另一个更大,不是因为你使用Bintray而不是Central,而是因为你使用maven-publish
插件而不是maven
,并且功能更强大,配置有点更冗长。您可以将Bintray(和bintray
插件)与maven
和maven-publish
一起使用,无论您喜欢什么。
重新测试 - 您可以随时针对您的私人存储库运行测试版本(单击“设置我”按钮以获取有关如何设置Maven和/或Gradle以从中解析的说明。)
另一个验证将与Maven Central同步。如果包元数据出现问题,它将失败。
Re md5和sha1,我们没有看到将可计算元数据作为文件存储在现代分发平台上的原因,但我们在同步时将它们发送到Maven Central。