Reputation: 942
I want to upload a jar inside my project (Android Studio) to JFrog Artifactory. I have gone through few links and finally I am doing this,
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')
}
This is building fine in gradle but I see nothing gets uploaded. Am I missing something?
Upvotes: 0
Views: 6375
Reputation: 5623
You need plugins :
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
to build project and retrieve jars from artifactory:
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 configs:
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
}
}
}
and for publishing:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
gradle.properties
artifactory_user=publisher
artifactory_password=*****
artifactory_contextUrl=http://IP:PORT/artifactory
So everything is just simple. If you want to upload your jar:
gradle artifactoryPublish
Upvotes: 3
Reputation: 942
I am able to upload jar. This is how my build.gradle(app module) looks like.Also, if I write the code in the root build.gradle (which was suggested by posts that I checked, I getan error, buildToolsversion not specified)
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'
}
Upvotes: 0
Reputation: 22893
Please use Gradle Artifactory plugin. It takes care of the upload and annotates the artifacts with build metadata.
JFrog GitHub repo contains a lot of examples on how to configure the plugin.
Upvotes: 2