Skip to content

Commit b7e2f3e

Browse files
authored
Merge pull request #3566 from square/bquenaudon.2026-04-14.sourceReleaseJar
Test confirming we don't duplicate sources in jar creation anymore
2 parents fb8eefc + 8ec1f74 commit b7e2f3e

5 files changed

Lines changed: 83 additions & 2 deletions

File tree

wire-gradle-plugin/src/main/kotlin/com/squareup/wire/gradle/kotlin/SourceRoots.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ private class AndroidSource(
185185
}
186186
is KotlinTarget -> {
187187
variant.sources.kotlin?.addGeneratedSourceDirectory(wireTask) { it.outputDirectoriesList[index] }
188-
// Remove line below when AGP is upgraded to 9.0+ as it will contain fix for https://issuetracker.google.com/446220448
189-
variant.sources.java?.addGeneratedSourceDirectory(wireTask) { it.outputDirectoriesList[index] }
190188
}
191189
is CustomTarget -> {
192190
// Custom targets are wildcards, so we add all output directories.

wire-gradle-plugin/src/test/kotlin/com/squareup/wire/gradle/WirePluginTest.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,22 @@ class WirePluginTest {
13781378
}
13791379
}
13801380

1381+
/** Regression test for https://github.com/square/wire/issues/3558 */
1382+
@Test
1383+
fun androidKotlinSourceReleaseJarNoDuplicates() {
1384+
val fixtureRoot = File("src/test/projects/android-kotlin-source-release-jar")
1385+
1386+
val localProperties = File(fixtureRoot, "local.properties")
1387+
if (!localProperties.exists()) {
1388+
val androidHome = System.getenv("ANDROID_HOME")
1389+
?: "${System.getProperty("user.home")}/Library/Android/sdk"
1390+
localProperties.writeText("sdk.dir=$androidHome\n")
1391+
}
1392+
1393+
val result = fixtureGradleRunner(fixtureRoot, "sourceReleaseJar", "--no-build-cache").build()
1394+
assertThat(result.task(":sourceReleaseJar")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
1395+
}
1396+
13811397
@Test
13821398
fun taskDependency() {
13831399
val fixtureRoot = File("src/test/projects/task-dependency")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def wireVersion = gradle.startParameter.projectProperties.get('wireVersion')
2+
3+
buildscript {
4+
repositories {
5+
maven {
6+
url new File(rootDir, "../../../../../build/localMaven").toURI().toString()
7+
}
8+
google()
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
classpath("com.squareup.wire:wire-gradle-plugin:${wireVersion}")
14+
classpath("com.android.tools.build:gradle:8.13.2")
15+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21")
16+
}
17+
}
18+
19+
apply plugin: 'com.android.library'
20+
apply plugin: 'org.jetbrains.kotlin.android'
21+
apply plugin: 'com.squareup.wire'
22+
apply plugin: 'maven-publish'
23+
24+
android {
25+
namespace = "com.example.producer"
26+
compileSdk = 36
27+
28+
publishing {
29+
singleVariant('release') {
30+
withSourcesJar()
31+
}
32+
}
33+
}
34+
35+
wire {
36+
kotlin {}
37+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
repositories {
3+
maven {
4+
url new File(rootDir, "../../../../../build/localMaven").toURI().toString()
5+
}
6+
google()
7+
mavenCentral()
8+
}
9+
}
10+
11+
dependencyResolutionManagement {
12+
repositories {
13+
google {
14+
mavenContent {
15+
includeGroupAndSubgroups("androidx")
16+
includeGroupAndSubgroups("com.android")
17+
includeGroupAndSubgroups("com.google")
18+
}
19+
}
20+
mavenCentral()
21+
}
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
syntax = "proto2";
2+
3+
package squareup.geology;
4+
5+
enum Period {
6+
JURASSIC = 1;
7+
CRETACEOUS = 2;
8+
}

0 commit comments

Comments
 (0)