How to publish android library to Jfrog bintray? - android

I am working on Android library development, i have already finished my library work and generated aar and jar file, but when i am trying to publish to binary at that time i am getting one error message.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mylittlelibrary:bintrayUpload'.
> Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.391 secs
Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
2:41:59 AM: External task execution finished 'bintrayUpload'.
build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
repositories {
mavenCentral()
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
}
group = 'helloaar.example.com.mylittlelibrary'
version = '1.0.2'
task generateSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
}
task generateJavaDocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath()
.join(File.pathSeparator))
}
task generateJavaDocsJar(type: Jar) {
from generateJavaDocs.destinationDir
classifier 'javadoc'
}
generateJavaDocsJar.dependsOn generateJavaDocs
bintray {
user = 'abcd'
key = '1234567890fghgfhffjfgjfjfjrtyjtkjg'
pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
version {
name = '1.0.2'
desc = 'My test upload'
released = new Date()
vcsTag = '1.0.2'
}
licenses = ['Apache-2.0']
vcsUrl = ''
websiteUrl = ''
}
configurations = ['archives']
}
artifacts {
archives generateJavaDocsJar
archives generateSourcesJar
}
Please kindly go through my script and suggest me some solution.

Before you publish to Bintray you must have a stable build of your code.
The hierarchy on Bintray is the following:
User --> Repo --> package --> version --> artifact
means that the Repo should be above the package by that hierarchy.
The following lines in your gradle.build are probably the main cause for the error:
pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
}
The hierarchy is wrong.
When using maven you should check that you comply with the maven convention, else the Maven Build can not succeed. Explanation for Maven Repositories on Bintray.
The error you had:
HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
Means that you do not have a Repository on Bintray calls maven. All the packages versions and files should be under the Bintray Repository you have created.
For more details or support issues you can use the Bintray support team which is available for all Bintray users and can help you with any problem related to any JFrog platform services such as Bintray, Artifactory, Mission control & Xray.

