Skip to content

Commit 3ccd1c5

Browse files
committed
Add publisher test.
1 parent cb4fb1f commit 3ccd1c5

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/PublishingPluginTests.kt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,49 @@ licenses {
7878
scope = "compile")))
7979
}
8080

81+
@Test
82+
fun `Publishing dependent projects one of which is a jar succeeds`() {
83+
val project1 = Project(name = "childProject1", version = "1.0", libraryType = LibraryType.JAVA)
84+
val project2 = Project(
85+
name = "childProject2",
86+
version = "0.9",
87+
projectDependencies = setOf(project1),
88+
customizePom = """
89+
licenses {
90+
license {
91+
name = 'Hello'
92+
}
93+
}
94+
""")
95+
subprojectsDefined(project1, project2)
96+
val result = publish(Mode.RELEASE, project1, project2)
97+
assertThat(result.task(":firebasePublish")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
98+
99+
val pomOrNull1 = project1.getPublishedPom("${testProjectDir.root}/build/m2repository")
100+
val pomOrNull2 = project2.getPublishedPom("${testProjectDir.root}/build/m2repository")
101+
assertThat(pomOrNull1).isNotNull()
102+
assertThat(pomOrNull2).isNotNull()
103+
val pom1 = pomOrNull1!!
104+
val pom2 = pomOrNull2!!
105+
106+
assertThat(pom1.artifact.version).isEqualTo(project1.version)
107+
assertThat(pom2.artifact.version).isEqualTo(project2.version)
108+
assertThat(pom1.license).isEqualTo(License(
109+
"The Apache Software License, Version 2.0",
110+
"http://www.apache.org/licenses/LICENSE-2.0.txt"))
111+
assertThat(pom2.license).isEqualTo(License(
112+
"Hello",
113+
""))
114+
115+
assertThat(pom2.dependencies).isEqualTo(
116+
listOf(Artifact(
117+
groupId = project1.group,
118+
artifactId = project1.name,
119+
version = project1.version,
120+
type = Type.JAR,
121+
scope = "compile")))
122+
}
123+
81124
@Test
82125
fun `Publish with unreleased dependency`() {
83126
val project1 = Project(name = "childProject1", version = "1.0")

buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/publishing.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ data class Project(
2828
val projectDependencies: Set<Project> = setOf(),
2929
val externalDependencies: Set<Artifact> = setOf(),
3030
val releaseWith: Project? = null,
31-
val customizePom: String? = null
31+
val customizePom: String? = null,
32+
val libraryType: LibraryType = LibraryType.ANDROID
3233
) {
3334
fun generateBuildFile(): String {
3435
return """
3536
plugins {
36-
id 'firebase-library'
37+
id 'firebase-${if (libraryType == LibraryType.JAVA) "java-" else ""}library'
3738
}
3839
group = '$group'
3940
version = '$version'
@@ -42,7 +43,7 @@ data class Project(
4243
${if (releaseWith != null) "releaseWith project(':${releaseWith.name}')" else ""}
4344
${if (customizePom != null) "customizePom {$customizePom}" else ""}
4445
}
45-
android.compileSdkVersion = 26
46+
${if (libraryType == LibraryType.ANDROID) "android.compileSdkVersion = 26" else ""}
4647
4748
repositories {
4849
google()

0 commit comments

Comments
 (0)