This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from hzsweers/z/fix_and_test
Fix for gradle plugin 1.3.0+ and some basic configuration testing
- Loading branch information
Showing
14 changed files
with
229 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.3.1' | ||
classpath 'com.novoda:bintray-release:0.3.0' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
version = "0.3.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
core/src/test/fixtures/android_app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.novoda.gradle.release.test"> | ||
|
||
<!-- This needs to be an empty element as workaround for https://code.google.com/p/android/issues/detail?id=77890 --> | ||
|
||
</manifest> |
14 changes: 14 additions & 0 deletions
14
...c/test/fixtures/android_app/src/main/java/com/novoda/gradle/release/test/SampleClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.novoda.gradle.release.test; | ||
|
||
public class SampleClass { | ||
|
||
/** | ||
* This is a main function, because reasons. | ||
* | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
System.out.println("Hello world!"); | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
core/src/test/groovy/com/novoda/gradle/release/TestBintrayRelease.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.novoda.gradle.release | ||
import com.jfrog.bintray.gradle.BintrayUploadTask | ||
import org.gradle.api.Project | ||
import org.gradle.api.Task | ||
import org.gradle.api.publish.maven.tasks.GenerateMavenPom | ||
import org.junit.AfterClass | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
|
||
import static com.google.common.truth.Truth.assertThat | ||
|
||
class TestBintrayRelease { | ||
|
||
// This is necessary because the IDE debugger and command line invocations have different working directories ಠ_ಠ | ||
private static final WORKING_DIR = System.getProperty("user.dir") | ||
private static final PATH_PREFIX = WORKING_DIR.endsWith("core") ? WORKING_DIR : "$WORKING_DIR/core" | ||
|
||
static final String FIXTURE_WORKING_DIR = "$PATH_PREFIX/src/test/fixtures/android_app" | ||
|
||
@BeforeClass | ||
static void setup() { | ||
} | ||
|
||
@AfterClass | ||
static void tearDown() { | ||
// I don't know why this gets generated, but toss it | ||
new File("${FIXTURE_WORKING_DIR}/userHome").deleteDir() | ||
new File("${FIXTURE_WORKING_DIR}/.gradle").deleteDir() | ||
} | ||
|
||
@Test | ||
public void testConfiguration() { | ||
Project project = TestHelper.evaluatableLibProject() | ||
ReleasePlugin plugin = new ReleasePlugin() | ||
plugin.apply(project) | ||
project.publish { | ||
userOrg = 'novoda' | ||
groupId = 'com.example.novoda' | ||
artifactId = "test" | ||
version = project.version | ||
description = 'Super duper easy way to release your Android and other artifacts to bintray' | ||
website = "https://github.com/novoda/bintray-release" | ||
dryRun = true | ||
} | ||
project.evaluate() | ||
|
||
Task task1 = project.getTasks().findByPath(":bintrayUpload") | ||
assertThat(task1).isNotNull() | ||
Task task2 = project.getTasks().findByPath(":generatePomFileForMavenPublication") | ||
assertThat(task2).isNotNull() | ||
|
||
// Now assert some other stuff about the tasks | ||
BintrayUploadTask uploadTask = task1 as BintrayUploadTask | ||
|
||
GenerateMavenPom generatePomTask = task2 as GenerateMavenPom | ||
generatePomTask.execute() | ||
File pomFile = new File(project.buildDir, "/publications/maven/pom-default.xml") | ||
assertThat(pomFile.exists()) | ||
NodeList nodes = new XmlParser().parse(pomFile).depthFirst() | ||
assertThat(nodes).isNotNull() | ||
assertThat(nodes).hasSize 6 | ||
|
||
// Skip the first two since they're boilerplate xml stuff | ||
Node groupIdNode = nodes[2] | ||
assertThat(groupIdNode.name().localPart).isEqualTo "groupId" | ||
assertThat(groupIdNode.value()[0]).isEqualTo "com.example.novoda" | ||
Node artifactIdNode = nodes[3] | ||
assertThat(artifactIdNode.name().localPart).isEqualTo "artifactId" | ||
assertThat(artifactIdNode.value()[0]).isEqualTo "test" | ||
Node versionNode = nodes[4] | ||
assertThat(versionNode.name().localPart).isEqualTo "version" | ||
assertThat(versionNode.value()[0]).isEqualTo "1.0" | ||
Node packagingNode = nodes[5] | ||
assertThat(packagingNode.name().localPart).isEqualTo "packaging" | ||
assertThat(packagingNode.value()[0]).isEqualTo "aar" | ||
|
||
// uploadTask verification here | ||
|
||
project.buildDir.deleteDir() | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
core/src/test/groovy/com/novoda/gradle/release/TestHelper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.novoda.gradle.release | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.testfixtures.ProjectBuilder | ||
|
||
final class TestHelper { | ||
|
||
public static Project evaluatableLibProject() { | ||
Project project = ProjectBuilder.builder().withProjectDir(new File(TestBintrayRelease.FIXTURE_WORKING_DIR)).build() | ||
project.apply plugin: 'com.android.library' | ||
project.version = "1.0" | ||
project.group = "com.example.novoda.gradle.release" | ||
project.android { | ||
compileSdkVersion 23 | ||
buildToolsVersion '23.0.0' | ||
|
||
defaultConfig { | ||
versionCode 1 | ||
versionName '1.0' | ||
minSdkVersion 23 | ||
targetSdkVersion 23 | ||
} | ||
|
||
buildTypes { | ||
release { | ||
signingConfig signingConfigs.debug | ||
} | ||
} | ||
} | ||
|
||
return project | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:23.0.0' | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
testCompile 'junit:junit:4.12' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/hsweers/dev/android/android-sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
sample/src/androidTest/java/com/novoda/gradle/release/sample/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.novoda.gradle.release.sample; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.novoda.gradle.release.sample"> | ||
|
||
<application android:allowBackup="true" android:label="@string/app_name"> | ||
|
||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">BintrayReleaseSample</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
include ':core', ':sample' | ||
rootProject.name = 'bintray-release' | ||
include 'core' |