pkg {
repo = 'maven'
name = 'helloaar.example.com.mylittlelibrary'
version {
name = '1.0.2'
desc = 'My test upload'
released = new Date()
vcsTag = '1.0.2'
}
Could not create package 'abcd/maven/helloaar.example.com.mylittlelibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
2:41:59 AM: External task execution finished 'bintrayUpload'.
'abcd/maven/helloaar.example.com.mylittlelibrary'
abcd : bintray user name
maven : pkg { repo = 'maven' } set by you, example 'abcd/android-lib/helloaar.example.com.mylittlelibrary' when set repo = 'android-lib'
helloaar.example.com.mylittlelibrary : pkg{ name = 'helloaar.example.com.mylittlelibrary'
-
first : check your bintray account,
second : make repository,
third : modify your pkg repo = 'input making repository name from second step' build.gradle
last : build again
i hope help for you, have a nice day

Related

Android studio 2.2.2 publish my app module as library to jcenter with bintray repository

Here, I have done qr code scan project successfully. i have used for qrcodereaderview 1.0.0 v url repository library. this is my dependency.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}
I have only one app module in my project.I want to upload this project as a library(.AAR) to jcenter repository.
I have tried for some jcenter uploading steps and I got Successful upload response also from bintrayupload.
For this reason, I have created Github login and created project url. but, I did not upload my project code into github. I have given empty project url only in build.gradle.
but, when I saw in bintray repository.There is no code update/version change on my bintray maven repository.
Android Studio Project convert as .aar(library) file and uploading to jcenter repository in below steps following.
1). I have changed main app module build.gradle files for three changes.
Changed library plugin,commented application id and changed manifest file launcher activity.
My app module build.gradle file:
//apply plugin: 'com.android.application'
apply plugin: 'com.android.library'
ext {
bintrayRepo = 'maven' //mavenrepo
bintrayName = 'app'
publishedGroupId = 'com.test.testsdkproj16'
libraryName = 'TestsdkProj16'
artifact = 'app'
libraryDescription = 'A simple qr code library calling your project in Android'
siteUrl = 'https://github.com/vhkrishnanv/TestsdkProj16'
gitUrl = 'https://github.com/vhkrishnanv/TestsdkProj16.git'
githubRepository= 'vhkrishnanv/TestsdkProj16'
libraryVersion = '1.0.0'
developerId = 'vhk*********6'
developerName = 'harikrish'
developerEmail = 'vhkris******#gmail.com'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
//applicationId "com.test.testsdkproj16"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:1.0.0'
compile files('libs/ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar')
}
// Place it at the end of the file
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
My Manifest file:
<activity android:name=".MainActivitySDK_16">
<intent-filter>
<action android:name="com.test.testsdkproj16.MainActivitySDK_16" />
<!--comment when exporting AAR below two lines-->
<!--<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
</activity>
gradle.properties file:
bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***
2). Next Steps for upload my studio project to bintray.com. I have used three command for that.
-gradleW clean
BUILD SUCCESSFUL
-gradleW install
BUILD SUCCESSFUL
-gradleW bintrayupload
BUILD SUCCESSFUL
After executed the above three commands, when i saw in my bintray repository, there is no change in my repository.
My repository's screenshot
I dont know exactly what step is missing. Can anyone help to come out this error.
Overall I want to Publish my Studio2.2.2 project(converted as .aar library) to jcenter repository and need to get my project url this like. ( when i tried this url also in other new project in dependencies, getting error while sync,because, code/.aar not upload in repository)
I have one pending final steps is there. once code is uploaded, need to jcenter sync is pending in bintray repos.then only, I can able to use the above url to other New Project.
compile 'com.test.testsdkproj16:app:1.0.0'
In your question you have written, that you keep credientials to bintray account in gradle.properties:
bintray.user=vhk*********6
bintray.apikey=***1f************************98f51***
If you look into the source file from:
https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle
You will see the following lines:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
You have put the credientials in the wrong file. They should be in local.properties
EDIT
After long discussion finally the project was published to bintray. The problem here was that the user was publishing to another organisation project. So indeed, the answer made by #gba was correct.
However, #harikrishnan was advised to download bintray.gradle and install.gradle to the project and modify them. Here is how they should look:
bintray.gradle
apply plugin: 'com.jfrog.bintray'
apply from: '../bintray.data.gradle'
version = libraryVersion
if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
task javadoc(type: Javadoc) {
options.addBooleanOption('Xdoclint:none', true)
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(new FileInputStream(file(rootProject.file('local.properties'))))
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
userOrg = userOrg
licenses = allLicenses
publish = true
publicDownloadNumbers = true
}
}
install.gradle
apply plugin: 'com.github.dcendents.android-maven'
apply from: '../bintray.data.gradle'
group = publishedGroupId
install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
groupId publishedGroupId
artifactId artifact
name libraryName
description libraryDescription
url siteUrl
licenses {
license {
name licenseName
url licenseUrl
}
}
developers {
developer {
id developerId
name developerName
email developerEmail
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
bintray.data.gradle:
ext {
bintrayRepo = 'maven'
bintrayName = 'samplename'
publishedGroupId = 'sample.package.name'
libraryName = 'SampleName'
artifact = 'samplename'
libraryDescription = ''
siteUrl = ''
gitUrl = ''
libraryVersion = '1.0.0'
developerId = ''
developerName = 'Zagórski'
developerEmail = ''
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
app's build.gradle:
apply plugin: 'com.android.application'
(...)
apply from: '../install.gradle'
apply from: '../bintray.gradle'
main build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
A sample project that utilises those classes is here
seems like you are missing the userOrg parameter. Please look at the following threads:
HTTP/1.1 401 Unauthorized when uploading binary on bintray
Trouble Publishing Android Studio Library on jCenter with Bintray
publish my android aar to jcenter
In short, your repo is under your org and not under your user account.

Volley doesn't work with Gradle 2.0 and Instant run

I've recently updated Android Studio to version 2.0 : Beta 7.
I'm trying to use Instant Run, I've just installed Gradle 2.0.
But now I can't compile my project due to an error related to bintray.gradle
When I compile I get the following error :
Error:Cannot configure the 'publishing' extension after it has been accessed.
Debugger Error :
Error:FAILURE: Build failed with an exception.
* Where:
Script 'C:\Project\AtkApp\volley\bintray.gradle' line: 43
* What went wrong:
A problem occurred evaluating script.
> Cannot configure the 'publishing' extension after it has been accessed.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Bintray.gradle :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2"
}
}
// apply the plugin with its class name rather than its Id to work around gradle limitation of
// not being able to find the plugin by Id despite the dependencies being added right above. Gradle
// is currently not capable of loading plugins by Id if the dependency is anywhere else than
// in the main project build.gradle. This file is "imported" into the project's build.gradle
// through a "apply from:".
apply plugin: com.jfrog.bintray.gradle.BintrayPlugin
apply plugin: 'maven-publish'
project.ext.group = 'com.android.volley'
project.ext.archivesBaseName = 'volley'
project.ext.version = '1.0.0'
project.ext.pomDesc = 'Volley Android library'
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
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
}
publishing {
publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
}
bintray {
user = System.env.BINTRAY_USER
key = System.env.BINTRAY_USER_KEY
publications = [ 'library' ]
publish = project.has("release")
pkg {
userOrg = 'android'
repo = 'android-utils'
group = project.ext.group
name = project.ext.group + '.' + project.ext.archivesBaseName
desc = project.ext.pomDesc
licenses = [ 'Apache-2.0' ]
websiteUrl = 'https://tools.android.com'
issueTrackerUrl = 'https://code.google.com/p/android/'
vcsUrl = 'https://android.googlesource.com/platform/frameworks/volley.git'
labels = ['android', 'volley', 'network']
publicDownloadNumbers = true
version {
name = project.ext.version
desc = project.ext.pomDesc + ' version ' + project.ext.version
gpg {
sign = true
passphrase = System.env.GPG_PASSPHRASE
}
}
}
}
I have faced same problem when I update the latest version.
I tried do this and success.
The culprit is publishing tag used in bintray.gradle of Volley project.
With Gradle 2.0.0 update its complaining about publishing can't be configured after it has been accessed.
For now commenting following line in build.gradle of Volley project will get the build going.
//apply from: 'bintray.gradle'
I will updted the comment once have better solution.
Don't comment this line:
apply from: 'bintray.gradle'
just change these line of codes
publishing {
publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
}
to
publishing.publications {
library(MavenPublication) {
groupId project.ext.group
artifactId project.ext.archivesBaseName
version project.ext.version
// Release AAR, Sources, and JavaDoc
artifact "$buildDir/outputs/aar/volley-release.aar"
artifact sourcesJar
artifact javadocJar
}
}
publishing{ publications{}}, it's in the volley files you added to your project. Don't waste time looking in the project gradle.

