From 6d4f65a1941bf5ee54ef899d6f2ada781ad24c0b Mon Sep 17 00:00:00 2001 From: Gabriel Ittner Date: Mon, 26 Dec 2022 13:42:34 +0100 Subject: [PATCH] run all tests also with the base plugin (#477) * run all tests also with the base plugin * add missing basePluginConfig values --- .github/workflows/build.yml | 2 +- CHANGELOG.md | 1 + .../common/expected/test-artifact-1.0.0.pom | 36 ---- .../fixtures/common/gradle.properties | 31 ---- .../fixtures/common/maven-publish.gradle | 8 - .../fixtures/common/settings.gradle | 15 -- .../fixtures/common/test-secring.gpg | Bin 4944 -> 0 bytes .../build.gradle | 33 ---- .../expected/test-artifact-1.0.0.pom | 37 ---- .../settings.gradle | 9 - .../src/main/AndroidManifest.xml | 1 - .../maven/publish/test/TestActivity.java | 18 -- .../build.gradle | 33 ---- .../expected/test-artifact-1.0.0.pom | 37 ---- .../settings.gradle | 9 - .../src/main/AndroidManifest.xml | 1 - .../maven/publish/test/TestActivity.java | 18 -- .../MavenPublishPluginIntegrationTest.kt | 158 ------------------ .../publish/MavenPublishPluginPlatformTest.kt | 35 ++++ .../vanniktech/maven/publish/ProjectSpec.kt | 1 + .../maven/publish/ProjectSpecRunner.kt | 32 ++-- .../vanniktech/maven/publish/ProjectSpecs.kt | 19 ++- .../com/vanniktech/maven/publish/Subjects.kt | 10 +- .../vanniktech/maven/publish/TestOptions.kt | 1 + .../com/vanniktech/maven/publish/Platform.kt | 10 +- 25 files changed, 87 insertions(+), 468 deletions(-) delete mode 100644 plugin/src/integrationTest/fixtures/common/expected/test-artifact-1.0.0.pom delete mode 100644 plugin/src/integrationTest/fixtures/common/gradle.properties delete mode 100644 plugin/src/integrationTest/fixtures/common/maven-publish.gradle delete mode 100644 plugin/src/integrationTest/fixtures/common/settings.gradle delete mode 100644 plugin/src/integrationTest/fixtures/common/test-secring.gpg delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/build.gradle delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/expected/test-artifact-1.0.0.pom delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/settings.gradle delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/AndroidManifest.xml delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_single_variant_project/build.gradle delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_single_variant_project/expected/test-artifact-1.0.0.pom delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_single_variant_project/settings.gradle delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/AndroidManifest.xml delete mode 100644 plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java delete mode 100644 plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93d73598..3ac6f6dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: java_version: [11, 17] - test_config_method: ["DSL", "PROPERTIES"] + test_config_method: ["DSL", "PROPERTIES", "BASE"] steps: - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc3248a..909c3308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Updated docs can be found on [the new website](https://vanniktech.github.io/grad please use the new `coordinates` method instead. - The `GROUP` and `VERSION_NAME` Gradle properties will not be explicitly set as `project.group` and `project.version` anymore. +- Fix publishing Kotlin/JS project with the base plugin. - The minimum supported Gradle version has been increased to 7.3. Version 0.22.0 *(2022-09-09)* diff --git a/plugin/src/integrationTest/fixtures/common/expected/test-artifact-1.0.0.pom b/plugin/src/integrationTest/fixtures/common/expected/test-artifact-1.0.0.pom deleted file mode 100644 index 504cd663..00000000 --- a/plugin/src/integrationTest/fixtures/common/expected/test-artifact-1.0.0.pom +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - 4.0.0 - com.example - test-artifact - 1.0.0 - Gradle Maven Publish Plugin Test Artifact - Testing the Gradle Maven Publish Plugin - https://github.com/vanniktech/gradle-maven-publish-plugin/ - 2018 - - - The Apache Software License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - vanniktech - Niklas Baudy - https://github.com/vanniktech/ - - - - scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git - scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git - https://github.com/vanniktech/gradle-maven-publish-plugin/ - - diff --git a/plugin/src/integrationTest/fixtures/common/gradle.properties b/plugin/src/integrationTest/fixtures/common/gradle.properties deleted file mode 100644 index 227885e5..00000000 --- a/plugin/src/integrationTest/fixtures/common/gradle.properties +++ /dev/null @@ -1,31 +0,0 @@ -RELEASE_SIGNING_ENABLED=true - -GROUP=com.example -VERSION_NAME=1.0.0 -POM_ARTIFACT_ID=test-artifact - -POM_NAME=Gradle Maven Publish Plugin Test Artifact -POM_PACKAGING=jar - -POM_DESCRIPTION=Testing the Gradle Maven Publish Plugin -POM_INCEPTION_YEAR=2018 - -POM_URL=https://github.com/vanniktech/gradle-maven-publish-plugin/ -POM_SCM_URL=https://github.com/vanniktech/gradle-maven-publish-plugin/ -POM_SCM_CONNECTION=scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git -POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git - -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo - -POM_DEVELOPER_ID=vanniktech -POM_DEVELOPER_NAME=Niklas Baudy -POM_DEVELOPER_URL=https://github.com/vanniktech/ - -signing.keyId=B89C4055 -signing.password=test -signing.secretKeyRingFile=test-secring.gpg - -org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m -org.gradle.vfs.watch=false diff --git a/plugin/src/integrationTest/fixtures/common/maven-publish.gradle b/plugin/src/integrationTest/fixtures/common/maven-publish.gradle deleted file mode 100644 index f24c3326..00000000 --- a/plugin/src/integrationTest/fixtures/common/maven-publish.gradle +++ /dev/null @@ -1,8 +0,0 @@ -publishing { - repositories { - maven { - name = "testFolder" - url = project.property("test.releaseRepository") - } - } -} diff --git a/plugin/src/integrationTest/fixtures/common/settings.gradle b/plugin/src/integrationTest/fixtures/common/settings.gradle deleted file mode 100644 index a8c76e60..00000000 --- a/plugin/src/integrationTest/fixtures/common/settings.gradle +++ /dev/null @@ -1,15 +0,0 @@ -pluginManagement { - repositories { - mavenLocal() - mavenCentral() - google() - } -} - -dependencyResolutionManagement { - repositories { - mavenLocal() - mavenCentral() - google() - } -} diff --git a/plugin/src/integrationTest/fixtures/common/test-secring.gpg b/plugin/src/integrationTest/fixtures/common/test-secring.gpg deleted file mode 100644 index 69899a7e323da4dcc6261d3a0c4d57b3707a7512..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4944 zcmajhWm^*fps?Z5AV~KBopg+rZcyoN5Ez{U>FzEWNDI>4xgj7OQqqldH%Jf8`(Ecd z@$LM8=ks%?Vtqt6q1SjqAp~Tnrh3E4%xMR3g*#fVl;lb};n8o54#F)BS-l9?H=|nv z7{Rk=>$=6MA1!MVA-UZ z=h>;9GcT0HZ-v!8h#B|0+Bs$jEUY6ngR1B{L$!vr+dBf^p6u?N#Sg|*uM(?fS(Qe% zvi3d12~jqGz|9b4IRW#;FXB0h_#oPYy%;Xf3kKM}z2@nuJ^*pjhu+Tu$wd2_Mr=h%ehm8WBpoF<9ejZWVb zp3%q-CtE(T8v_zHI2fK}VJ#)u<1zybO0Y3-J+Tp*FycNrczPu)fq7K_!rG=Lf_Kaau7CSp9H8|Y{} z*@i*#>2lxH?cG-?X+rO#IW@DB*Fc&OI9@@dmyaMffG*I1JdNx<7=yKs-8#tYdQx;m zzI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ti{ zQDG(QeHJL-*Y;CoVa_Bs!Z@Nmx7*1& zs&p#L#!-ZAtM52IKNKP#<@-hDvp)qqPp2Essr|Xxpfg|YZ5@y<4CiZ4xlRkW3j3Qi z0kNnZonwyW@MCm1VBdvzEG!{tqA<$whB97mGj!Oj!Y)D$1E6|e<=dgEI6KQL=rm?v z8UDZW)PEtNcU;&c7Y24(@}%lm3T0i*Mr26o3j|DVHIq07RScc-|M`sR|L_^!fBNiy zJM8*_;E6y8_osqF&>>^OFY`lXkFI#7PcqO*$;RPqTXqoB1P~-8Yc%owE>eA}!q#?t zyti@YZ~GG%ic{Z4zsJ9i=*3B|CXz;Eqm`Bhs}*PokNT zm$zo8^M?8qcMJBIxP#`;O(i7<{{J*id_~aEc&#*7#Q9avGx{KXDMv9*H{uOkF2jx~ zG9OZ3si7A%vne~Zc( - - - - - - - 4.0.0 - com.example - test-artifact - 1.0.0 - pom - Gradle Maven Publish Plugin Test Artifact - Testing the Gradle Maven Publish Plugin - https://github.com/vanniktech/gradle-maven-publish-plugin/ - 2018 - - - The Apache Software License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - vanniktech - Niklas Baudy - https://github.com/vanniktech/ - - - - scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git - scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git - https://github.com/vanniktech/gradle-maven-publish-plugin/ - - diff --git a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/settings.gradle b/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/settings.gradle deleted file mode 100644 index 7ed333ec..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -rootProject.name = "test-artifact" - -dependencyResolutionManagement { - repositories { - mavenLocal() - mavenCentral() - google() - } -} diff --git a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/AndroidManifest.xml b/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/AndroidManifest.xml deleted file mode 100644 index 7ee177e5..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java b/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java deleted file mode 100644 index 12017313..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_multi_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vanniktech.maven.publish.test; - -import android.app.Activity; -import android.os.Bundle; - -/** - * Just a test Activity with Javadoc. - */ -public class TestActivity extends Activity { - /** - * Main method which does something. - * - * @param args Command-line arguments passed to the program. - */ - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } -} diff --git a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/build.gradle b/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/build.gradle deleted file mode 100644 index 861b0ceb..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -import com.vanniktech.maven.publish.AndroidSingleVariantLibrary - -buildscript { - repositories { - mavenLocal() - mavenCentral() - google() - } - - dependencies { - classpath "com.vanniktech:gradle-maven-publish-plugin:${System.getProperty("com.vanniktech.publish.version")}" - classpath "com.android.tools.build:gradle:7.3.1" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.20" - } -} - -apply plugin: "com.android.library" -apply plugin: "com.vanniktech.maven.publish.base" - -group = "com.example" -version = "1.0.0" - -android { - compileSdkVersion 29 -} - -mavenPublishing { - signAllPublications() - pomFromGradleProperties() - configure(new AndroidSingleVariantLibrary("release")) -} - -apply from: "maven-publish.gradle" diff --git a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/expected/test-artifact-1.0.0.pom b/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/expected/test-artifact-1.0.0.pom deleted file mode 100644 index be18df21..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/expected/test-artifact-1.0.0.pom +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - 4.0.0 - com.example - test-artifact - 1.0.0 - aar - Gradle Maven Publish Plugin Test Artifact - Testing the Gradle Maven Publish Plugin - https://github.com/vanniktech/gradle-maven-publish-plugin/ - 2018 - - - The Apache Software License, Version 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - vanniktech - Niklas Baudy - https://github.com/vanniktech/ - - - - scm:git:git://github.com/vanniktech/gradle-maven-publish-plugin.git - scm:git:ssh://git@github.com/vanniktech/gradle-maven-publish-plugin.git - https://github.com/vanniktech/gradle-maven-publish-plugin/ - - diff --git a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/settings.gradle b/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/settings.gradle deleted file mode 100644 index 7ed333ec..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -rootProject.name = "test-artifact" - -dependencyResolutionManagement { - repositories { - mavenLocal() - mavenCentral() - google() - } -} diff --git a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/AndroidManifest.xml b/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/AndroidManifest.xml deleted file mode 100644 index 7ee177e5..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java b/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java deleted file mode 100644 index 12017313..00000000 --- a/plugin/src/integrationTest/fixtures/passing_android_single_variant_project/src/main/java/com/vanniktech/maven/publish/test/TestActivity.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vanniktech.maven.publish.test; - -import android.app.Activity; -import android.os.Bundle; - -/** - * Just a test Activity with Javadoc. - */ -public class TestActivity extends Activity { - /** - * Main method which does something. - * - * @param args Command-line arguments passed to the program. - */ - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } -} diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt deleted file mode 100644 index f5f52867..00000000 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginIntegrationTest.kt +++ /dev/null @@ -1,158 +0,0 @@ -package com.vanniktech.maven.publish - -import java.io.File -import java.util.zip.ZipFile -import org.assertj.core.api.Assertions.assertThat -import org.gradle.testkit.runner.BuildResult -import org.gradle.testkit.runner.GradleRunner -import org.gradle.testkit.runner.TaskOutcome.SUCCESS -import org.junit.Rule -import org.junit.Test -import org.junit.rules.TemporaryFolder - -class MavenPublishPluginIntegrationTest { - @get:Rule val testProjectDir: TemporaryFolder = TemporaryFolder() - - private lateinit var repoFolder: File - private lateinit var projectFolder: File - private lateinit var expectedFolder: File - - // TODO - @Test fun generatesArtifactsAndDocumentationOnAndroidSingleVariantProject() { - setupFixture("passing_android_single_variant_project") - - val result = executeGradleCommands(TEST_TASK, "--stacktrace") - - assertExpectedTasksRanSuccessfully(result) - assertExpectedCommonArtifactsGenerated(artifactExtension = "aar") - assertPomContentMatches() - } - - // TODO - @Test fun generatesArtifactsAndDocumentationOnAndroidMultiVariantProject() { - setupFixture("passing_android_multi_variant_project") - - val result = executeGradleCommands(TEST_TASK, "--stacktrace") - - assertExpectedTasksRanSuccessfully(result) - assertExpectedCommonArtifactsGenerated("aar", qualifier = "debug") - assertExpectedCommonArtifactsGenerated("aar", qualifier = "release") - assertPomContentMatches() - } - - /** - * Copies test fixture into temp directory under test. - */ - private fun setupFixture(fixtureName: String, projectName: String = fixtureName) { - repoFolder = testProjectDir.newFolder("repo") - projectFolder = testProjectDir.newFolder(projectName) - expectedFolder = projectFolder.resolve(EXPECTED_DIR) - - File("$FIXTURES/common").copyRecursively(projectFolder) - File("$FIXTURES/$fixtureName").copyRecursively(projectFolder, overwrite = true) - } - - private fun assertExpectedTasksRanSuccessfully(result: BuildResult, hasDokka: Boolean = false) { - assertThat(result.task(":$TEST_TASK")?.outcome).isEqualTo(SUCCESS) - if (hasDokka) { - assertThat(result.task(":dokkaHtml")?.outcome).isEqualTo(SUCCESS) - } else { - assertThat(result.task(":dokkaHtml")).isNull() - } - } - - /** - * Makes sure common artifacts are generated (POM, javadoc, sources, etc.), - * no matter what project type is and which plugins are applied. - */ - private fun assertExpectedCommonArtifactsGenerated( - artifactExtension: String = "jar", - artifactId: String = TEST_POM_ARTIFACT_ID, - groupId: String = TEST_GROUP, - version: String = TEST_VERSION_NAME, - qualifier: String? = null, - ) { - val qualifierSuffix = qualifier?.let { "-$it" } ?: "" - val artifactJar = "$artifactId-$version$qualifierSuffix.$artifactExtension" - val pomFile = "$artifactId-$version.pom" - val moduleFile = "$artifactId-$version.module" - val javadocJar = "$artifactId-$version$qualifierSuffix-javadoc.jar" - val sourcesJar = "$artifactId-$version$qualifierSuffix-sources.jar" - assertArtifactGenerated(artifactJar, artifactId, groupId, version) - assertArtifactGenerated(pomFile, artifactId, groupId, version) - assertArtifactGenerated(moduleFile, artifactId, groupId, version) - assertArtifactGenerated(javadocJar, artifactId, groupId, version) - assertArtifactGenerated(sourcesJar, artifactId, groupId, version) - } - - private fun assertArtifactGenerated( - artifactFileNameWithExtension: String, - artifactId: String = TEST_POM_ARTIFACT_ID, - groupId: String = TEST_GROUP, - version: String = TEST_VERSION_NAME - ) { - val artifactFolder = artifactFolder(artifactId, groupId, version) - - assertThat(artifactFolder.resolve(artifactFileNameWithExtension)).exists() - assertThat(artifactFolder.resolve("$artifactFileNameWithExtension.asc")).exists() - } - - private fun assertPomContentMatches( - artifactId: String = TEST_POM_ARTIFACT_ID, - groupId: String = TEST_GROUP, - version: String = TEST_VERSION_NAME - ) { - val artifactFolder = artifactFolder(artifactId, groupId, version) - val pomFileName = "$artifactId-$version.pom" - - val resolvedPomFile = artifactFolder.resolve(pomFileName) - val content = resolvedPomFile.readText() - - val expectedContent = expectedFolder.resolve(pomFileName).readText() - assertThat(content).isEqualToNormalizingWhitespace(expectedContent) - } - - private fun assertSourceJarContainsFile( - file: String, - srcRoot: String, - artifactId: String = TEST_POM_ARTIFACT_ID, - groupId: String = TEST_GROUP, - version: String = TEST_VERSION_NAME - ) { - val artifactFolder = artifactFolder(artifactId, groupId, version) - val sourcesJar = ZipFile(artifactFolder.resolve("$artifactId-$version-sources.jar")) - val entry = sourcesJar.getEntry(file) - assertThat(entry).describedAs(file).isNotNull() - - val content = sourcesJar.getInputStream(entry)?.reader()?.buffered()?.readText() - - val expected = projectFolder.resolve(srcRoot).resolve(file) - val expectedContent = expected.readText() - - assertThat(content).describedAs(file).isNotBlank() - assertThat(content).describedAs(file).isEqualTo(expectedContent) - } - - private fun artifactFolder(artifactId: String, groupId: String, version: String): File { - val group = groupId.replace(".", "/") - return repoFolder.resolve(group).resolve(artifactId).resolve(version) - } - - private fun executeGradleCommands(vararg commands: String) = GradleRunner.create() - .withProjectDir(projectFolder) - .withArguments(*commands, "-Ptest.releaseRepository=$repoFolder") - .withDebug(true) - .forwardOutput() - .build() - - companion object { - const val FIXTURES = "src/integrationTest/fixtures" - const val EXPECTED_DIR = "expected" - - const val TEST_GROUP = "com.example" - const val TEST_VERSION_NAME = "1.0.0" - const val TEST_POM_ARTIFACT_ID = "test-artifact" - - const val TEST_TASK = "publishAllPublicationsToTestFolderRepository" - } -} diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt index c50d1afb..fb17d79a 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginPlatformTest.kt @@ -378,6 +378,41 @@ class MavenPublishPluginPlatformTest { assertThat(result).javadocJar().isSigned() } + @TestParameterInjectorTest + fun androidMultiVariantLibraryProject(@TestParameter agpVersion: AgpVersion) { + // regular plugin does not have a way to enable multi variant config + assume().that(config).isEqualTo(TestOptions.Config.BASE) + agpVersion.assumeSupportedGradleVersion() + + val project = androidLibraryProjectSpec(agpVersion).copy( + basePluginConfig = "configure(new AndroidMultiVariantLibrary(true, true))", + ) + val result = project.run(fixtures, testProjectDir, testOptions) + + assertThat(result).outcome().succeeded() + assertThat(result).pom().exists() + assertThat(result).pom().isSigned() + assertThat(result).pom().matchesExpectedPom("pom") + assertThat(result).module().exists() + assertThat(result).module().isSigned() + + assertThat(result).artifact("debug", "aar").exists() + assertThat(result).artifact("debug", "aar").isSigned() + assertThat(result).sourcesJar("debug").exists() + assertThat(result).sourcesJar("debug").isSigned() + assertThat(result).sourcesJar("debug").containsAllSourceFiles() + assertThat(result).javadocJar("debug").exists() + assertThat(result).javadocJar("debug").isSigned() + + assertThat(result).artifact("release", "aar").exists() + assertThat(result).artifact("release", "aar").isSigned() + assertThat(result).sourcesJar("release").exists() + assertThat(result).sourcesJar("release").isSigned() + assertThat(result).sourcesJar("release").containsAllSourceFiles() + assertThat(result).javadocJar("release").exists() + assertThat(result).javadocJar("release").isSigned() + } + @TestParameterInjectorTest fun androidLibraryKotlinProject( @TestParameter agpVersion: AgpVersion, diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpec.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpec.kt index c4d97cec..8bb1ef15 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpec.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpec.kt @@ -10,6 +10,7 @@ data class ProjectSpec( val version: String?, val properties: Map, val sourceFiles: List, + val basePluginConfig: String, val defaultProjectName: String = "default-root-project-name", val buildFileExtra: String = "", ) diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt index 1c28105b..26fc033b 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt @@ -37,7 +37,9 @@ fun ProjectSpec.run(fixtures: Path, temp: Path, options: TestOptions): ProjectRe private fun ProjectSpec.writeBuildFile(path: Path, repo: Path, options: TestOptions) { path.writeText( """ - ${pluginsBlock()} + import com.vanniktech.maven.publish.* + + ${pluginsBlock(options)} ${publishingBlock(options)} @@ -56,7 +58,7 @@ private fun ProjectSpec.writeBuildFile(path: Path, repo: Path, options: TestOpti ) } -private fun ProjectSpec.pluginsBlock() = buildString { +private fun ProjectSpec.pluginsBlock(options: TestOptions) = buildString { appendLine("plugins {") plugins.forEach { append(" id \"${it.id}\"") @@ -67,16 +69,31 @@ private fun ProjectSpec.pluginsBlock() = buildString { appendLine() } } - appendLine(" id \"com.vanniktech.maven.publish\" version \"${System.getProperty("com.vanniktech.publish.version")}\"") + + val pluginVersion = System.getProperty("com.vanniktech.publish.version") + when (options.config) { + TestOptions.Config.BASE -> appendLine(" id \"com.vanniktech.maven.publish.base\" version \"${pluginVersion}\"") + TestOptions.Config.DSL, + TestOptions.Config.PROPERTIES -> appendLine(" id \"com.vanniktech.maven.publish\" version \"${pluginVersion}\"") + } + appendLine("}") } private fun ProjectSpec.publishingBlock(options: TestOptions): String { - return if (options.config == TestOptions.Config.DSL) { - listOfNotNull( + return when (options.config) { + TestOptions.Config.PROPERTIES -> { + """ + mavenPublishing { + } + """.trimIndent() + } + TestOptions.Config.BASE, + TestOptions.Config.DSL -> listOfNotNull( """ mavenPublishing { + ${if (options.config == TestOptions.Config.BASE) basePluginConfig else ""} ${if (options.signing != TestOptions.Signing.NO_SIGNING) "signAllPublications()" else ""} ${if (group != null && artifactId != null && version != null) "coordinates(\"$group\", \"$artifactId\", \"$version\")" else ""} @@ -117,11 +134,6 @@ private fun ProjectSpec.publishingBlock(options: TestOptions): String { } """.trimIndent(), ).joinToString(separator = "\n") - } else { - """ - mavenPublishing { - } - """.trimIndent() } } diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt index 265479c7..d80d485c 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt @@ -44,7 +44,8 @@ fun javaProjectSpec() = ProjectSpec( properties = defaultProperties, sourceFiles = listOf( SourceFile("main", "java", "com/vanniktech/maven/publish/test/JavaTestClass.java"), - ) + ), + basePluginConfig = "configure(new JavaLibrary(new JavadocJar.Empty(), true))", ) fun javaLibraryProjectSpec() = ProjectSpec( @@ -57,7 +58,8 @@ fun javaLibraryProjectSpec() = ProjectSpec( properties = defaultProperties, sourceFiles = listOf( SourceFile("main", "java", "com/vanniktech/maven/publish/test/JavaTestClass.java"), - ) + ), + basePluginConfig = "configure(new JavaLibrary(new JavadocJar.Empty(), true))", ) fun javaGradlePluginProjectSpec() = ProjectSpec( @@ -81,7 +83,8 @@ fun javaGradlePluginProjectSpec() = ProjectSpec( } } } - """.trimIndent() + """.trimIndent(), + basePluginConfig = "configure(new GradlePlugin(new JavadocJar.Empty(), true))", ) fun kotlinJvmProjectSpec(version: KotlinVersion) = ProjectSpec( @@ -95,7 +98,8 @@ fun kotlinJvmProjectSpec(version: KotlinVersion) = ProjectSpec( sourceFiles = listOf( SourceFile("main", "java", "com/vanniktech/maven/publish/test/JavaTestClass.java"), SourceFile("main", "kotlin", "com/vanniktech/maven/publish/test/KotlinTestClass.kt"), - ) + ), + basePluginConfig = "configure(new KotlinJvm(new JavadocJar.Empty(), true))", ) fun kotlinJsProjectSpec(version: KotlinVersion) = ProjectSpec( @@ -109,13 +113,14 @@ fun kotlinJsProjectSpec(version: KotlinVersion) = ProjectSpec( sourceFiles = listOf( SourceFile("main", "kotlin", "com/vanniktech/maven/publish/test/KotlinTestClass.kt"), ), + basePluginConfig = "configure(new KotlinJs(new JavadocJar.Empty(), true))", buildFileExtra = """ kotlin { js("IR") { nodejs() } } - """.trimIndent() + """.trimIndent(), ) fun kotlinMultiplatformProjectSpec(version: KotlinVersion) = ProjectSpec( @@ -132,6 +137,7 @@ fun kotlinMultiplatformProjectSpec(version: KotlinVersion) = ProjectSpec( SourceFile("linuxMain", "kotlin", "com/vanniktech/maven/publish/test/ExpectedTestClass.kt"), SourceFile("nodeJsMain", "kotlin", "com/vanniktech/maven/publish/test/ExpectedTestClass.kt"), ), + basePluginConfig = "configure(new KotlinMultiplatform(new JavadocJar.Empty()))", buildFileExtra = """ kotlin { jvm() @@ -202,6 +208,7 @@ fun androidLibraryProjectSpec(version: AgpVersion) = ProjectSpec( sourceFiles = listOf( SourceFile("main", "java", "com/vanniktech/maven/publish/test/JavaTestClass.java"), ), + basePluginConfig = "configure(new AndroidSingleVariantLibrary(\"release\", true, true))", buildFileExtra = """ android { namespace "com.test.library" @@ -244,6 +251,7 @@ fun javaPlatformProjectSpec() = ProjectSpec( version = "1.0.0", properties = defaultProperties, sourceFiles = emptyList(), + basePluginConfig = "configure(new JavaPlatform())", buildFileExtra = """ dependencies { constraints { @@ -263,6 +271,7 @@ fun versionCatalogProjectSpec() = ProjectSpec( version = "1.0.0", properties = defaultProperties, sourceFiles = emptyList(), + basePluginConfig = "configure(new VersionCatalog())", buildFileExtra = """ catalog { versionCatalog { diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Subjects.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Subjects.kt index ad2b5d82..9214c262 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Subjects.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/Subjects.kt @@ -100,18 +100,20 @@ class ProjectResultSubject private constructor( open class ArtifactSubject internal constructor( failureMetadata: FailureMetadata, private val artifact: Path, + private val result: ProjectResult, ) : Subject(failureMetadata, artifact) { companion object { private val BUILD_RESULT_SUBJECT_FACTORY: Factory> = - Factory { metadata, actual -> ArtifactSubject(metadata, actual.first) } + Factory { metadata, actual -> ArtifactSubject(metadata, actual.first, actual.second) } fun artifact() = BUILD_RESULT_SUBJECT_FACTORY } fun exists() { if (!artifact.exists()) { - failWithoutActual(fact("expected to exist", artifact)) + val files = result.repo.toFile().walkTopDown().filter { it.isFile }.toList() + failWithActual(fact("expected to exist", artifact), fact("but repo contained", files)) } } @@ -134,7 +136,7 @@ class SourcesJarSubject private constructor( failureMetadata: FailureMetadata, private val artifact: Path, private val result: ProjectResult, -) : ArtifactSubject(failureMetadata, artifact) { +) : ArtifactSubject(failureMetadata, artifact, result) { companion object { private val BUILD_RESULT_SUBJECT_FACTORY: Factory> = @@ -200,7 +202,7 @@ class PomSubject private constructor( failureMetadata: FailureMetadata, private val artifact: Path, private val result: ProjectResult, -) : ArtifactSubject(failureMetadata, artifact) { +) : ArtifactSubject(failureMetadata, artifact, result) { companion object { private val BUILD_RESULT_SUBJECT_FACTORY: Factory> = diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt index b6c4deb4..bf9bdc98 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/TestOptions.kt @@ -8,6 +8,7 @@ data class TestOptions( enum class Config { DSL, PROPERTIES, + BASE, } enum class Signing { NO_SIGNING, diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt index e9ad10f4..d28af25d 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt @@ -294,10 +294,12 @@ data class KotlinJs @JvmOverloads constructor( override fun configure(project: Project) { // Create publication, since Kotlin/JS doesn't provide one by default. // https://youtrack.jetbrains.com/issue/KT-41582 - project.gradlePublishing.publications.create(PUBLICATION_NAME, MavenPublication::class.java) { - it.from(project.components.getByName("kotlin")) - it.withSourcesJar { project.kotlinSourcesJar(sourcesJar) } - it.withJavadocJar { project.javadocJarTask(javadocJar) } + project.afterEvaluate { + project.gradlePublishing.publications.create(PUBLICATION_NAME, MavenPublication::class.java) { + it.from(project.components.getByName("kotlin")) + it.withSourcesJar { project.kotlinSourcesJar(sourcesJar) } + it.withJavadocJar { project.javadocJarTask(javadocJar) } + } } } }