关键词:
【中文标题】Gradle with maven-publish:如何自动版本化并将目录中的非 gradle jar 发布到 Artifactory【英文标题】:Gradle with maven-publish: how to autoversion and publish non-gradle jars in a directory to Artifactory 【发布时间】:2014-07-08 17:31:28 【问题描述】:作为从 ant 迁移到 gradle 的短期选择,我们希望仅在 ant 构建的开始和结束时使用 gradle,而不是在 gradle 中运行 ant。
基本上我们想使用 gradle 将依赖项获取到一个目录,然后运行 ant build 将所有指定的 jar 放在一个目录中,然后使用 gradle 将该目录中的工件发布到 Artifactory。
这意味着 gradle 不会真正构建工件——它会在目录中找到它们,但我们仍然希望它们被版本化(因为它们将进入工件)
所以我们希望使用 Gradle 来动态版本化和发布目录中的所有文件。
查看 gradle 文档,Gradle 和 artifactory-publish 插件似乎专注于“要发布哪些模块”的更多静态定义。我很难让 Gradle 正确发布目录中的文件的动态计数。
我尝试了以下(精简),但到目前为止它在我的测试中不起作用(因为 MavenPublication 名称似乎需要静态文本)——并且 artifactory-publish 位当前没有循环正确的集合MavenPublications:
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'artifactory-publish'
version = new Version( 1, 0, System.env.BUILD_NUMBER ) // set by Jenkins
ext.filesToPublish=['foo.jar', 'bar.ear']
publishing
publications
def i=0;
for ( s in filesToPublish )
++i
def vname="artifact" + i;
$vname(MavenPublication)
artifact s
artifactId vname
artifactory
contextUrl = 'http://.../artifactory'
publish
repository
repoKey='...'
username='...'
password='...'
defaults
publications('artifact0')
publications('artifact1')
publications('artifact2')
resolve
repository
repoKey='...'
如果有人想出一种将所有文件动态发布到 Artifactory 目录的方法,我非常感兴趣。
有没有更好的方法,比如像 Java 插件那样定义组件?
我还尝试动态创建 MavenPublication 对象,但无法使其正常工作。那会是更好的方法吗?
谢谢!
【问题讨论】:
您可能只想查看以太蚂蚁任务来解决依赖关系并将工件从构建部署到存储库。这将使事情变得更简单恕我直言。 github.com/eclipse/aether-ant 谢谢你,曼弗雷德。我去看看。 【参考方案1】:编辑:通过额外的研究和对 Groovy 的更好理解,我能够做到这一点,如下所示——注意在变量扩展周围使用双引号——与以前相比,“$fbase”:
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'artifactory-publish'
version = new Version( 1, 0, System.env.BUILD_NUMBER ) // set by Jenkins
ext.filesToPublish = []
ext.dir= new File("pub")
ext.dir.eachFile( groovy.io.FileType.FILES ) file ->
ext.filesToPublish << file
publishing
publications
for ( f in filesToPublish )
def fbase=f.getName().split("\\.")[0]
"$fbase"(MavenPublication)
artifact f
artifactId fbase
artifactory
contextUrl = 'http://.../artifactory'
publish
repository
repoKey='...'
username='...'
password='...'
defaults
for ( f in filesToPublish )
def fbase=f.getName().split("\\.")[0]
publications( fbase )
resolve
repository
repoKey='...'
【讨论】:
终于!我希望 gradle 文档有一个示例,展示如何像这个示例一样动态创建出版物名称。干得好!如何使用 maven-publish 和 artifactory-gradle-plugin 生成 maven-metata.xml?
】如何使用maven-publish和artifactory-gradle-plugin生成maven-metata.xml?【英文标题】:HowdoIgeneratemaven-metata.xmlwithmaven-publishandtheartifactory-gradle-plugin?【发布时间】:2015-05-0312:25:24【问题描述】:我在groovy中编写了一个Gradle插件并使用Gradle... 查看详情
gradle部署
...需要签署已发布的POM文件使用Maven插件发布Gradle默认提供maven-publish插件。它用于发布gradle脚本。看看下面的代码。applyplugin:‘java‘applyplugin:‘maven-publish‘publishing{publications{maven 查看详情
Gradle maven-publish 不构建独立的 spring-boot 应用程序
】Gradlemaven-publish不构建独立的spring-boot应用程序【英文标题】:Gradlemaven-publishdoesnotbuildstandalonespring-bootapplication【发布时间】:2014-11-3011:26:57【问题描述】:当我使用gradlebuild构建一个spring-boot应用程序(到一个独立的jar)时,... 查看详情
pluginwithid‘maven‘notfoundandroidstudio|gradle|插件开发(代码片段)
...及以后的版本中maven插件已经被移除了,改为使用"maven-publish"解决办法:applyplugin:'maven'改为applyplugin:'maven-publish'uploadArchives需要改为新的写法publishing:旧:uploadArchivesrepositories.mavenDeployerpom.groupId&... 查看详情
Gradle with Eclipse - 多个源集时不完整的.classpath
】GradlewithEclipse-多个源集时不完整的.classpath【英文标题】:GradlewithEclipse-incomplete.classpathwhenmultiplesourcesets【发布时间】:2013-06-0712:43:03【问题描述】:我有一个gradle构建脚本,其中包含一些源集,它们都定义了各种依赖项(一... 查看详情
gradle如何打包springboot可执行jar
如何在Gradle中配置一个项目可以打包为SpringBoot可执行Jar?你首先需要添加到org.springframework.boot到插件中:例如下面的代码:plugins{id‘maven-publish‘id"org.asciidoctor.convert"version"2.3.0"id‘org.springframework.boot‘version‘2.1.4.RELEASE‘} 查看详情
使用 Gradle 将文件上传到 Artifactory,无需 maven 发布
...是否可以使用Gradle将文件上传到Artifactory存储库而不使用maven-publish插件?我要做的就是将任何文件上传到特定的存储库位置。这里是发布sn-p:publishi 查看详情
OpenCv with Android studio 1.3+ using new gradle - undefined reference
】OpenCvwithAndroidstudio1.3+usingnewgradle-undefinedreference【英文标题】:【发布时间】:2015-11-1705:23:49【问题描述】:我在使用原生OpenCv2.4.11(3.0.0也可以)和AndroidStudio1.3+以及新的ndk支持时遇到问题。所有关于.mk文件的教程,但我想将... 查看详情
Flutter:如何修复“Gradle task assembleDebug failed with exit code -1”?
】Flutter:如何修复“GradletaskassembleDebugfailedwithexitcode-1”?【英文标题】:Flutter:Howtofix\'GradletaskassembleDebugfailedwithexitcode-1\'?【发布时间】:2020-06-2214:32:12【问题描述】:我刚开始在vscode上使用flutter,Android模拟器连接到vscode。当... 查看详情
gradle7.0及以上使用jitpack发布仓库教程
参考技术A最近在使用jitpack发布仓库时发现旧版的发布插件已经无法使用了,于是我研究了maven-publish。因为记性一般,所以在本文记录一下使用方法。提交一次,然后执行gitupdate-index--chmod=+xgradlewhttps://gitee.com/liuxiaoliu66/jiuwo 查看详情
Spring with Gradle - H2 控制台未显示在 localhost:8080/h2-console
】SpringwithGradle-H2控制台未显示在localhost:8080/h2-console【英文标题】:SpringwithGradle-H2consoledoesnotshowinlocalhost:8080/h2-console【发布时间】:2019-03-2002:29:13【问题描述】:我下载了gradle并创建了指向现有gradle文件的新项目。现在我想连接... 查看详情
Android Studio 3.3:Gradle Build Sync 消息是错误 FAILURE: Build failed with an exception
】AndroidStudio3.3:GradleBuildSync消息是错误FAILURE:Buildfailedwithanexception【英文标题】:AndroidStudio3.3:GradleBuildSyncmessageiserrorFAILURE:Buildfailedwithanexception【发布时间】:2019-06-1109:24:08【问题描述】:错误:在org.gradle.api.internal.a 查看详情
使用 gradle 发布到 maven 时删除附加到工件名称的默认 date.time
...布时间】:2016-11-2215:01:01【问题描述】:我正在使用带有maven-publish插件的gradle将工件发布到我们的本地maven存储库。我的build.gradle看起来 查看详情
如何解决错误 FAILURE: Build failed with an exception。 * 其中:脚本 'C:\flutter\packages\flutter_tools\gradle\fl
】如何解决错误FAILURE:Buildfailedwithanexception。*其中:脚本\\\'C:\\\\flutter\\\\packages\\\\flutter_tools\\\\gradle\\\\flutter.gradle\\\'行:1005【英文标题】:HowtosolvetheerrorFAILURE:Buildfailedwithanexception.*Where:Script\'C:\\flutter\\ 查看详情
BUILD FAILED in 6s Exception: Gradle task assembleDebug failed with exit code 1
】BUILDFAILEDin6sException:GradletaskassembleDebugfailedwithexitcode1【英文标题】:【发布时间】:2021-09-0408:21:29【问题描述】:当我尝试在Android模拟器中运行我的Flutter应用时,它会引发以下异常:Launchinglib/main.dartonsdkgphonex86indebugmode...lib/mai... 查看详情
Flutter:gradle build failed with error "A problem occurred evaluation root project 'android' &g
】Flutter:gradlebuildfailedwitherror"Aproblemoccurredevaluationrootproject\\\'android\\\'>Aproblemoccurredusingproject\\\':app\\\'."【英文标题】:Flutter:gradlebuildfailedwitherror"Aproblemoccurredevaluatingroo 查看详情
flyway with spring boot and gradle--org.flywaydb.core.Flyway: 方法 <init>()V not found
】flywaywithspringbootandgradle--org.flywaydb.core.Flyway:方法<init>()Vnotfound【英文标题】:flywaywithspringbootandgradle--org.flywaydb.core.Flyway:method<init>()Vnotfound【发布时间】:2020-01-2622:02:07【问题描述】:我有一个带有gradle并使 查看详情
如何使用旧的 maven 插件在 gradle 中的本地和远程 repo 之间切换?
...布时间】:2016-07-1322:38:23【问题描述】:我没有使用新的maven-publish插件,它看起来很棒并且非常适合这个用例,因为我一直在阅读没有人可以让jar的签名工作(尽管我愿意接受解释的答案以及我还没有找到 查看详情