Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch backend #20

Merged
merged 18 commits into from
Jun 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,25 @@ jobs:
- restore_cache:
key: gradle-cache-v0-{{ checksum "build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

# Install Artifactory - has to be BEFORE we run the tests
- run: docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest
- run: sleep 30 # Sleep a little bit until Artifacotry is started...

- run:
environment:
ANDROID_HOME: "/home/circleci/android-sdk" # TODO: Try to don't hardcode me and use $HOME env variable
command: ./gradlew build --no-daemon
command: ./gradlew test --no-daemon

# Save the gradle folder for caching
- save_cache:
paths:
- ~/.gradle
key: gradle-cache-v0-{{ checksum "build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

# Install Artifactory and test uploading works
- run: docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest
- run: sleep 30 # Sleep a little bit until Artifacotry is started...
- run:
command: |
cd consumer
echo "sdk.dir=$HOME/android-sdk" >> local.properties
./gradlew build artifactoryPublish -PartifactoryUser=admin -PartifactoryKey=password --no-daemon

workflows:
Expand Down
29 changes: 29 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ArtifactoryPublish Development

## Plugin dependencies
### AndroidArtifacts
We are using the [AndroidArtifacts](https://github.com/StefMa/AndroidArtifacts/) to generate the [Gradle publications](https://docs.gradle.org/current/userguide/publishing_maven.html)
for us. This plugin will only use the generated **publications** and streamline the process over the "original" [Artifactory plugin](https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin).

### Artifactory Plugin
As already mentioned above we use the [Artifactory plugin](https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin).
Basically this plugin will only setup some default properties for you for this plugin. See the [`ArtifactoryPublishConfiguration` class](https://github.com/StefMa/ArtifactoryPublish/blob/1341ccdc82d1034151aab68ccefb7568e0bbb471/core/src/main/groovy/guru/stefma/artifactorypublish/ArtifactoryPublishConfiguration.groovy).

## Tasks
Because we depend on the [AndroidArtifacts plugin](https://github.com/StefMa/AndroidArtifacts/) the same tasks are available in this plugin
as in the AndroidArtifacts plugin. Checkout the [DEVELOPMENT.md](https://github.com/StefMa/AndroidArtifacts/blob/e90023b015f40ea0f268bd44df9280cacd7ca481/DEVELOPMENT.md) their
to see a list of available task and what they do.

Because we apply the **Artifactory plugin** the task `artifactoryPublish` will also be exposed.
The task will publish - by default - the `releaseAar` publication (generated by the **AndroidArtifacts plugin**) to the
Artifactory

## Testing
Since we test this plugin if it can successfully publish a artifact to a running instance of Artifactory you have to make sure
that there **is a running instance** of Artifactory **before** executing the tests.

You can simply use the **Artifactory docker** image:
```
docker run --name artifactory -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss:latest
```
You can also checkout the [**consumer README**](consumer/README.md) for more information.
89 changes: 29 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,46 @@

# ArtifactoryPublish

A super easy way to release Android and Java artifacts to artifactory.
A super easy way to release Android ~and Java artifacts~ to Artifactory.

## Description
This is a simple helper to simplify the configuration of the artifactory plugin.
This is a simple helper to simplify the configuration of the [Artifactory plugin](https://www.jfrog.com/confluence/display/RTF/Gradle+Artifactory+Plugin).

## How to use it
### Apply the plugin
Since the plugin is **not** available via the [Gradle Plugin Portal](https://plugins.gradle.org) you have to put these
to the **top** of your `settings.gradle`:
```groovy
pluginManagement {
repositories {
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "guru.stefma.artifactorypublish") {
useModule("guru.stefma.artifactorypublish:artifactorypublish:${requested.version}")
}
}
}
}
```

Now you are able to apply the plugin in the [`plugins` block](https://docs.gradle.org/4.5/userguide/plugins.html#sec:plugins_block):
```groovy
plugins {
// The current version can be found here https://git.io/vdsOs
id "guru.stefma.artifactorypublish" version "$artifactoryPublishVersion"
}
```

<details>
<summary>Use the old way</summary>

Put this into your **project** `build.gradle`:
```groovy
buildscript {
repositories {
jcenter()
google()
}
dependencies {
// The current version can be found here https://git.io/vdsOs
classpath "guru.stefma.artifactorypublish:artifactorypublish:$artifactoryPublishVersion"
}
}

apply plugin: "guru.stefma.artifactorypublish"
```

</details>

> **Note:** The plugin should be applied **after** the java-library or com.android.library plugin!

### Configuration
To configure the plugin:

Then you are able to apply the `guru.stefma.artifactorypublish` plugin:
```groovy
apply plugin: "com.android.library"
apply plugin: "org.jetbrains.kotlin-android" //1
apply plugin: "guru.stefma.artifactorypublish" //2

version = "1.0.0"
group = "guru.stefma.artifactorypublish"
artifactoryPublish {
groupId = "net.example"
artifactId = "artifactorypublish"
publishVersion = "0.1"
artifactoryUrl = "https://artifactory.example.com/"
artifactoryRepo = "maven-repo"
artifactId = 'artifactorypublish'
artifactoryRepo = "example-repo-local"
artifactoryUrl = "http://localhost:8081/artifactory"
}
```
* **//1:** The Kotlin plugin is optional of course. But if you add it, it will generate a KDoc together with a javadoc.
* **//2:** The **ArtifactoryPublish** plugin should always be added **after** the android library and kotlin-android plugin.

All configuration options are:
### Configuration
There are several configuration options. The following table give you a overview about all of them:

| Property | Description | Mandatory | Property finder* |
|-|-|-|-|
Expand All @@ -79,27 +52,23 @@ All configuration options are:
| artifactoryUser | Artifactory username | ✅ | ✅ |
| artifactoryKey | API Key or Password | ✅ | ✅ |

> *could be added via closure extension, terminal or property file.
> *can be added via [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html)

### Publish
To publish your library to artifactory simply run
```
./gradlew clean build artifactoryPublish -PartifactoryUser=ARTIFACTORY_USERNAME -PartifactoryKey=ARTIFACTORY_KEY
```

## Advanced
### bintray-release
This plugin depends on novoda's [bintray-release](https://github.com/novoda/bintray-release) and I trying to archive a
100% interoperability. Which mean you can use **this** plugin to use it to publish your libs to a **Artifactory** *and*
to [**Bintray**](https://bintray.com). Besides of the benefits it brings it brings also a little bit more overhead to
setup the extension for **ArtifactoryPublish**. So keep in mind to always take a look over at
[bintray-release](https://github.com/novoda/bintray-release) which properties are required for the configuration and use
these for setup the artifactoryPublish configuration as well.
## Gradle support
Unfourtaly the [AndroidArtifacts plugin](https://github.com/StefMa/AndroidArtifacts) (where we heavily depends on (see [DEVELOPMENT.md](DEVELOPMENT.md) for more)) don't have a proper Gradle support section.

But this plugin has setup [some tests](https://github.com/StefMa/ArtifactoryPublish/blob/3a7828a4f2356c95f1e12d5a791b7416282ebd49/core/src/test/kotlin/guru/stefma/artifactorypublish/ArtifactoryPublishPluginTest.kt) where it approves that the following Gradle versions are definitely supported:
* 4.5
* 4.5.1
* 4.6
* 4.7

> Current version we depend on: [**0.8.0**](https://github.com/novoda/bintray-release/tree/0.8.0)
The newst version of Gradle (currently 4.8 and 4.8.1) are **not** supported due an issue in the **Artifactory plugin**. See [this GitHub issue](https://github.com/jfrog/build-info/issues/171) fore more.

### Gradle compatibility
<!-- TODO: Don't use master here but the tag for the release -->
Since we depends heavily on `bintray-release` the [Gradle compatibility their](https://github.com/novoda/bintray-release/tree/master#gradle-compatibility)
is identical to this plugin.
`ArtifactoryPublish` don't bring other Gradle version limitations.
Feel free to report back to me if even older versions of Gradle are working for you 👍.
6 changes: 3 additions & 3 deletions consumer/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# A test project for ArtifactoryPublish
The [`jvm`](jvm/) sample contains a simple class called `JVMSample` with a
The [`android`](android/) sample contains a simple class called `AndroidSample` with a
static `helloWorld()` method.

The containing [build.gradle](jvm/build.gradle) is fully setup to publish
The containing [build.gradle](android/build.gradle) is fully setup to publish
this library to a Artifactory.

## Testing
Expand Down Expand Up @@ -40,6 +40,6 @@ repositories {
}

dependencies {
implementation "guru.stefma:jvm.sample:0.0.1"
implementation "guru.stefma.sample:android:0.0.1"
}
```
35 changes: 35 additions & 0 deletions consumer/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.library'
apply plugin: guru.stefma.artifactorypublish.ArtifactoryPublishPlugin

android {
compileSdkVersion = 26

defaultConfig {
minSdkVersion = "26"
targetSdkVersion = "26"
versionCode = 1
versionName = "1"
}

lintOptions {
abortOnError false
}
}

repositories {
jcenter()
google()
}

dependencies {
implementation "junit:junit:4.12"
}

version = "0.0.1"
group = "guru.stefma.sample"
artifactoryPublish {
artifactId = 'android'

artifactoryRepo = "example-repo-local"
artifactoryUrl = "http://localhost:8081/artifactory"
}
1 change: 1 addition & 0 deletions consumer/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="sample.android"/>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package sample;

public class JVMSample {
public class AndroidSample {

public static void helloWorld() {
System.out.println("Hello World");
Expand Down
3 changes: 2 additions & 1 deletion consumer/buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ plugins {

repositories {
jcenter()
google()
}

// We have to make sure that we are using the same dependencies as in our 'core' project
dependencies {
compile("org.jfrog.buildinfo:build-info-extractor-gradle:4.4.12") {
exclude module: "groovy-all"
}
compile "com.novoda:bintray-release:0.8.0"
compile "guru.stefma.androidartifacts:androidartifacts:1.0.0"
}

sourceSets {
Expand Down
Binary file modified consumer/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion consumer/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
22 changes: 0 additions & 22 deletions consumer/jvm/build.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion consumer/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include("jvm")
include("android")
18 changes: 11 additions & 7 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
plugins {
id "groovy"
id "java-gradle-plugin"
id "org.jetbrains.kotlin.jvm" version "1.2.21"
id "org.jetbrains.kotlin.jvm" version "1.2.50"
id "com.novoda.bintray-release" version "0.8.0"
id "org.junit.platform.gradle.plugin" version "1.0.3"
}

gradlePlugin {
Expand All @@ -15,12 +14,17 @@ gradlePlugin {
}
}

test {
useJUnitPlatform()
}

compileGroovy {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
}

repositories {
google()
jcenter()
}

Expand All @@ -31,14 +35,14 @@ dependencies {
compile("org.jfrog.buildinfo:build-info-extractor-gradle:4.4.12") {
exclude module: "groovy-all"
}
compile "com.novoda:bintray-release:0.8.0"
compile "guru.stefma.androidartifacts:androidartifacts:1.0.0"

testCompile "org.jetbrains.kotlin:kotlin-stdlib"
testCompile "org.junit.jupiter:junit-jupiter-api:5.0.3"
testCompile "org.junit.jupiter:junit-jupiter-params:5.0.3"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.0.3"
testCompile "org.junit.jupiter:junit-jupiter-api:5.2.0"
testCompile "org.junit.jupiter:junit-jupiter-params:5.2.0"
testRuntime "org.junit.jupiter:junit-jupiter-engine:5.2.0"
testCompile "org.assertj:assertj-core:3.9.0"
testCompile "com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-alpha02"
testCompile "com.nhaarman.mockitokotlin2:mockito-kotlin:2.0.0-RC1"
}

publish {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class ArtifactoryPublishConfiguration {
void configure(Project project) {
ArtifactoryPublishPropertyFinder propertyFinder = new ArtifactoryPublishPropertyFinder(project, mExtension)

def publication = mExtension.publications ?: project.plugins.hasPlugin('com.android.library') ? ['release'].toArray() : ['maven'].toArray()
project.logger.debug("Set publication to : " + publication)

project.artifactory {
contextUrl = mExtension.artifactoryUrl
publish {
Expand All @@ -25,7 +22,8 @@ class ArtifactoryPublishConfiguration {
password = propertyFinder.artifactoryKey
}
defaults {
publications publication
// Currently we only support the `release` publication
publications ('releaseAar')
publishArtifacts = true
publishPom = true
}
Expand Down
Loading