Publishing android library as maven jar

Gradle/maven newbie here. I have created a library that is currently published to bintray/jcenter as an AAR, to be used with gradle in Android Studio projects.
However, since my library doesn't really have any hard Android dependencies, and may be used in any Java SE environment, I would like to publish it also as a normal jar. Since I am not very familiar with the non-android java development community I am not sure if this means I should publish it to Maven central, or would developers typically be fine fetching my library from bintray, given that the library is actually hosted in a maven repo on bintray?
Should I simply extend my artifacts to include the jar (alongside with the aar, the javadoc and the source jar), or should I typically publish the jar separately, say to Maven central?
Getting the bintray/jcenter stuff up and running was no picnic, I found a few guides on how to do it, but none was really complete, but finally I have it working. I am however having a surprisingly difficult time finding a similar easy guide for maven publishing.
My gradle file looks like this:
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 1
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
}
}
group = <my library name>
version = <my version>
dependencies {
}
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))
options.overview = 'src/main/overview.html'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = <my library name>
websiteUrl = <my site url>
vcsUrl = <my git url>
licenses = ["Apache-2.0"]
publish = true
}
}
The com.github.dcendents.android-maven plugin offers an install task that produces the AAR, Source Jar and Javadoc Jar. I have defined my own bintray task that publishes the library to bintray. What would be the easiest way to create a task for publishing my library also as a standard jar to maven? Can I use com.github.dcendents.android-maven for this as well, or do I need a separate plugin?

Some problems were found with the configuration of task ':app:bintrayUpload' when trying to upload an Android Library to jCenter

I am trying to upload my library to jCenter. I am following this tutorial:
http://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
After following the steps and getting to typing in the Android terminal "> gradlew bintrayUpload" I get the following error:
:app:bintrayUpload FAILED
FAILURE: Build failed with an exception.
What went wrong:
Some problems were found with the configuration of task ':app:bintrayUpload'.
No value has been specified for property 'packageName'.
No value has been specified for property 'user'.
No value has been specified for property 'apiKey'.
No value has been specified for property 'repoName'.
Before flagging my question as a duplicate, I shall indicate that i tried the solutions from the following stackoverflow questions:
Publications(s) specified but no publications exist in project :library
After trying that solution, I get the following error:
FAILURE: Build failed with an exception.
What went wrong:
Task 'bintrayUpload' not found in root project 'UniFont'.
Searching this error, I got to the following solution from this question on stackoverflow:
Task 'bintrayUpload' not found in root project 'bin'
That was not the solution for me. My path with jdk/jre exists. I have tried switching between them multiple times. Optional question:
Do I need to declare both JDK and JRE paths into Windows Envirorment Variables?
Here is my top level 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.2.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
//apply plugin: 'com.jfrog.bintray'
repositories {
jcenter()
}
}
Here is my build.gradle(app module):
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
ext {
bintrayRepo = 'maven'
bintrayName = 'Library Name'
publishedGroupId = '...'
libraryName = '...'
artifact = '...'
libraryDescription = 'A simple library for setting a single font in a View in Android.'
siteUrl = '...'
gitUrl = '...'
libraryVersion = '1.0'
developerId = '...'
developerName = '...'
developerEmail = '...'
licenseName = 'The Apache Software License, Version 2.0'
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
Can anyone please help me with this?
Thanks you!
Here is a simple tutorial for uploading your libraries to bintray.
Your build.gradle file of project should be something like this.
buildscript {
//...
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
}
//...
}
And add these lines at the end of build.gradle file of your desired module which you want to upload to jcenter
ext {
developerId = 'your username in bintray'
developerName = 'your name'
developerEmail = 'your email'
bintrayRepo = 'maven'
bintrayName = 'your library name in bintray'
publishedGroupId = 'your group id'
libraryName = 'your library name(better to be as like as bintrayName)'
artifact = 'your artifact'
libraryDescription = 'description'
libraryVersion = 'version'
}
apply from: 'https://raw.githubusercontent.com/smasoumi/Bintray/master/install.gradle'
apply from: 'https://raw.githubusercontent.com/smasoumi/Bintray/master/bintray.gradle'
And also add your apiKey and username of bintray to your local.properties and change your gradle version to 2.2.1
Then execute
gradlew.bat install
If it shows successful message then upload your project to bintray by this command
gradlew.bat bintrayUpload
Also be sure that JDK path is set.

