forked from openrewrite/rewrite-recipe-markdown-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
188 lines (163 loc) · 8.11 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import org.kordamp.gradle.plugin.markdown.tasks.MarkdownToHtmlTask
plugins {
application
id("org.jetbrains.kotlin.jvm").version("1.7.20")
id("org.owasp.dependencycheck") version "7.0.4.1"
id("org.kordamp.gradle.markdown") version "2.2.0"
}
dependencyCheck {
analyzers.assemblyEnabled = false
failBuildOnCVSS = 9.0F
suppressionFile = "suppressions.xml"
scanConfigurations = listOf("runtimeClasspath")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenLocal()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
mavenCentral()
gradlePluginPortal()
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor(0, TimeUnit.SECONDS)
cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
}
}
val recipeConf = configurations.create("recipe")
// Either `latest.release` or `latest.integration`
val rewriteVersion = "latest.release"
// Used to determine what type of changelog to build up.
// * "release" : When making a changelog for larger releases of OpenRewrite
// * "snapshot" : When making a changelog for snapshot releases on a weekly cadence.
// * "diff" : When making a diff-log for what recipes are made over time.
val deployType = "release"
// When you set the above to diff, this will be the name of the markdown file generated
val diffFileName = "desjardins"
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("info.picocli:picocli:latest.release")
implementation("org.openrewrite:rewrite-core:$rewriteVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2")
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")
"recipe"("org.openrewrite:rewrite-gradle")
"recipe"("org.openrewrite:rewrite-hcl")
"recipe"("org.openrewrite:rewrite-java")
"recipe"("org.openrewrite:rewrite-json")
"recipe"("org.openrewrite:rewrite-maven")
"recipe"("org.openrewrite:rewrite-properties")
"recipe"("org.openrewrite:rewrite-protobuf")
"recipe"("org.openrewrite:rewrite-xml")
"recipe"("org.openrewrite:rewrite-yaml")
"recipe"("org.openrewrite:rewrite-java-test")
// "recipe"("org.openrewrite:rewrite-csharp:$rewriteVersion")
// "recipe"("org.openrewrite:rewrite-javascript:$rewriteVersion")
"recipe"("org.openrewrite:rewrite-kotlin:$rewriteVersion")
// "recipe"("org.openrewrite:rewrite-python:$rewriteVersion") // Removed based on Olga request
// "recipe"("org.openrewrite:rewrite-ruby:$rewriteVersion")
// "recipe"("org.openrewrite.recipe:rewrite-all:$rewriteVersion") // Exclude language composition data table recipes
"recipe"("org.openrewrite.meta:rewrite-analysis:$rewriteVersion")
// "recipe"("org.openrewrite.recipe:rewrite-ai-search:$rewriteVersion") Needs further attention
"recipe"("org.openrewrite.recipe:rewrite-apache:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-circleci:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-cloud-suitability-analyzer:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-concourse:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-cucumber-jvm:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-github-actions:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-hibernate:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-java-dependencies:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-java-security:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-jenkins:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-kubernetes:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-liberty:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-launchdarkly:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-logging-frameworks:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-micrometer:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-micronaut:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-migrate-java:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-nodejs:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-okhttp:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-openapi:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-quarkus:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-recommendations:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-spring:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-sql:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-static-analysis:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-struts:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-terraform:$rewriteVersion")
"recipe"("org.openrewrite.recipe:rewrite-testing-frameworks:$rewriteVersion")
// "recipe"("org.openrewrite.recipe:rewrite-third-party:$rewriteVersion") Needs further attention
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.named<JavaCompile>("compileJava") {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}
tasks.withType<Test> {
useJUnitPlatform()
}
application {
mainClass.set("org.openrewrite.RecipeMarkdownGenerator")
}
tasks.named<JavaExec>("run").configure {
val targetDir = File(project.buildDir, "docs")
// Collect all of the dependencies from recipeConf, then stuff them into a string representation
val recipeModules = recipeConf.resolvedConfiguration.firstLevelModuleDependencies.flatMap { dep ->
dep.moduleArtifacts.map { artifact ->
"${dep.moduleGroup}:${dep.moduleName}:${dep.moduleVersion}:${artifact.file}"
}
}.joinToString(";")
// recipeModules doesn't include transitive dependencies, but those are needed to load recipes and their descriptors
val recipeClasspath = recipeConf.resolvedConfiguration.files.asSequence()
.map { it.absolutePath }
.joinToString(";")
val gradlePluginVersion = configurations.detachedConfiguration(dependencies.create("org.openrewrite:plugin:latest.release"))
.resolvedConfiguration
.firstLevelModuleDependencies
.first()
.moduleVersion
val mavenPluginVersion = configurations.detachedConfiguration(dependencies.create("org.openrewrite.maven:rewrite-maven-plugin:latest.release"))
.resolvedConfiguration
.firstLevelModuleDependencies
.first()
.moduleVersion
description = "Writes generated markdown docs to $targetDir"
args = listOf(targetDir.toString(), recipeModules, recipeClasspath, gradlePluginVersion, mavenPluginVersion, deployType, diffFileName)
doFirst {
logger.lifecycle("Recipe modules: ")
logger.lifecycle(recipeModules)
// Ensure no stale output from previous runs is in the output directory
targetDir.deleteRecursively()
targetDir.mkdirs()
}
doLast {
this as JavaExec
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION") // IntelliJ says this is unnecessary, kotlin compiler disagrees
logger.lifecycle("Wrote generated docs to: file://${args!!.first()}")
}
}
defaultTasks = mutableListOf("run")
tasks.withType<MarkdownToHtmlTask> {
dependsOn("run")
sourceDir = file("build/docs")
outputDir = file("build/html")
fencedCodeBlocks = true
tables = true
doLast {
this as MarkdownToHtmlTask
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION") // IntelliJ says this is unnecessary, kotlin compiler disagrees
logger.lifecycle("Wrote generated html to: file://${outputDir}")
}
}