2016-04-29 65 views
0

我是Java 8 java.time JSP tags庫的mantainer。我自己發佈圖書館的經驗很少。對於這個圖書館的出版物,我做了一些研究,並以Gradle構建腳本that you can check in GitHub結束。這個過程有點笨重,但最終還是有效的。如何遷移gradle發佈腳本以將OSS庫發佈到Bintray的JCenter而不是Sonatype的Maven Central

似乎有一個普遍的認識,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:[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 
      } 
     } 
    } 
} 

你可以找到my public Bintray maven repository最新公佈的結果。您可以將其與the same version currently available on Maven Central的文件進行比較。

恭喜你是否閱讀過這篇文章,因爲我還沒有提出任何問題。對於那個很抱歉。

我的問題:

的是的gradle構建腳本正確和適當/規範的方法?鑑於該庫非常簡單,我發現構建腳本龐大笨重。它應該更容易,它甚至有一個gradle插件。但新的腳本是較長的比maven中央一個。

怎麼樣*.md5*.sha1文件?將由JCenter,Maven Central生成,同步處理...還是應該這樣做?

考慮到存儲庫上沒有未發佈的功能,有沒有一種方法可以測試所有這些,而不必發佈實際版本的庫? (有一個很好的理由,呃?任何人都可以?)。

回答

1

首先,很好的工作計算出來。它看起來不錯,而且效果很好。

它比另一個更大,不是因爲您使用Bintray而不是Central,但是因爲您使用maven-publish插件而不是maven,而且功能更強大,所以配置稍微冗長一些。無論你喜歡什麼,你都可以使用Bintray(和bintray插件)與mavenmaven-publish

重新測試它 - 您總是可以針對您的私有存儲庫運行測試版本(單擊「設置我」按鈕以獲取有關如何設置Maven和/或Gradle以解決此問題的說明)。

另一個驗證將同步到Maven Central。如果你的包元數據有問題,它會失敗。

對於md5和sha1,我們沒有看到將可計算元數據作爲文件存儲在現代分發平臺上的理由,但是當我們同步時,我們會將它們發送到Maven Central。

相關問題