Skip to content
This repository was archived by the owner on Jan 25, 2021. It is now read-only.

Commit a553dc6

Browse files
committed
using manual classpath injection to be able to apply android plugin first
1 parent aa28878 commit a553dc6

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ sourceSets {
3434
}
3535
}
3636

37+
// Write the plugin's classpath to a file to share with the tests
38+
task createClasspathManifest {
39+
def outputDir = file("$buildDir/$name")
40+
41+
inputs.files sourceSets.main.runtimeClasspath
42+
outputs.dir outputDir
43+
44+
doLast {
45+
outputDir.mkdirs()
46+
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
47+
}
48+
}
49+
3750
dependencies {
3851
jacocoRuntime "org.jacoco:org.jacoco.agent:${jacoco.toolVersion}:runtime"
3952

@@ -80,6 +93,8 @@ dependencies {
8093
dependency 'org.sonatype.aether:aether-connector-wagon:1.13.1@jar'
8194
}
8295

96+
testRuntime files(createClasspathManifest)
97+
8398
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
8499
exclude module: 'groovy-all'
85100
}

src/test/groovy/org/gradle/api/plugins/AndroidMavenPluginIT.groovy

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class AndroidMavenPluginIT extends Specification {
1818
@Shared def buildDir = "${System.properties['buildDir']}"
1919

2020
@Rule final TemporaryFolder testProjectDir = new TemporaryFolder()
21+
List<File> pluginClasspath
2122

2223
File androidManifest
2324
File settingsFile
@@ -32,6 +33,13 @@ class AndroidMavenPluginIT extends Specification {
3233
settingsFile = testProjectDir.newFile('settings.gradle')
3334
gradlePropertiesFile = testProjectDir.newFile('gradle.properties')
3435
buildFile = testProjectDir.newFile('build.gradle')
36+
37+
def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt")
38+
if (pluginClasspathResource == null) {
39+
throw new IllegalStateException("Did not find plugin classpath resource, run `testClasses` build task.")
40+
}
41+
42+
pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) }
3543
}
3644

3745
@Unroll
@@ -47,6 +55,11 @@ class AndroidMavenPluginIT extends Specification {
4755

4856
gradlePropertiesFile << "org.gradle.jvmargs=-javaagent:${jacocoRuntime}=destfile=${buildDir}/jacoco/testKit-${gradleVersion}.exec"
4957

58+
def classpathString = pluginClasspath
59+
.collect { it.absolutePath.replace('\\', '/') }
60+
.collect { "'$it'" }
61+
.join(", ")
62+
5063
def uri = testProjectDir.root.toURI()
5164
buildFile << """
5265
buildscript {
@@ -60,14 +73,12 @@ class AndroidMavenPluginIT extends Specification {
6073
6174
dependencies {
6275
classpath "com.android.tools.build:gradle:${androidGradleBuildVersion}"
76+
classpath files(${classpathString})
6377
}
6478
}
6579
66-
plugins {
67-
id "com.github.dcendents.android-maven"
68-
}
69-
7080
apply plugin: 'com.android.library'
81+
apply plugin: 'com.github.dcendents.android-maven'
7182
7283
group = 'org.test'
7384
version = '1.0'

0 commit comments

Comments
 (0)