gradle 上传jar包_Gradle:如何将自定义JAR文件上传到Maven存储库

你是对的,工件关闭只能向给定的配置添加工件(见

ArtifactHandler API).

你有两个选择:

1)按照here(见第45.6.4.1节“每个项目的多个工件”)添加工件过滤器.如果您使用此方法,请尝试声明存档配置,如:

artifacts {

archives file: file('bin/result.jar'), name: 'result', type: 'jar'

}

这样,你的工件过滤器就像这样:

addFilter('result') {artifact, file ->

artifact.name == 'result'

}

2)将其作为单独的maven模块上传.如果result.jar是您上传的唯一jar,这可能是一个很好的解决方案.

configurations {

resultArchives

}

uploadResultArchives {

repositories {

mavenDeployer {

repository(url: "same/url/here")

}

}

}

artifacts{

resultArchives file: file('bin/result.jar')

}

希望这可以帮助.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用以下步骤将 Jar上传到 JFrog Artifactory: 1. 在 build.gradle 文件中添加以下代码,以配置 JFrog 插件: ``` buildscript { repositories { maven { url "${artifactory_contextUrl}/plugins-release" credentials { username = "${artifactory_user}" password = "${artifactory_password}" } name = "maven-username-plugins" } } dependencies { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>" classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>" } } apply plugin: 'com.jfrog.artifactory' apply plugin: 'maven-publish' artifactory { contextUrl = "${artifactory_contextUrl}" publish { repository { repoKey = '<your-repo-name>' username = "${artifactory_user}" password = "${artifactory_password}" maven = true } defaults { publications ('<your-publication-name>') } } } ``` 2. 在 gradle.properties 文件中添加以下代码,以配置 Artifactory 的用户名和密码: ``` artifactory_contextUrl=<your-artifactory-url> artifactory_user=<your-artifactory-username> artifactory_password=<your-artifactory-password> ``` 3. 将 Jar 包添加到发布配置中,在 build.gradle 文件中添加以下代码: ``` publishing { publications { maven(MavenPublication) { groupId = '<your-group-id>' artifactId = '<your-artifact-id>' version = '<your-version>' artifact(file('<path-to-your-jar>')) } } } ``` 4. 运行以下命令将 Jar上传到 Artifactory: ``` ./gradlew artifactoryPublish ``` 这将把你的 Jar 包发布到 Artifactory 中的指定仓中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值