![](/img/trans.png)
[英]Don't upload *.jar files to artifactory except one using org.jfrog.buildinfo
[英]Upload jar to JFrog Artifactory using gradle
我想將我的項目(Android Studio)中的 jar 上傳到 JFrog Artifactory。 我瀏覽了幾個鏈接,最后我這樣做了,
apply plugin : 'maven'
configurations {
resultArchives
}
uploadResultArchives {
repositories {
mavenDeployer {
repository(url: "http://artifactory/libs-release-local/")
{
authentication(userName: 'a', password: 'pass');
}
}
}}
artifacts{
resultArchives file: file('gradle/plugin-1.0.0.jar')
}
這在 gradle 中構建得很好,但我看不到任何內容被上傳。 我錯過了什么嗎?
請使用Gradle Artifactory 插件。 它負責上傳並使用構建元數據注釋工件。
JFrog GitHub 存儲庫包含許多關於如何配置插件的示例。
你需要插件:
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
構建項目並從 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()
}
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
}
}
}
和出版:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
gradle.properties
artifactory_user=publisher
artifactory_password=*****
artifactory_contextUrl=http://IP:PORT/artifactory
所以一切都很簡單。 如果你想上傳你的jar:
gradle artifactoryPublish
我可以上傳jar。 這就是我的 build.gradle(app 模塊) 的樣子。另外,如果我在根 build.gradle 中編寫代碼(這是我檢查過的帖子所建議的,我得到一個錯誤,未指定 buildToolsversion)
apply plugin: 'com.android.application
apply plugin: 'maven'
apply plugin: 'project-reports'
apply plugin: 'maven-publish
apply plugin: 'com.jfrog.artifactory'
GroupId = "grp Id"
version = 1.0.0
buildscript {
repositories {
jcenter()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.gradle.publish:plugin-publish-plugin:0.9.3'
}
}
apply plugin:'maven'
publishing {
publications {
mavenJava(MavenPublication) {
// from components.java
artifact file("path/plugin.jar")
}
}
}
allprojects {
apply plugin: "com.jfrog.artifactory"
}
artifactory {
contextUrl = "http://artifactory"
publish {
repository {
repoKey = 'libs-snapshot-local'
username = "unam"
password = "pass"
maven = true
}
defaults{
publications ('mavenJava')
publishArtifacts = true
}
}
}
repositories {
maven {
url 'http://artifactory/libs-release-local/'
credentials {
username = "uname"
password = "pass"
}
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.vitalconnect.artifactory_demo"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.