gpt4 book ai didi

grails - Gradle - 创建具有不同版本依赖项的多个 jar

转载 作者:行者123 更新时间:2023-12-02 15:56:02 25 4
gpt4 key购买 nike

我需要为 grails3 插件创建两个具有不同版本的自定义库的 jar 文件,并将两个 Artifactory 发布到远程 maven 存储库( Artifactory )。
这是构建文件的示例:

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命令我想在 build/libs 中有两个 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 上。

我怎样才能做到这一点?

最佳答案

由于您正在上传 mavenJava发布,您需要做的就是将生成另一个 jar 文件的任务添加到 from您的 publication 列表.

关于grails - Gradle - 创建具有不同版本依赖项的多个 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33700609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com