From 1299399ea63cb040b0f172920c869d118b64d550 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 14 Dec 2023 18:19:29 +0100 Subject: [PATCH 1/3] Correctly link refaster recipes --- build.gradle.kts | 7 +++++++ .../kotlin/org/openrewrite/RecipeOrigin.kt | 2 +- .../org/openrewrite/RecipeOriginTest.kt | 21 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/test/kotlin/org/openrewrite/RecipeOriginTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 40d95d7..4d94796 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,6 +54,9 @@ dependencies { implementation("io.github.java-diff-utils:java-diff-utils:4.11") runtimeOnly("org.slf4j:slf4j-simple:1.7.30") + testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release") + "recipe"(platform("org.openrewrite:rewrite-bom:$rewriteVersion")) "recipe"("org.openrewrite:rewrite-core") "recipe"("org.openrewrite:rewrite-groovy") @@ -111,6 +114,10 @@ tasks.named("compileJava") { targetCompatibility = JavaVersion.VERSION_17.toString() } +tasks.withType { + useJUnitPlatform() +} + application { mainClass.set("org.openrewrite.RecipeMarkdownGenerator") } diff --git a/src/main/kotlin/org/openrewrite/RecipeOrigin.kt b/src/main/kotlin/org/openrewrite/RecipeOrigin.kt index d3d8b7e..8f57d27 100755 --- a/src/main/kotlin/org/openrewrite/RecipeOrigin.kt +++ b/src/main/kotlin/org/openrewrite/RecipeOrigin.kt @@ -18,7 +18,7 @@ class RecipeOrigin( fun isFromCoreLibrary() = groupId == "org.openrewrite" && coreLibs.contains(artifactId) private fun convertNameToJavaPath(recipeName: String): String = - recipeName.replace('.', '/').removeSuffix("Recipe") + ".java" + recipeName.replace('.', '/').replace(Regex("Recipes\\$?.*"), "") + ".java" fun githubUrl(recipeName: String, source: URI): String { val sourceString = source.toString() diff --git a/src/test/kotlin/org/openrewrite/RecipeOriginTest.kt b/src/test/kotlin/org/openrewrite/RecipeOriginTest.kt new file mode 100644 index 0000000..7fc77a9 --- /dev/null +++ b/src/test/kotlin/org/openrewrite/RecipeOriginTest.kt @@ -0,0 +1,21 @@ +package org.openrewrite + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import java.net.URI + +class RecipeOriginTest { + @Test + fun githubUrl() { + val githubUrl = RecipeOrigin( + "org.openrewrite.recipe", "rewrite-migrate-java", "2.4.2", URI.create("file:///tmp/foo") + ).githubUrl( + "org.openrewrite.java.migrate.apache.commons.lang.ApacheCommonsStringUtilsRecipes\$AbbreviateRecipe", + URI("https://github.com") + ) + assertEquals( + "https://github.com/openrewrite/rewrite-migrate-java/blob/main/src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java", + githubUrl + ) + } +} \ No newline at end of file From 2288bc713b80d5ecaeca26361c9450b34d9ecfb4 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 14 Dec 2023 18:30:31 +0100 Subject: [PATCH 2/3] Also link the individual case correctly --- src/main/kotlin/org/openrewrite/RecipeOrigin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/org/openrewrite/RecipeOrigin.kt b/src/main/kotlin/org/openrewrite/RecipeOrigin.kt index 8f57d27..e9fa255 100755 --- a/src/main/kotlin/org/openrewrite/RecipeOrigin.kt +++ b/src/main/kotlin/org/openrewrite/RecipeOrigin.kt @@ -18,7 +18,7 @@ class RecipeOrigin( fun isFromCoreLibrary() = groupId == "org.openrewrite" && coreLibs.contains(artifactId) private fun convertNameToJavaPath(recipeName: String): String = - recipeName.replace('.', '/').replace(Regex("Recipes\\$?.*"), "") + ".java" + recipeName.replace('.', '/').replace(Regex("Recipes?\\$?.*"), "") + ".java" fun githubUrl(recipeName: String, source: URI): String { val sourceString = source.toString() From c98068e81ea69f899955207e6e1146f010340261 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 14 Dec 2023 18:35:33 +0100 Subject: [PATCH 3/3] Run check in CI as well --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 41a6576..4ebb27a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -34,7 +34,7 @@ jobs: - name: build uses: gradle/gradle-build-action@v2 with: - arguments: ${{ env.GRADLE_SWITCHES }} markdownToHtml + arguments: ${{ env.GRADLE_SWITCHES }} check markdownToHtml - name: Create index.html run: cp build/html/SUMMARY_snippet.html build/html/index.html