apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

CB-8348: (android) Add the ability to publish to Bintray jCenter Maven repository #361

Closed bhariharan closed 7 years ago

bhariharan commented 7 years ago

Platforms affected

Android

What does this PR do?

Adds support for publishing the Cordova platform on jCenter, so that applications can consume Cordova by specifying as a one line dependency in build.gradle.

What testing has been done on this change?

Tested by publishing to my local Maven repo and consuming it in my application.

Checklist

bhariharan commented 7 years ago

With this change, the command gradle bintrayUpload will upload the library artifacts to jCenter.

bhariharan commented 7 years ago

@infil00p @stevengill Could you please review?

infil00p commented 7 years ago

@bhariharan It seems that this change is breaking the Gradle. @stevengill has already uploaded an AAR to BinTray. Also, it's probably not a good idea to put this under @shazron.

bhariharan commented 7 years ago

@infil00p Looks like the issue is missing buildToolsVersion:

Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.

Should I add a default value for that in build.gradle? I'll try that. I can change the author to Steven Gill too. Could you point me to the existing artifact on Bintray?

stevengill commented 7 years ago

Hey! This is super cool. The artifact I posted is at https://bintray.com/cordova/maven/cordova-android#files/org/apache/cordova/cordova-android/5.2.2-beta

It was more of a proof of concept. I never got around to automating it and adding it to the release process for cordova-android. I'd love to do that though.

Lets get these build errors fixed up and I'll take a closer look at your PR and see if it will work with our current release process.

Thanks!

infil00p commented 7 years ago

@bhariharan The buildToolsVersion is determined by cdvBuildToolsVersion in cordova.gradle. The main thing that I'm wondering is why cordova.gradle isn't being included here, or why it's not returning the buildToolsVersion.

I really wish our Gradle scripts were a lot simpler, that's been the main hurdle getting this thing happening.

bhariharan commented 7 years ago

@stevengill @infil00p I updated the repo settings based on your existing Maven repo and updated the author's name to Steve Gill here. I'm not sure why it's not including properties from cordova.gradle, but I moved the inclusion higher up - let's see if that makes a difference. Let me know if you'd like me to change anything else.

bhariharan commented 7 years ago

Looks like this might be the issue:

* Where:
Build file '/home/travis/build/apache/cordova-android/test-com.test.create.app1/CordovaLib/build.gradle' line: 39
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> Plugin with id 'com.jfrog.bintray' not found.

Funnily enough, it seems to work fine locally. @infil00p How do I simulate the Gradle tests you run on Travis locally, so I can debug and fix the test failure?

infil00p commented 7 years ago

@bhariharan I'm going to blame Travis for this. I'll take a look at this issue later today or tomorrow, time permitting.

bhariharan commented 7 years ago

It this build stuck?

codecov-io commented 7 years ago

Codecov Report

Merging #361 into master will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #361   +/-   ##
=======================================
  Coverage   35.58%   35.58%           
=======================================
  Files          12       12           
  Lines        1037     1037           
  Branches      173      173           
=======================================
  Hits          369      369           
  Misses        668      668

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5591a1a...8915e40. Read the comment docs.

bhariharan commented 7 years ago

@stevengill The build errors are fixed. You should be able to run gradle bintrayUpload and see the artifacts on your Maven repo once this pull request is merged. The only requirement is that BINTRAY_USER and BINTRAY_KEY are set as environment variables, their values being your Bintray username and key respectively.

bhariharan commented 7 years ago

@infil00p @stevengill Any feedback on this PR? I was hoping to switch my plugin to consume Cordova from jCenter soon :-)

stevengill commented 7 years ago

Yes! Sorry I promise to test it locally today and merge it in if all goes well!

bhariharan commented 7 years ago

Thanks @stevengill! Let me know if it needs any tweaks.

stevengill commented 7 years ago

So it doesn't seem to be uploading for me but the output isn't helping.

I managed to add gradlew into cordova-android/framework by importing it into android studio. Then I run the command ./gradlew bintrayUpload and get the following.

./gradlew bintrayUpload
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileLint UP-TO-DATE
:copyDebugLint UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:mergeDebugProguardFiles UP-TO-DATE
:packageDebugRenderscript UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:packageDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
:bundleDebug UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:checkReleaseManifest
:prepareReleaseDependencies
:compileReleaseAidl UP-TO-DATE
:compileReleaseNdk UP-TO-DATE
:copyReleaseLint UP-TO-DATE
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders UP-TO-DATE
:generateReleaseAssets UP-TO-DATE
:mergeReleaseAssets UP-TO-DATE
:mergeReleaseProguardFiles UP-TO-DATE
:packageReleaseRenderscript UP-TO-DATE
:compileReleaseRenderscript UP-TO-DATE
:generateReleaseResValues UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:packageReleaseResources UP-TO-DATE
:processReleaseManifest UP-TO-DATE
:generateReleaseBuildConfig UP-TO-DATE
:processReleaseResources UP-TO-DATE
:generateReleaseSources UP-TO-DATE
:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
:compileReleaseJavaWithJavac UP-TO-DATE
:processReleaseJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:mergeReleaseJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:bundleRelease UP-TO-DATE
:sourcesJar
:install
:bintrayUpload

BUILD SUCCESSFUL

Total time: 8.86 secs

This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html

The build time alone makes me think the upload isn't happening. No new activity at https://bintray.com/cordova

Any ideas?

bhariharan commented 7 years ago

@stevengill Did you put in your BINTRAY_USER and BINTRAY_KEY values in bash? If that's in the env variables path, the next thing to try is the repo path of the publishing on jCenter. Try echo $BINTRAY_USER and echo $BINTRAY_KEY on your terminal. Also, check if they're showing up as unpublished items in your jCenter repo.

bhariharan commented 7 years ago

@stevengill Once BINTRAY_USER and BINTRAY_KEY are set, try this:

./gradlew :framework:bintrayUpload

instead of:

./gradlew bintrayUpload
stevengill commented 7 years ago

I did but looks like i added it incorrectly. I added them straight to my terminal so echo $BINTRAY_USER and key worked but when i logged it in build.gradle, it did not. I added them properly now to my .profile file and it has access to them.

Now getting

:bintrayUpload FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bintrayUpload'.
> Could not create version '6.1.2': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]

* 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: 16.423 secs

I'll continue debugging.

bhariharan commented 7 years ago

Interesting! That means it didn't accept your auth key.

stevengill commented 7 years ago

Yup. I think i'm using the wrong BINTRAY_USER value. Using my email login. Looks like I need to use my account name? https://bintray.com/docs/api/

bhariharan commented 7 years ago

Yeah - use your Bintray username. Mine's bhariharan for instance.

stevengill commented 7 years ago

Woo! https://bintray.com/cordova/maven/cordova-android/6.1.2

stevengill commented 7 years ago

Thanks @bhariharan!! I'll merge this up and add it to the release process!

bhariharan commented 7 years ago

Right on! Awesome @stevengill! Thanks! I've got some other ideas for other Cordova improvements as a heavy Cordova platform user. I'll reach out to you on JIRA.

stevengill commented 7 years ago

Sweet! Feel free to ping me on the cordova slack too. slack.cordova.io to signup.