0
我需要爲grails3插件創建兩個帶有不同版本的自定義庫的jar文件,並將這兩個工件發佈到遠程maven倉庫(artifactory)。 這裏是構建文件的樣本:Gradle - 使用不同版本的依賴項創建多個罐子
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
jcenter()
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.2"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
id "com.jfrog.bintray" version "1.2"
}
version "0.1.0-SNAPSHOT"
group "org.grails.plugins"
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "spring-boot"
apply plugin: "org.grails.grails-plugin"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
maven { url "${artifactory_contextUrl}"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
provided 'org.springframework.boot:spring-boot-starter-logging'
provided "org.springframework.boot:spring-boot-starter-actuator"
provided "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"
provided "org.grails:grails-web-boot"
provided "org.grails:grails-dependencies"
provided 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.grails:grails-plugin-testing"
console "org.grails:grails-console"
//TODO build two jars with different versions of this dependency
compile "com.mycompany.custom-lib:x.x.x-SNAPSHOT"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
artifactory {
contextUrl = artifactoryContextUrl
publish {
defaults {
publications('mavenJava')
maven = true
}
repository {
repoKey = project.version.endsWith('-SNAPSHOT') ? snapshotRepoKey : releaseRepoKey
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
由於gradle artifactoryPublish
命令我想有在建/庫兩個jar文件的結果:
爲myplugin-0.1.0-X-SNAPSHOT.jar - 以lib com.mycompany.custom-lib目錄下:1.0.2-SNAPSHOT
和
爲myplugin-0.1.0-Y-SNAPSHOT.jar - 以lib com.mycompany.custom-lib目錄下:2.0.2- SNAPSHOT
另外我希望他們都被髮布到artifactory。
我該如何做到這一點?
你準備一個肥缸嗎? – Opal
@Opal no,根據grails package-plugin的結果,它是一個沒有來自所有庫的類的jar,它只包含當前項目的類。但後來,在主項目(grails webapp)中,我希望能夠在構建過程中在兩個插件版本之間切換。 – airfox