Gradle push library to local/private maven repo [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am just changing from eclipse to android studio. To have the benefits, gradle is teaching us, I am trying to set up a local repository using jForgs Artifacts. Now I am facing the problem, that I want to push/publish a library I have written in Android Studio to artifacts so I can easily import it via a depency in my next android App project.
The Folder structure looks like this:
LibDeploy
build.gradle
gradle.properties
-> app
--> build
--> libs
--> src
--> main
--> java
build.gradle
-> gradle
--> wrapper
my gradle.build in the app folder look like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.0'
classpath 'com.github.dcendents:android-maven-plugin:1.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3'
}
}
import java.text.SimpleDateFormat
def globalVersion = new Version(currentVersion)
// Define the artifacts coordinates
group = 'org.jfrog.example.android'
version = globalVersion
status = version.status
// Plugins
apply plugin: 'com.android.library'
apply plugin: 'artifactory'
// We need the patched maven plugin since 'install' task is overriden by 'installDebugTest', see: https://github.com/dcendents/android-maven-plugin
apply plugin: 'android-maven'
// Android
android {
compileSdkVersion 21
buildToolsVersion "21.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
}
}
configurations {
published
}
task sourceJar(type: Jar) {
from android.sourceSets.main.java
classifier "sources"
}
artifactoryPublish {
dependsOn sourceJar
}
artifacts {
published sourceJar
}
configure(install.repositories.mavenInstaller) {
pom.project {
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}
artifactory {
contextUrl = 'http://localhost:8080/artifactory'
publish {
repository {
repoKey = 'libs-snapshot-local' //The Artifactory repository key to publish to
username = artifactory_user //The publisher user name, property taken from gradle.properties
password = artifactory_password //The publisher password, property taken from gradle.properties
}
defaults {
publishConfigs('archives', 'published')
properties = ['build.status': "$it.project.status".toString()]
publishPom = true //Publish generated POM files to Artifactory (true by default)
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
}
}
resolve {
repository {
repoKey = 'libs-release' //The Artifactory (preferably virtual) repository key to resolve from
username = artifactory_user //Optional resolver user name (leave out to use anonymous resolution), property taken from gradle.properties
password = artifactory_password //The resolver password, property taken from gradle.properties
}
}
}
repositories {
jcenter()
}
// Our project dependencies
dependencies {
compile 'joda-time:joda-time:2.3'
// Backward compatibility for andoird <http://developer.android.com/tools/support-library/index.html>
//compile 'com.android.support:support-v4:19.1.+'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
class Version {
String thisVersion = 'default'
String status = 'default'
Version(String versionValue) {
thisVersion = versionValue
if (thisVersion.endsWith('-SNAPSHOT')) {
status = 'integration'
} else {
status = 'release'
}
}
String toString() {
thisVersion
}
}
When I am trying to push/publish to artifactory via gradlew artifactoryPublish
I am getting the error:
:app:sourceJar
FAILURE: Build failed with an exception.
* What went wrong:
Cannot convert the provided notation to a File or URI: [src/main/java].
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
I think the problem should be in this line in the build.gradle file
task sourceJar(type: Jar) {
from android.sourceSets.main.java
classifier "sources"
}
Does anybody have a great tut how to set up a central maven repo for our build process?
Thanks in advance!
I solved this by changing
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main
}
to
task sourcesJar(type: Jar) {
classifier = 'sources'
from 'src/main/java'
}

Categories

Resources