tun*_*urk 73 publish artifactory gradle
我是Gradle和Artifactory的新手,我想将一个JAR文件上传到Artifactory.
这是我的build.gradle档案:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'artifactory-publish'
groupId = 'myGroup'
version = '1.0'
def artifactId = projectDir.name
def versionNumber = version
artifactory {
contextUrl = 'http://path.to.artifactory' // base artifactory url
publish {
repository {
repoKey = 'libs-releases' // Artifactory repository key to publish to
username = 'publisher' // publisher user name
password = '********' // publisher password
maven = true
}
}
}
artifactoryPublish {
dependsOn jar
}
Run Code Online (Sandbox Code Playgroud)
运行artifactoryPublish任务后,构建成功,如下所示:
> gradle artifactoryPublish --stacktrace
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:artifactoryPublish
Deploying build info to: http://path.to.artifactory/api/build
BUILD SUCCESSFUL
Total time: 7.387 secs
Run Code Online (Sandbox Code Playgroud)
但是,除了构建信息之外,没有任何内容发送到Artifactory.
任何帮助都感激不尽.
编辑:
正如JBaruch所说,我补充道
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
Run Code Online (Sandbox Code Playgroud)
和默认部分到神器任务
defaults {
publications ('mavenJava')
}
Run Code Online (Sandbox Code Playgroud)
现在它有效.
谢谢
JBa*_*uch 49
那是因为你没有publications.该artifactory-publish插件适用于maven-publish插件和上传publications.
如果您更喜欢使用旧的maven插件,则需要artifactory插件,而不是artifactory-publish.
请查看官方文档的"使用Gradle"页面中的Overview部分.
你需要插件:
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
Run Code Online (Sandbox Code Playgroud)
构建项目并从 artifactory 中检索 jars:
buildscript {
repositories {
maven {
url 'http://[IP]:[PORT]/artifactory/gradle-dev'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
mavenCentral()
}
dependencies { classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4" }
}
repositories {
mavenCentral()
mavenLocal()
}
Run Code Online (Sandbox Code Playgroud)
Artifactory 配置:
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'gradle-dev-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('mavenJava')
}
publishBuildInfo = true
publishArtifacts = true
publishPom = true
}
resolve {
repository {
repoKey = 'gradle-dev'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
Run Code Online (Sandbox Code Playgroud)
和出版:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
Run Code Online (Sandbox Code Playgroud)
gradle.properties
artifactory_user=publisher
artifactory_password=*****
artifactory_contextUrl=http://IP:PORT/artifactory
Run Code Online (Sandbox Code Playgroud)
所以一切都很简单。如果你想上传你的jar:
gradle artifactoryPublish
Run Code Online (Sandbox Code Playgroud)
我得到了这个工作.我实际上是在使用已经创建的jar,所以我使用下面的代码来指定要上传的jar:
publishing {
publications {
mavenJava(MavenPublication) {
// from components.java
artifact file("path/jar-1.0.0.jar")
}
}
}
Run Code Online (Sandbox Code Playgroud)
这就是对我有用的命令 gradle clean build publish
apply plugin: 'maven-publish'
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'maven'
group = 'com.mine'
version = '1.0.1-SNAPSHOT'
repositories{
mavenCentral()
}
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.google.guava:guava:27.0-jre'
testCompile 'junit:junit:4.12'
//compile 'org.apache.commons:commons-lang3:3.8.1'
}
publishing {
repositories {
maven {
url = 'https://artifactory.mine.net/artifactory/my-snapshots-maven'
credentials {
username 'user'
password 'password'
}
}
}
publications{
mavenJava(MavenPublication) {
from components.java
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
62108 次 |
| 最近记录: |