Skip to content

Commit

Permalink
Correctly link refaster recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 14, 2023
1 parent dc2ecd2 commit 1299399
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -111,6 +114,10 @@ tasks.named<JavaCompile>("compileJava") {
targetCompatibility = JavaVersion.VERSION_17.toString()
}

tasks.withType<Test> {
useJUnitPlatform()
}

application {
mainClass.set("org.openrewrite.RecipeMarkdownGenerator")
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/openrewrite/RecipeOrigin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
21 changes: 21 additions & 0 deletions src/test/kotlin/org/openrewrite/RecipeOriginTest.kt
Original file line number Diff line number Diff line change
@@ -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
)
}
}

0 comments on commit 1299399

Please sign in to comment.