diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 470579f53b6..1c666c44d86 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -98,17 +98,30 @@ gradlePlugin { } } +tasks.register("testPlugins") { + project.ext["enablePluginTests"] = "true" + dependsOn("test") +} + +tasks.register("dackkaPluginTests") { + systemProperty("rebuildDackkaOutput", "true") + include("com/google/firebase/gradle/plugins/DackkaPluginTests.class") +} + +tasks.register("updateDackkaTestsOutput") { + project.ext["enablePluginTests"] = "true" + dependsOn("dackkaPluginTests") +} + +tasks.test.configure { + onlyIf { + project.hasProperty("enablePluginTests") + } +} + tasks.withType { testLogging { // Make sure output from standard out or error is shown in Gradle output. showStandardStreams = true } - val enablePluginTests: String? by rootProject - enabled = enablePluginTests == "true" -} - -tasks.withType().configureEach { - kotlinOptions { - jvmTarget = "11" - } } diff --git a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/KotlinUtils.kt b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/KotlinUtils.kt index 0045afeef87..f35ee064ceb 100644 --- a/buildSrc/src/main/java/com/google/firebase/gradle/plugins/KotlinUtils.kt +++ b/buildSrc/src/main/java/com/google/firebase/gradle/plugins/KotlinUtils.kt @@ -14,8 +14,135 @@ package com.google.firebase.gradle.plugins +import java.io.BufferedReader +import java.io.File + /** Replaces all matching substrings with an empty string (nothing) */ fun String.remove(regex: Regex) = replace(regex, "") /** Replaces all matching substrings with an empty string (nothing) */ fun String.remove(str: String) = replace(str, "") + +/** The value of this string or an empty string if null. */ +fun String?.orEmpty() = this ?: "" + +/** + * Represents a Diff in the context of two inputs. + * + * Every subclass overrides toString() to provide output similar to that of the UNIX diff command. + * + * @see FileChanged + * @see ContentChanged + * @see LineChanged + */ +interface DiffEntry + +/** When a file is either added or removed. */ +data class FileChanged(val file: File, val added: Boolean) : DiffEntry { + override fun toString() = "${if (added) "+++" else "---"} ${file.name}" +} + +/** When the contents of a file are changed. */ +data class ContentChanged(val file: File, val lines: List) : DiffEntry { + override fun toString() = + """ + == [ ${file.path} ] == + ${lines.joinToString("\n")} + + """ + .trimIndent() +} + +/** + * Represents an individual line change, providing the original and new strings. + * + * This exists to provide a type-safe way of organizing data, while also overriding toString() to + * match the output of the UNIX diff command. + * + * @see ContentChanged + */ +data class LineChanged(val from: String, val to: String) { + override fun toString() = + """ + --- ${from.trim()} + +++ ${to.trim()} + """ + .trimEnd() +} + +/** + * Recursively compares two directories and returns their diff. + * + * You should call [File.diff] instead for individual files and non recursive needs. + * + * @throws RuntimeException when called from or on a non directory file. + */ +fun File.recursiveDiff(newDirectory: File): List { + if (!isDirectory) throw RuntimeException("Called on a non directory file: $path") + if (!newDirectory.isDirectory) + throw RuntimeException("Called for a non directory file: ${newDirectory.path}") + + val changedFiles = + walkTopDown().mapNotNull { + val relativePath = it.toRelativeString(this) + val newFile = File("${newDirectory.path}/$relativePath") + + if (!newFile.exists()) { + FileChanged(it, false) + } else { + it.diff(newFile) + } + } + + val addedFiles = + newDirectory.walkTopDown().mapNotNull { + val relativePath = it.toRelativeString(newDirectory) + val oldFile = File("$path/$relativePath") + + FileChanged(it, true).takeUnless { oldFile.exists() } + } + + return (changedFiles + addedFiles).toList() +} + +/** + * Compares two files and returns their diff. + * + * While this can handle comparing directories, it will NOT recursively compare them. If that is the + * behavior you are looking for, you should use [File.recursiveDiff] instead. + * + * @see [DiffEntry] + */ +fun File.diff(otherFile: File): DiffEntry? { + if (isDirectory || otherFile.isDirectory) { + return FileChanged(this, false).takeUnless { isDirectory && otherFile.isDirectory } + } + + val otherFileReader = otherFile.bufferedReader() + + val changedLines = + bufferedReader().useLines { + it + .mapNotNull { + LineChanged(it, otherFileReader.safeReadLine().orEmpty()).takeIf { it.from != it.to } + } + .toList() + } + + val addedLines = otherFileReader.useLines { it.map { LineChanged("", it) }.toList() } + + val diff = changedLines + addedLines + + return ContentChanged(otherFile, diff).takeUnless { diff.isEmpty() } +} + +/** + * A safe variant of [BufferedReader.readLine] that will catch [NullPointerException] and return + * null instead. + */ +fun BufferedReader.safeReadLine(): String? = + try { + readLine() + } catch (_: NullPointerException) { + null + } diff --git a/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/DackkaPluginTests.kt b/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/DackkaPluginTests.kt new file mode 100644 index 00000000000..9b158baa872 --- /dev/null +++ b/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/DackkaPluginTests.kt @@ -0,0 +1,126 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.firebase.gradle.plugins + +import com.google.common.truth.Truth.assertThat +import java.io.File +import org.gradle.testkit.runner.GradleRunner +import org.junit.BeforeClass +import org.junit.ClassRule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +/** + * Ensures the current state of Dackka outputs what we expect from it. + * + * We do this by running the [DackkaPlugin] against a small project fixture and comparing the output + * to a pre-compiled output that represents what we expect Dackka to generate. + * + * ## Resources + * + * The resources for the tests are stored under `src/test/resources/dackka-plugin-tests` with two + * sub directories that will be explained below. + * + * ### project + * + * Directory containing a small gradle project, with various sub-projects. These exist to test edge + * case scenarios in our doc generation- to ensure any changes do not break previous fixes. + * + * ### output + * + * Directory containing the **expected** output from running the [DackkaPlugin] against the + * predefined project fixture. + * + * ## Updating Output + * + * Should the time come where Dackka behavior completely changes, the format changes, or maybe we + * find a new edge-case; the output directory that gets compared during testing time should be + * updated. + * + * Since the tests run on a project fixture, the easiest way to update the output is to add a clause + * in the tests itself to overwrite the previous output. This behavior is not preferred, and should + * be evaluated at a later date. You can see this in [DackkaPluginTests.updateDocs]. + * + * You can trigger this function to run one of two ways; passing the `rebuildDackkaOutput` property + * to gradle during the build, or calling the `updateDackkaTestsPlugin` task. + * + * Example: + * ``` + * ./gradlew -b buildSrc/build.gradle.kts updateDackkaTestsPlugin + * ``` + */ +class DackkaPluginTests { + + companion object { + @ClassRule @JvmField val testProjectDir = TemporaryFolder() + + private val resourcesDirectory = File("src/test/resources/dackka-plugin-tests/") + private val outputDirectory = File("$resourcesDirectory/output/firebase-kotlindoc") + + @BeforeClass + @JvmStatic + fun setup() { + copyFixtureToTempDirectory() + buildDocs() + if (System.getProperty("rebuildDackkaOutput") == "true") { + updateDocs() + } + } + + /** + * Updates the current docs and output to match an updated source. + * + * Unfortunately, we need GradleRunner to be able to do this automatically, and this was the + * cleanest way I could accomplish such. I'm sure this can be fixed down the line should we + * expand buildSrc into its own composite build. + */ + private fun updateDocs() { + removeOldOutputFiles() + + val docDirectory = File("${testProjectDir.root}/build/firebase-kotlindoc") + + docDirectory.copyRecursively(outputDirectory, true) + } + + private fun removeOldOutputFiles() { + outputDirectory.deleteRecursively() + } + + private fun copyFixtureToTempDirectory() { + val project = File("$resourcesDirectory/project") + project.copyRecursively(testProjectDir.root) + } + + private fun buildDocs() { + GradleRunner.create() + .withProjectDir(testProjectDir.root) + .withPluginClasspath() + .withArguments("kotlindoc") + .build() + } + } + + @Test + fun `Transforms correctly`() { + val buildDirectory = File("${testProjectDir.root}/build") + val docDirectory = File("$buildDirectory/firebase-kotlindoc") + + val diff = docDirectory.recursiveDiff(outputDirectory) + val diffAsString = diff.joinToString("\n") + + println(diffAsString) + assertThat(diffAsString).isEmpty() + } +} diff --git a/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/LicenseResolverPluginTests.kt b/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/LicenseResolverPluginTests.kt index 14755fbf1f2..2905d00f645 100644 --- a/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/LicenseResolverPluginTests.kt +++ b/buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/LicenseResolverPluginTests.kt @@ -150,7 +150,7 @@ class LicenseResolverPluginTests { } thirdPartyLicenses { - add 'customLib1', "${File("src/test/fixtures/license.txt").absolutePath}" + add 'customLib1', "${File("src/test/resources/license.txt").absolutePath}" } """ } diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/client/module/_toc.yaml b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/client/module/_toc.yaml new file mode 100644 index 00000000000..89fb3aeeea5 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/client/module/_toc.yaml @@ -0,0 +1,22 @@ +toc: +- title: "com.example" + path: "/reference/com/example/package-summary.html" + + section: + - title: "Interfaces" + + section: + - title: "Phrase" + path: "/reference/com/example/Phrase.html" + + - title: "Classes" + + section: + - title: "CheckTheReleaseSpreadsheet" + path: "/reference/com/example/CheckTheReleaseSpreadsheet.html" + - title: "Goodbye" + path: "/reference/com/example/Goodbye.html" + - title: "Hello" + path: "/reference/com/example/Hello.html" + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/CheckTheReleaseSpreadsheet.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/CheckTheReleaseSpreadsheet.html new file mode 100644 index 00000000000..c2f7ce5a0e1 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/CheckTheReleaseSpreadsheet.html @@ -0,0 +1,75 @@ + + + CheckTheReleaseSpreadsheet +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/android/_reference-head-tags.html" %} + + +

CheckTheReleaseSpreadsheet

+

+

public final class CheckTheReleaseSpreadsheet implements Phrase
+

+
+

An old phrase that was used exclusively by the folks at Firebase.

+
+ + + + + + + + + + + + +
See also
FirebaseMake your app the best it can be
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + +

Public methods

String + +
+
+

Public constructors

+
+

CheckTheReleaseSpreadsheet

+
public CheckTheReleaseSpreadsheet()
+
+

Public methods

+
+

speak

+
public String speak()
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Goodbye.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Goodbye.html new file mode 100644 index 00000000000..f1ee60f200f --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Goodbye.html @@ -0,0 +1,85 @@ + + + Goodbye +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/android/_reference-head-tags.html" %} + + +

Goodbye

+

+

public final class Goodbye implements Phrase
+

+
+

A phrase used when one is leaving, or departing from a premise. Pronounced good · bi

+
+ + + + + + + + + + + + +
See also
Hello
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + + + + + +

Public methods

String + +
String + +
+
+

Public constructors

+
+

Goodbye

+
public Goodbye()
+
+

Public methods

+
+

sayGoodbye

+
public String sayGoodbye()
+
+
+

speak

+
public String speak()
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Hello.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Hello.html new file mode 100644 index 00000000000..39f516ebb1a --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Hello.html @@ -0,0 +1,85 @@ + + + Hello +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/android/_reference-head-tags.html" %} + + +

Hello

+

+

public final class Hello implements Phrase
+

+
+

A phrase used when one is entering a premise. Pronounced he · lo

+
+ + + + + + + + + + + + +
See also
Goodbye
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + + + + + +

Public methods

String + +
String + +
+
+

Public constructors

+
+

Hello

+
public Hello()
+
+

Public methods

+
+

sayHello

+
public String sayHello()
+
+
+

speak

+
public String speak()
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Phrase.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Phrase.html new file mode 100644 index 00000000000..671d3ba18b8 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/Phrase.html @@ -0,0 +1,68 @@ + + + Phrase +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/android/_reference-head-tags.html" %} + + +

Phrase

+

+

public interface Phrase
+

+
Known direct subclasses + + +
+
+ + + + + + + + + + + + + + + +
CheckTheReleaseSpreadsheet +

An old phrase that was used exclusively by the folks at Firebase.

+
Goodbye +

A phrase used when one is leaving, or departing from a premise.

+
Hello +

A phrase used when one is entering a premise.

+
+
+
+
+
+

Summary

+
+ + + + + + + + + + + + +

Public methods

abstract String + +
+
+

Public methods

+
+

speak

+
abstract String speak()
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/package-summary.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/package-summary.html new file mode 100644 index 00000000000..60f38ee429d --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/android/com/example/package-summary.html @@ -0,0 +1,47 @@ + + + com.example +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/android/_reference-head-tags.html" %} + + +

com.example

+

Interfaces

+
+ + + + + + + +
Phrase
+
+

Classes

+
+ + + + + + + + + + + + + + + +
CheckTheReleaseSpreadsheet +

An old phrase that was used exclusively by the folks at Firebase.

+
Goodbye +

A phrase used when one is leaving, or departing from a premise.

+
Hello +

A phrase used when one is entering a premise.

+
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/client/module/_toc.yaml b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/client/module/_toc.yaml new file mode 100644 index 00000000000..52297f3b15a --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/client/module/_toc.yaml @@ -0,0 +1,22 @@ +toc: +- title: "com.example" + path: "/reference/kotlin/com/example/package-summary.html" + + section: + - title: "Interfaces" + + section: + - title: "Phrase" + path: "/reference/kotlin/com/example/Phrase.html" + + - title: "Classes" + + section: + - title: "CheckTheReleaseSpreadsheet" + path: "/reference/kotlin/com/example/CheckTheReleaseSpreadsheet.html" + - title: "Goodbye" + path: "/reference/kotlin/com/example/Goodbye.html" + - title: "Hello" + path: "/reference/kotlin/com/example/Hello.html" + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/CheckTheReleaseSpreadsheet.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/CheckTheReleaseSpreadsheet.html new file mode 100644 index 00000000000..553818fd66a --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/CheckTheReleaseSpreadsheet.html @@ -0,0 +1,75 @@ + + + CheckTheReleaseSpreadsheet +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/kotlin/_reference-head-tags.html" %} + + +

CheckTheReleaseSpreadsheet

+

+

class CheckTheReleaseSpreadsheet : Phrase
+

+
+

An old phrase that was used exclusively by the folks at Firebase.

+
+ + + + + + + + + + + + +
See also
FirebaseMake your app the best it can be
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + +

Public functions

String! + +
+
+

Public constructors

+
+

CheckTheReleaseSpreadsheet

+
CheckTheReleaseSpreadsheet()
+
+

Public functions

+
+

speak

+
fun speak(): String!
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Goodbye.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Goodbye.html new file mode 100644 index 00000000000..148d0d18a85 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Goodbye.html @@ -0,0 +1,85 @@ + + + Goodbye +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/kotlin/_reference-head-tags.html" %} + + +

Goodbye

+

+

class Goodbye : Phrase
+

+
+

A phrase used when one is leaving, or departing from a premise. Pronounced good · bi

+
+ + + + + + + + + + + + +
See also
Hello
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + + + + + +

Public functions

String! + +
String! + +
+
+

Public constructors

+
+

Goodbye

+
Goodbye()
+
+

Public functions

+
+

sayGoodbye

+
fun sayGoodbye(): String!
+
+
+

speak

+
fun speak(): String!
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Hello.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Hello.html new file mode 100644 index 00000000000..cc73cad47c0 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Hello.html @@ -0,0 +1,85 @@ + + + Hello +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/kotlin/_reference-head-tags.html" %} + + +

Hello

+

+

class Hello : Phrase
+

+
+

A phrase used when one is entering a premise. Pronounced he · lo

+
+ + + + + + + + + + + + +
See also
Goodbye
+
+

Summary

+
+ + + + + + + + + + + +

Public constructors

+ +
+
+
+ + + + + + + + + + + + + + + + +

Public functions

String! + +
String! + +
+
+

Public constructors

+
+

Hello

+
Hello()
+
+

Public functions

+
+

sayHello

+
fun sayHello(): String!
+
+
+

speak

+
fun speak(): String!
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Phrase.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Phrase.html new file mode 100644 index 00000000000..235e7166ce9 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/Phrase.html @@ -0,0 +1,68 @@ + + + Phrase +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/kotlin/_reference-head-tags.html" %} + + +

Phrase

+

+

interface Phrase
+

+
Known direct subclasses + + +
+
+ + + + + + + + + + + + + + + +
CheckTheReleaseSpreadsheet +

An old phrase that was used exclusively by the folks at Firebase.

+
Goodbye +

A phrase used when one is leaving, or departing from a premise.

+
Hello +

A phrase used when one is entering a premise.

+
+
+
+
+
+

Summary

+
+ + + + + + + + + + + + +

Public functions

String! + +
+
+

Public functions

+
+

speak

+
fun speak(): String!
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/package-summary.html b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/package-summary.html new file mode 100644 index 00000000000..8ddcf3ba81b --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/output/firebase-kotlindoc/kotlin/com/example/package-summary.html @@ -0,0 +1,47 @@ + + + com.example +{% setvar book_path %}/_book.yaml{% endsetvar %} +{% include "docs/reference/kotlin/_reference-head-tags.html" %} + + +

com.example

+

Interfaces

+
+ + + + + + + +
Phrase
+
+

Classes

+
+ + + + + + + + + + + + + + + +
CheckTheReleaseSpreadsheet +

An old phrase that was used exclusively by the folks at Firebase.

+
Goodbye +

A phrase used when one is leaving, or departing from a premise.

+
Hello +

A phrase used when one is entering a premise.

+
+
+ + + diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/build.gradle b/buildSrc/src/test/resources/dackka-plugin-tests/project/build.gradle new file mode 100644 index 00000000000..a8cc6ff4bca --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/build.gradle @@ -0,0 +1,25 @@ +buildscript { + repositories { + google() + mavenCentral() + maven { + url 'https://storage.googleapis.com/android-ci/mvn/' + metadataSources { + artifact() + } + } + } +} + +configure(subprojects) { + repositories { + google() + mavenCentral() + maven { + url 'https://storage.googleapis.com/android-ci/mvn/' + metadataSources { + artifact() + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/build.gradle b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/build.gradle new file mode 100644 index 00000000000..9de8b8ed311 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'firebase-library' +} + +firebaseLibrary { + publishSources = true + publishJavadoc = false +} + +android.compileSdkVersion = 26 +android.sourceSets { + main.java.srcDirs += 'src/main/kotlin' +} \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/gradle.properties b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/gradle.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/AndroidManifest.xml b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..31af592ffb5 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/kotlin/source.kt b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/kotlin/source.kt new file mode 100644 index 00000000000..1740b352915 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/hidden-module/src/main/kotlin/source.kt @@ -0,0 +1,28 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.example + +interface AlternativePhrases { + fun speak(): String +} + +/** + * A phrase used when one is entering a premise. + */ +class Hi() : AlternativePhrases { + fun sayHi() = "Hi" + + override fun speak() = sayHi() +} \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/module/build.gradle b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/build.gradle new file mode 100644 index 00000000000..6bb36f36034 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'firebase-library' +} + +firebaseLibrary { + publishSources = true + publishJavadoc = true +} + +android.compileSdkVersion = 26 +android.sourceSets { + main.java.srcDirs += 'src/main/kotlin' +} \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/module/gradle.properties b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/gradle.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/AndroidManifest.xml b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..31af592ffb5 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/kotlin/source.kt b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/kotlin/source.kt new file mode 100644 index 00000000000..7af2fc5f1f5 --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/module/src/main/kotlin/source.kt @@ -0,0 +1,63 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.example + +interface Phrase { + fun speak(): String +} + +/** + * A phrase used when one is entering a premise. + * + * Pronounced he · lo + * + * @see Goodbye + */ +class Hello() : Phrase { + fun sayHello() = "Hello" + + override fun speak() = sayHello() +} + +/** + * A phrase used when one is leaving, or departing from a premise. + * + * Pronounced good · bi + * + * @see Hello + */ +class Goodbye() : Phrase { + fun sayGoodbye() = "Goodbye" + + override fun speak() = sayGoodbye() +} + +/** + * An old phrase that was used exclusively by the folks at Firebase. + * + * @see FirebaseMake your app the best it can be + */ +class CheckTheReleaseSpreadsheet(): Phrase { + override fun speak() = "Check the release spreadsheet" +} + +/** + * An unprofessional greeting, typically used with friends. + * + * @hide + */ +class Wasgood() : Phrase { + override fun speak() = "Wasgood" +} diff --git a/buildSrc/src/test/resources/dackka-plugin-tests/project/settings.gradle b/buildSrc/src/test/resources/dackka-plugin-tests/project/settings.gradle new file mode 100644 index 00000000000..f68515c0a6d --- /dev/null +++ b/buildSrc/src/test/resources/dackka-plugin-tests/project/settings.gradle @@ -0,0 +1,2 @@ +include ":module" +include ":hidden-module" \ No newline at end of file diff --git a/buildSrc/src/test/fixtures/license.txt b/buildSrc/src/test/resources/license.txt similarity index 100% rename from buildSrc/src/test/fixtures/license.txt rename to buildSrc/src/test/resources/license.txt