Skip to content

Commit d25e28d

Browse files
authored
Merge pull request #79 from ToxicBakery/feature/ci
Migration to circle
2 parents e31520f + 415e563 commit d25e28d

7 files changed

Lines changed: 169 additions & 109 deletions

File tree

.circleci/config.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
defaults: &defaults
2+
working_directory: ~/repo
3+
docker:
4+
- image: toxicbakery/alpine-glibc-android:release-1.2.0
5+
environment:
6+
TERM: dumb
7+
8+
version: 2
9+
jobs:
10+
build:
11+
<<: *defaults
12+
steps:
13+
- checkout
14+
- run:
15+
name: Execute Gradle
16+
command: |
17+
echo "org.gradle.parallel=false" >> gradle.properties
18+
echo "kotlin.incremental=false" >> gradle.properties
19+
./gradlew build --no-daemon -PdisablePreDex
20+
bash <(curl -s https://codecov.io/bash)
21+
if [ "master" = "$CIRCLE_BRANCH" ] || [ ! -z "$CIRCLE_TAG" ]; then
22+
echo "signing.keyId=${SIGNING_KEY}" >> "gradle.properties"
23+
echo "signing.password=${SIGNING_PASSWORD}" >> "gradle.properties"
24+
echo "signing.secretKeyRingFile=../maven.keystore" >> "gradle.properties"
25+
gpg --cipher-algo AES256 --yes --batch --passphrase=$ENC_FILE_KEY maven.keystore.gpg
26+
./gradlew uploadArchives --no-daemon -PdisablePreDex
27+
fi
28+
workflows:
29+
version: 2
30+
build:
31+
jobs:
32+
- build:
33+
context: Sonatype
34+
filters:
35+
tags:
36+
only: /.*/
37+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/ToxicBakery/ViewPagerTransforms.svg)](https://travis-ci.org/ToxicBakery/ViewPagerTransforms)
1+
[![CircleCI](https://circleci.com/gh/ToxicBakery/ViewPagerTransforms.svg?style=svg)](https://circleci.com/gh/ToxicBakery/ViewPagerTransforms)
22

33
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-ViewPagerTransforms-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1193)
44

build.gradle

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,33 @@
1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818

1919
buildscript {
20+
ext.kotlin_version = '1.2.51'
2021
repositories {
21-
jcenter()
2222
google()
23+
jcenter()
2324
}
2425
dependencies {
25-
classpath 'com.android.tools.build:gradle:3.1.0'
26-
27-
// NOTE: Do not place your application dependencies here; they belong
28-
// in the individual module build.gradle files
26+
classpath 'com.android.tools.build:gradle:3.1.3'
27+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
28+
classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.16"
2929
}
3030
}
3131

32+
task clean(type: Delete) {
33+
delete rootProject.buildDir
34+
}
35+
3236
allprojects {
37+
String tagName = System.getenv('CIRCLE_TAG')
38+
boolean isTag = tagName != null && !tagName.isEmpty()
39+
String buildNumber = System.getenv('CIRCLE_BUILD_NUM') ?: "0"
40+
41+
group 'com.ToxicBakery.viewpager.transforms'
42+
version "1.3.${buildNumber}" + (isTag ? "" : "-SNAPSHOT")
43+
3344
repositories {
3445
jcenter()
3546
google()
3647
}
3748
}
3849

39-
def isReleaseBuild() {
40-
return isTag() && !isSnapshot()
41-
}
42-
43-
def isSnapshot() {
44-
return version.contains("SNAPSHOT")
45-
}
46-
47-
boolean isTravis() {
48-
return System.getenv('TRAVIS_BUILD_NUMBER') ? true : false
49-
}
50-
51-
boolean isTag() {
52-
def tag = System.getenv('TRAVIS_TAG')
53-
return !(tag == null || tag.isEmpty())
54-
}
55-
56-
def buildNumber() {
57-
return System.getenv('TRAVIS_BUILD_NUMBER') ?: "0"
58-
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
# limitations under the License.
1515
#
1616

17-
VERSION_NAME = 1.2.0
18-
VERSION_CODE = 1
19-
GROUP = com.ToxicBakery.viewpager.transforms
17+
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
2018

2119
POM_NAME=ViewPagerTransforms
2220
POM_ARTIFACT_ID=view-pager-transforms

library/build.gradle

Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,36 @@
1515
*/
1616

1717
apply plugin: 'com.android.library'
18-
apply plugin: 'signing'
18+
apply plugin: 'kotlin-android'
19+
apply plugin: 'org.jetbrains.dokka-android'
20+
apply plugin: 'jacoco'
1921

20-
String getVersionString() {
21-
String v = VERSION_NAME.replaceAll(".(0)\$", "." + buildNumber())
22-
v = isTag() ? v : v + "-SNAPSHOT"
23-
return v
22+
jacoco {
23+
toolVersion = '0.8.0'
2424
}
2525

26-
group = GROUP
27-
version = getVersionString()
28-
26+
tasks.withType(Test) {
27+
jacoco.includeNoLocationClasses = true
28+
}
2929

30-
if (isReleaseBuild()) {
31-
status = 'release'
32-
} else {
33-
status = 'integration'
30+
repositories {
31+
google()
32+
jcenter()
33+
mavenCentral()
3434
}
3535

3636
android {
3737
compileSdkVersion 27
38-
buildToolsVersion "27.0.3"
39-
38+
buildToolsVersion = "27.0.3"
4039
defaultConfig {
4140
minSdkVersion 14
4241
targetSdkVersion 27
43-
versionCode 1
44-
versionName "1.0"
45-
}
46-
47-
compileOptions {
48-
sourceCompatibility JavaVersion.VERSION_1_7
49-
targetCompatibility JavaVersion.VERSION_1_7
42+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
5043
}
5144
buildTypes {
45+
debug {
46+
testCoverageEnabled true
47+
}
5248
release {
5349
minifyEnabled false
5450
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -60,4 +56,81 @@ dependencies {
6056
implementation 'com.android.support:support-v13:27.1.1'
6157
}
6258

63-
apply from: '../maven_push.gradle'
59+
dokka {
60+
noStdlibLink = false
61+
includeNonPublic = false
62+
skipEmptyPackages = true
63+
outputFormat = 'html'
64+
outputDirectory = "$buildDir/javadoc"
65+
}
66+
67+
afterEvaluate { project ->
68+
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaAndroidTask) {
69+
outputFormat = 'javadoc'
70+
outputDirectory = "$buildDir/javadoc"
71+
inputs.dir 'src/main/java'
72+
}
73+
74+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
75+
classifier = 'javadoc'
76+
from "$buildDir/javadoc"
77+
}
78+
79+
task sourcesJar(type: Jar) {
80+
classifier = 'sources'
81+
from android.sourceSets.main.java.srcDirs
82+
}
83+
84+
artifacts {
85+
archives sourcesJar
86+
archives javadocJar
87+
}
88+
}
89+
90+
task jacocoUnitTestReport(type: JacocoReport, group: 'verification', dependsOn: ['testDebugUnitTest']) {
91+
reports {
92+
xml.enabled = true
93+
html.enabled = true
94+
}
95+
96+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
97+
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
98+
def mainSrc = "$project.projectDir/src/main/java"
99+
100+
sourceDirectories = files([mainSrc])
101+
classDirectories = files([debugTree])
102+
executionData = fileTree(dir: project.buildDir, includes: [
103+
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
104+
])
105+
}
106+
107+
task jacocoFullTestReport(type: JacocoReport, group: 'verification', dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
108+
reports {
109+
xml.enabled = true
110+
html.enabled = true
111+
}
112+
113+
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
114+
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
115+
def mainSrc = "$project.projectDir/src/main/java"
116+
117+
sourceDirectories = files([mainSrc])
118+
classDirectories = files([debugTree])
119+
executionData = fileTree(dir: project.buildDir, includes: [
120+
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
121+
])
122+
}
123+
124+
task copyAndroidCoverage(type: Copy) {
125+
/*afterEvaluate {
126+
dependsOn jacocoFullTestReport
127+
}*/
128+
from 'build/reports/jacoco/jacocoFullTestReport/jacocoFullTestReport.xml'
129+
into './'
130+
rename { String fileName ->
131+
fileName = "integration.xml"
132+
}
133+
}
134+
135+
apply from: "${rootDir}/publish.gradle"
136+
Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,31 @@
1-
/*
2-
* Copyright 2014 Toxic Bakery
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
apply plugin: 'maven'
182
apply plugin: 'signing'
193

20-
if (isReleaseBuild()) {
21-
println 'RELEASE BUILD'
22-
} else {
23-
println 'DEBUG BUILD'
24-
}
4+
static String getTagName() { return System.getenv('CIRCLE_TAG') ?: "" }
255

26-
def getRepositoryUsername() {
27-
return System.getenv('sonatype_user') ?: hasProperty('sonatype_user') ? sonatype_user : ""
28-
}
6+
boolean isSnapshot() { return version.contains("SNAPSHOT") }
297

30-
def getRepositoryPassword() {
31-
return System.getenv('sonatype_pass') ?: hasProperty('sonatype_pass') ? sonatype_pass : ""
32-
}
8+
static boolean isTag() { return !getTagName().isEmpty() }
339

34-
String getBranchName() {
35-
return System.getenv('TRAVIS_BRANCH')
36-
}
10+
static boolean isCircle() { return System.getenv('CIRCLECI') ? true : false }
11+
12+
static String getRepositoryUsername() { return System.getenv('SONATYPE_USERNAME') ?: "" }
13+
14+
static String getRepositoryPassword() { return System.getenv('SONATYPE_PASSWORD') ?: "" }
15+
16+
static String getBranchName() { return System.getenv('CIRCLE_BRANCH') }
17+
18+
boolean isRelease() { return isTag() && !isSnapshot() }
3719

3820
afterEvaluate { project ->
3921

40-
println "Is Tag ${isTag()}"
22+
println "Tag ${getTagName()}"
4123
println "Branch ${getBranchName()}"
42-
println "Is Release ${isReleaseBuild()}"
43-
println "Is Travis ${isTravis()}"
24+
println "Is Release ${isRelease()}"
25+
println "Is Circle ${isCircle()}"
4426
println "Has Username ${!getRepositoryUsername().empty}"
4527
println "Has Password ${!getRepositoryPassword().empty}"
46-
println "Determined Version ${version}"
28+
println "Version ${version}"
4729

4830
uploadArchives {
4931
repositories {
@@ -56,7 +38,7 @@ afterEvaluate { project ->
5638
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
5739
}
5840

59-
snapshotRepository(url: isTravis() ? "https://oss.sonatype.org/content/repositories/snapshots" : mavenLocal().url) {
41+
snapshotRepository(url: isCircle() ? "https://oss.sonatype.org/content/repositories/snapshots" : mavenLocal().url) {
6042
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
6143
}
6244

@@ -95,29 +77,8 @@ afterEvaluate { project ->
9577
}
9678

9779
signing {
98-
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
80+
required false
9981
sign configurations.archives
10082
}
10183

102-
task androidJavadocs(type: Javadoc) {
103-
source = android.sourceSets.main.java.sourceFiles
104-
}
105-
106-
task androidJavadocsJar(type: Jar) {
107-
classifier = 'javadoc'
108-
//basename = artifact_id
109-
from androidJavadocs.destinationDir
110-
}
111-
112-
task androidSourcesJar(type: Jar) {
113-
classifier = 'sources'
114-
//basename = artifact_id
115-
from android.sourceSets.main.java.sourceFiles
116-
}
117-
118-
artifacts {
119-
//archives packageReleaseJar
120-
archives androidSourcesJar
121-
archives androidJavadocsJar
122-
}
123-
}
84+
}

0 commit comments

Comments
 (0)