i try to upload an .aar file to an Artifactory Server. Im using artifactoy plugin :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0' // version plugin support
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.5"
}
}
I read quite a lot of documentation last 2 days and cant figure out why the following is not working:
First of all i do not understand how the artifactory plugin decides which repository it should take to upload the *.aar file ?
In Artifactory are two kind of endpoint to upload for internal use: lib-release-local and lib_snapshot
In my build.gradle in project root i define them:
allprojects {
apply plugin: "com.jfrog.artifactory"
repositories {
jcenter()
maven { url "https://jitpack.io" }
mavenLocal()
mavenCentral()
maven {
url 'https://servername/artifactory/libs-release-local'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
maven {
url 'https://servername/artifactory/libs-snapshot'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
}
artifactoryPublish.skip = true
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
My Second Problem is that Artifactory Plugin uploads something, i see this log entry:
Deploying build descriptor to: https://servername/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under https://servername/artifactory/webapp/builds/eap-androidcore/1475772844540
On the Artifactory Web UI I see only something got uploaded in the "Build Browser". There are no modules listed, the *.aar file is missing. Also no POM gets generated at all like in any other maven repositories.
publishing {
publications {
aar(MavenPublication) {
groupId = 'com.example.core'
artifactId project.name
version = VERSION_NAME
artifact "${project.buildDir}/build/outputs/aar/core_icons-debug.aar"
}
}
}
I checked the path to the file couple of times, it's correct.
So why does artifactory not upload the .aar file ?
Many thanks for reading/helping me
Related
I made an aar library and uploaded it locally, and then another project gradle went to download it, which prompted that it could not be downloaded
Library, aar file has been found locally
plugins {
id 'com.android.library'
id 'maven-publish'
}
def GroupId = 'intbird.soft.gradle'
def ArtifactId = 'maven-publish'
def Version = '1.0.0-SNAPSHOT'
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = GroupId
artifactId = ArtifactId
version = Version
pom {
name = "task Lib"
description = "task Lib Project Pom."
url = 'http://localhost.net'
}
}
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = GroupId
artifactId = ArtifactId
version = Version
}
}
repositories {
maven {
def releasesRepoUrl = "file://C:\\repository"
def snapshotsRepoUrl = "file://C:\\repository"
url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl
}
}
}
}
===============================
My new project
Failed to resolve :intbird.soft.gradle:maven-publish:1.0.0-SNAPSHOT
application gradle code blow:
buildscript {
repositories {
maven { url "file://C:\\repository" }
mavenLocal()
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0"
}
}
app gradle code blow:
dependencies {
implementation 'intbird.soft.gradle:maven-publish:1.0.0-SNAPSHOT'
}
WHY???
I have uploaded a few binary files in maven format to the jfrog artifactory, but could not seem to be able to resolve them in my project. This is what I am essentially doing,
build.gradle(app)
implementation 'io.sariska:sariska-media-transport:5.0.9'
build.gradle (project level)
allprojects {
apply plugin: 'maven-publish'
repositories {
google()
jcenter()
maven {
url = "https://sariska.jfrog.io/artifactory/sariska-media-libs-release-local/"
}
}
}
Am I missing something here?
Well , in my situation
I have declared a mavenRepoURL like this
mavenRepoURL = "https:link/to/artifactory"
Then I repositories section I have added
maven {
url = mavenRepoURL
credentials {
username artifactoryUser
password artifactoryPwd
}
}
and the artifactoryUser and artifactoryPwd either hardcoded or get from proeties or environment variables with this function
artifactoryUser = getConfigurationProperty("ARTIFACTORY_USER", "artifactoryUser", null)
artifactoryPwd = getConfigurationProperty("ARTIFACTORY_PWD", "artifactoryPwd", null)
String getConfigurationProperty(String envVar, String sysProp, String defaultValue) {
def result = System.getenv(envVar) ?: project.findProperty(sysProp)
result ?: defaultValue
}
This wat I can add to my dependencies like maven central
implementation "name:ImportJava:1.2.1-SNAPSHOT"
I need to configure artifactory inside gradle (android app).
I already put all the script below inside build.gradle:
buildscript {
repositories {
jcenter()
maven {
url '.../artifactory/plugins-releases'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.14"
}
}
apply plugin: "com.jfrog.artifactory"
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
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
}
}
resolve {
repository {
repoKey = 'libs-releases'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
When I try to compile a lib from this artifactory, I get this error:
Failed to resolve: my-lib:1.0.0
The com.jfrog.artifactory plugin is for publishing into artifactory, not for using it. If you want to use it, you need to define it as repository for your build.
I had a similar issue. For me, it was that the maven { url "" } value needed to start with "http://". So for exmaple
maven {
url 'http://.../artifactory/plugins-releases'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
I am trying to setup the artifacts (APK/aar files) build process with gradle similar to how I am used to with 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/)
I want to be able to run the gradle commands and achieve similar results. I am using https://github.com/researchgate/gradle-release plugin for the release management (which works fine so I am good with release). But when I run the command gradlew artifactoryPublish the artifact is deployed at some other location (as if it's not respecting the repoKey in the gradle file)
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
So my question is how can I fix my setup so that the artifact is pushed to a URL similar to this:
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 File:
// 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 File:
version=my-lib-android-0.0.3-SNAPSHOT
artifactory_user=myUserName
artifactory_password=myPasssword
artifactory_contextUrl=http://artifactory.XXX.local/artifactory
Using android-maven plugin:
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)
}
}
}
I usually do it with the mavenDeployer-plugin like this.
Don't know if it matches your case, but I'll just leave it here.
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: 'http://arandom.nexus.com:8081/nexus/content/repositories/releases') {
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD);
}
snapshotRepository(url: 'http://arandom.nexus.com:8081/nexus/content/repositories/snapshots') {
authentication(userName: NEXUS_USERNAME, password: NEXUS_PASSWORD);
}
pom.groupId = "groupId"
pom.artifactId = "artifactId"
pom.version = "${versionMajor}.${versionMinor}.${versionPatch}"
}
}
}
some further reading for local repos here
I'm trying to publish an Android library to jcenter. I've followed https://github.com/danielemaddaluno/gradle-jcenter-publish tutorial. Everything works fine until I try to execute
gradle bintrayUpload
When I do so I get a BUILD FAILED. When I look into the errors I see
package com.android.volley does not exist
Therefore the libraries that I have included as a gradle dependency are not being found
dependencies {
compile 'com.mcxiaoke.volley:library:1.+' (...)
}
The same happends with other libraries included.
How can I fix this problem?
I Attach the module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "0.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.shamanland:fab:0.0.8'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:gridlayout-v7:21.0.3'
}
def siteUrl = "SOME_URL"
def gitUrl = 'SOME_URL'
group = "GROUP_ID"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'NAME'
description = 'DESCRIPTION'
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'MY_ID'
name 'MY_NAME'
email 'MY_EMAIL'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "androidupdatechecker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
and the project 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.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
allprojects {
repositories {
jcenter()
}
}
The library is in maven repository, so you need to declare the maven central repository. Add it in your project build.gradle file like this:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1"
}
}
Please refer to the following:
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
At this point, you need in your local. Join in the properties files,
Bintray. User = XXX
Bintray apikey = XXX