Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly link refaster recipes #92

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
)
}
}