Skip to content

Commit 5112f91

Browse files
committed
Init commit
0 parents  commit 5112f91

15 files changed

+475
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
core/build
3+
.gradle/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Stefan M.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ArtifactoryPublish
2+
3+
A super easy way to release Android and Java artifacts to artifactory.
4+
5+
## Description
6+
This is a simple helper to simplify the configuration of the artifactory plugin.
7+
8+
## How to use it
9+
You can use it as a standalone plugin in the following way:
10+
Put these lines into your **project** `build.gradle`
11+
```groovy
12+
buildscript {
13+
repositories {
14+
jcenter()
15+
}
16+
dependencies {
17+
classpath 'guru.stefma.artifactorypublish:artifactorypublish:0.0.1'
18+
}
19+
}
20+
```
21+
22+
Then put these into your **module** `build.gradle`:
23+
```groovy
24+
apply plugin: 'guru.stefma.artifactorypublish' // Add this after your android or java plugin!
25+
26+
artifactoryPublish {
27+
groupId = 'net.example'
28+
artifactId = 'artifactorypublish'
29+
publishVersion = "0.1"
30+
artifactoryUrl = "https://artifactory.example.com/"
31+
artifactoryRepo = "maven-repo"
32+
}
33+
```

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath 'com.novoda:bintray-release:0.5.0'
7+
}
8+
}
9+
10+
allprojects {
11+
repositories {
12+
jcenter()
13+
}
14+
version = '0.0.1-SNAPSHOT'
15+
}

core/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apply plugin: 'com.novoda.bintray-release'
2+
apply plugin: 'groovy'
3+
apply plugin: 'java'
4+
5+
compileGroovy {
6+
sourceCompatibility = '1.6'
7+
targetCompatibility = '1.6'
8+
}
9+
10+
dependencies {
11+
compile gradleApi()
12+
compile localGroovy()
13+
compile ('org.jfrog.buildinfo:build-info-extractor-gradle:4.4.17') {
14+
exclude module: 'groovy-all'
15+
}
16+
compile 'guru.stefma.androidartifacts:androidartifacts:0.0.1'
17+
}
18+
19+
publish {
20+
userOrg = 'stefma'
21+
groupId = 'guru.stefma.artifactorypublish'
22+
artifactId = rootProject.name
23+
uploadName = 'ArtifactoryPublish'
24+
version = project.version
25+
description = 'Super duper easy way to release your Android and other artifacts to artifactory'
26+
website = "https://github.com/StefMa/ArtifactoryPublish"
27+
licences = ['MIT']
28+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package guru.stefma.artifactorypublish
2+
3+
import org.gradle.api.Project
4+
5+
class ArtifactoryPublishConfiguration {
6+
7+
ArtifactoryPublishExtension mExtension
8+
9+
ArtifactoryPublishConfiguration(ArtifactoryPublishExtension extension) {
10+
mExtension = extension
11+
}
12+
13+
void configure(Project project) {
14+
ArtifactoryPublishPropertyFinder propertyFinder = new ArtifactoryPublishPropertyFinder(project, mExtension)
15+
16+
def publication = mExtension.publications ?: project.plugins.hasPlugin('com.android.library') ? ['release'].toArray() : ['maven'].toArray()
17+
project.logger.debug("Set publication to : " + publication)
18+
19+
project.artifactory {
20+
contextUrl = mExtension.artifactoryUrl
21+
publish {
22+
repository {
23+
repoKey = mExtension.artifactoryRepo
24+
username = propertyFinder.artifactoryUser
25+
password = propertyFinder.artifactoryKey
26+
}
27+
defaults {
28+
publications publication
29+
publishArtifacts = true
30+
publishPom = true
31+
}
32+
}
33+
}
34+
}
35+
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package guru.stefma.artifactorypublish
2+
3+
import guru.stefma.androidartifacts.ArtifactsExtension
4+
5+
class ArtifactoryPublishExtension extends ArtifactsExtension {
6+
7+
String artifactoryUrl = ""
8+
9+
String artifactoryRepo = ""
10+
11+
String artifactoryUser
12+
13+
String artifactoryKey
14+
15+
String[] publications
16+
17+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package guru.stefma.artifactorypublish
2+
3+
import guru.stefma.androidartifacts.AndroidArtifactsPlugin
4+
import guru.stefma.androidartifacts.ArtifactsExtension
5+
import org.gradle.api.Project
6+
import org.jfrog.gradle.plugin.artifactory.ArtifactoryPlugin
7+
8+
class ArtifactoryPublishPlugin extends AndroidArtifactsPlugin {
9+
10+
ArtifactoryPublishExtension mPublishExtension
11+
12+
@Override
13+
void apply(Project project) {
14+
super.apply(project)
15+
16+
new ArtifactoryPlugin().apply(project)
17+
project.afterEvaluate {
18+
project.apply([plugin: 'com.jfrog.artifactory'])
19+
new ArtifactoryPublishConfiguration(mPublishExtension).configure(project)
20+
}
21+
}
22+
23+
@Override
24+
ArtifactsExtension getArtifactsExtensions(Project project) {
25+
mPublishExtension = project.extensions.create('artifactoryPublish', ArtifactoryPublishExtension)
26+
return mPublishExtension
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package guru.stefma.artifactorypublish
2+
3+
import org.gradle.api.Project
4+
5+
class ArtifactoryPublishPropertyFinder {
6+
7+
private final Project mProject
8+
9+
private final ArtifactoryPublishExtension mExtension
10+
11+
ArtifactoryPublishPropertyFinder(Project project, ArtifactoryPublishExtension extension) {
12+
mProject = project
13+
mExtension = extension
14+
}
15+
16+
def getArtifactoryUser() {
17+
getString(mProject, 'artifactoryUser', mExtension.artifactoryUser)
18+
}
19+
20+
def getArtifactoryKey() {
21+
getString(mProject, 'artifactoryKey', mExtension.artifactoryKey)
22+
}
23+
24+
private static String getString(Project project, String propertyName, String defaultValue) {
25+
project.hasProperty(propertyName) ? project.getProperty(propertyName) : defaultValue
26+
}
27+
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
implementation-class=guru.stefma.artifactorypublish.ArtifactoryPublishPlugin

0 commit comments

Comments
 (0)