gpt4 book ai didi

android - Gradle 发布到 Artifactory 的特定仓库

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:15:06 26 4
gpt4 key购买 nike

我正在尝试使用 gradle 设置 Artifact (APK/aar 文件)构建过程,类似于我习惯使用 maven 的方式。

mvn release:prepare (Adjusts version, checks into SVN, creates the tag) 
mvn release:perform -Dgoals=deploy (Pushes the artifact to http://artifactory.XXX.local/artifactory/libs-releases-local/)

我希望能够运行 gradle 命令并获得类似的结果。我正在使用 https://github.com/researchgate/gradle-release发布管理插件(工作正常,所以我很擅长发布)。但是当我运行命令 gradlew artifactoryPublish Artifact 被部署在其他一些位置(好像它不尊重 gradle 文件中的 repoKey)

D:\my-lib-android-0.0.2>gradlew artifactoryPublish ... ... [buildinfo] Not using buildInfo properties file for this build. :artifactoryPublish Deploying build descriptor to: http://artifactory.XXX.local/artifactory/api/build Build successfully deployed. Browse it in Artifactory under http://artifactory.XXX.local/artifactory/webapp/builds/my-lib-android-0.0.2/1449880830949>

BUILD SUCCESSFUL

Total time: 9.692 secs

所以我的问题是如何修复我的设置,以便将 Artifact 推送到与此类似的 URL:

http://artifactory.XXX.local/artifactory/libs-releases-local/com/example/my-lib-android/0.0.2/my-lib-android-0.0.2.aar

build.gradle 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '3.1.2')
classpath 'net.researchgate:gradle-release:2.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'net.researchgate.release' version '2.3.4'
}

apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
apply plugin: 'net.researchgate.release'

allprojects {
repositories {
jcenter()
maven {
url 'http://artifactory.XXX.local/artifactory/libs-releases-local'
}
}
}

artifactory {
contextUrl = "${artifactory_contextUrl}"
//The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = "libs-releases-local"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true

}
}
}

release {
revertOnFail = false
}
task build{

}

gradle.properties 文件:

version=my-lib-android-0.0.3-SNAPSHOT
artifactory_user=myUserName
artifactory_password=myPasssword
artifactory_contextUrl=http://artifactory.XXX.local/artifactory

最佳答案

使用android-maven插件:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
classpath 'com.github.dcendents:android-maven-plugin:1.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.2.0'
}
}

apply plugin: 'android-library'
apply plugin: 'com.jfrog.artifactory-upload'
apply plugin: 'android-maven'


configurations {
published
}

task sourceJar(type: Jar) {
from android.sourceSets.main.java
classifier "sources"
}

artifactoryPublish {
dependsOn sourceJar
}

artifacts {
published sourceJar
}

artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = "libs-releases-local"
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publishConfigs('archives', 'published')
publishPom = true //Publish generated POM files to Artifactory (true by default)
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
}
}
}

关于android - Gradle 发布到 Artifactory 的特定仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34235086/

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