Skip to content

Commit 805f115

Browse files
committed
WIP: rewrite
1 parent d21c15b commit 805f115

8 files changed

Lines changed: 143 additions & 47 deletions

File tree

build-logic/jvm/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ plugins {
2222
dependencies {
2323
api(projects.buildParameters)
2424
api(projects.verification)
25+
api(projects.openrewrite)
2526
api("me.champeau.jmh:me.champeau.jmh.gradle.plugin:0.7.2")
2627
api("com.github.vlsi.crlf:com.github.vlsi.crlf.gradle.plugin:1.90")
2728
api("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.90")
2829
api("org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.22")
2930
api("org.jetbrains.kotlin.kapt:org.jetbrains.kotlin.kapt.gradle.plugin:1.9.22")
3031
api("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:1.9.10")
31-
api("org.openrewrite.rewrite:org.openrewrite.rewrite.gradle.plugin:6.6.3")
3232
}

build-logic/jvm/src/main/kotlin/build-logic.openrewrite.gradle.kts

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,56 @@
1818
import org.openrewrite.gradle.RewriteDryRunTask
1919

2020
plugins {
21-
id("org.openrewrite.rewrite")
21+
id("build-logic.openrewrite-base")
2222
}
2323

2424
dependencies {
25-
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.integration"))
26-
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
27-
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks")
25+
openrewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:latest.integration"))
26+
openrewrite("org.openrewrite.recipe:rewrite-static-analysis")
27+
openrewrite("org.openrewrite.recipe:rewrite-testing-frameworks")
2828
}
2929

30-
rewrite {
30+
openrewrite {
3131
configFile = project.rootProject.file("config/openrewrite/rewrite.yml")
32-
// See RewriteDryRunTask workaround below
33-
failOnDryRunResults = false
34-
35-
activeStyle("org.apache.jmeter.style.Style")
36-
37-
// See config/openrewrite/rewrite.yml
38-
activeRecipe("org.apache.jmeter.staticanalysis.CodeCleanup")
39-
// See https://github.com/openrewrite/rewrite-static-analysis/blob/8c803a9c50b480841a4af031f60bac5ee443eb4e/src/main/resources/META-INF/rewrite/common-static-analysis.yml#L21
40-
activeRecipe("org.apache.jmeter.staticanalysis.CommonStaticAnalysis")
41-
plugins.withId("build-logic.test-junit5") {
42-
// See https://github.com/openrewrite/rewrite-testing-frameworks/blob/47ccd370247f1171fa9df005da8a9a3342d19f3f/src/main/resources/META-INF/rewrite/junit5.yml#L18C7-L18C62
43-
activeRecipe("org.openrewrite.java.testing.junit5.JUnit5BestPractices")
44-
// See https://github.com/openrewrite/rewrite-testing-frameworks/blob/47ccd370247f1171fa9df005da8a9a3342d19f3f/src/main/resources/META-INF/rewrite/junit5.yml#L255C7-L255C60
45-
activeRecipe("org.openrewrite.java.testing.junit5.CleanupAssertions")
46-
}
47-
}
48-
49-
// See https://github.com/openrewrite/rewrite-gradle-plugin/issues/255
50-
tasks.withType<RewriteDryRunTask>().configureEach {
51-
doFirst {
52-
if (reportPath.exists()) {
53-
// RewriteDryRunTask keeps the report file if there are no violations, so we remove it
54-
reportPath.delete()
55-
}
56-
}
57-
doLast {
58-
if (reportPath.exists()) {
59-
throw GradleException(
60-
"The following files have format violations. " +
61-
"Execute ./gradlew ${path.replace("Dry", "")} to apply the changes:\n" +
62-
reportPath.readText()
63-
)
64-
}
65-
}
32+
activeStyles += "org.apache.jmeter.style.Style"
6633
}
34+
//rewrite {
35+
//
36+
//}
37+
//rewrite {
38+
// configFile = project.rootProject.file("config/openrewrite/rewrite.yml")
39+
// // See RewriteDryRunTask workaround below
40+
// failOnDryRunResults = false
41+
//
42+
// activeStyle("org.apache.jmeter.style.Style")
43+
//
44+
// // See config/openrewrite/rewrite.yml
45+
// activeRecipe("org.apache.jmeter.staticanalysis.CodeCleanup")
46+
// // See https://github.com/openrewrite/rewrite-static-analysis/blob/8c803a9c50b480841a4af031f60bac5ee443eb4e/src/main/resources/META-INF/rewrite/common-static-analysis.yml#L21
47+
// activeRecipe("org.apache.jmeter.staticanalysis.CommonStaticAnalysis")
48+
// plugins.withId("build-logic.test-junit5") {
49+
// // See https://github.com/openrewrite/rewrite-testing-frameworks/blob/47ccd370247f1171fa9df005da8a9a3342d19f3f/src/main/resources/META-INF/rewrite/junit5.yml#L18C7-L18C62
50+
// activeRecipe("org.openrewrite.java.testing.junit5.JUnit5BestPractices")
51+
// // See https://github.com/openrewrite/rewrite-testing-frameworks/blob/47ccd370247f1171fa9df005da8a9a3342d19f3f/src/main/resources/META-INF/rewrite/junit5.yml#L255C7-L255C60
52+
// activeRecipe("org.openrewrite.java.testing.junit5.CleanupAssertions")
53+
// }
54+
//}
55+
//
56+
//// See https://github.com/openrewrite/rewrite-gradle-plugin/issues/255
57+
//tasks.withType<RewriteDryRunTask>().configureEach {
58+
// doFirst {
59+
// if (reportPath.exists()) {
60+
// // RewriteDryRunTask keeps the report file if there are no violations, so we remove it
61+
// reportPath.delete()
62+
// }
63+
// }
64+
// doLast {
65+
// if (reportPath.exists()) {
66+
// throw GradleException(
67+
// "The following files have format violations. " +
68+
// "Execute ./gradlew ${path.replace("Dry", "")} to apply the changes:\n" +
69+
// reportPath.readText()
70+
// )
71+
// }
72+
// }
73+
//}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
plugins {
19+
id("build-logic.kotlin-dsl-gradle-plugin")
20+
}
21+
22+
dependencies {
23+
api(projects.buildParameters)
24+
api("org.openrewrite.rewrite:org.openrewrite.rewrite.gradle.plugin:6.6.3")
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import org.apache.jmeter.buildtools.openrewrite.OpenRewriteExtension
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership.
7+
* The ASF licenses this file to you under the Apache License, Version 2.0
8+
* (the "License"); you may not use this file except in compliance with
9+
* the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
val openrewrite by configurations.creating {
21+
description = "OpenRewrite dependencies"
22+
isCanBeConsumed = false
23+
isCanBeResolved = false
24+
}
25+
26+
project.extensions.create<OpenRewriteExtension>(OpenRewriteExtension.NAME)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.jmeter.buildtools.openrewrite
19+
20+
import org.gradle.api.model.ObjectFactory
21+
import org.gradle.kotlin.dsl.property
22+
import org.gradle.kotlin.dsl.setProperty
23+
import javax.inject.Inject
24+
25+
open class OpenRewriteExtension @Inject constructor(objectFactory: ObjectFactory) {
26+
companion object {
27+
const val NAME = "openrewrite"
28+
}
29+
30+
val configFile = objectFactory.fileProperty()
31+
32+
val activeStyles = objectFactory.setProperty<String>()
33+
34+
val activeRecipes = objectFactory.setProperty<String>()
35+
36+
val failOnDryRunResults = objectFactory.property<Boolean>().convention(true)
37+
}

build-logic/settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ include("basics")
4646
include("batchtest")
4747
include("build-parameters")
4848
include("jvm")
49+
include("openrewrite")
4950
include("publishing")
5051
include("root-build")
5152
include("verification")

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
org.gradle.jvmargs=-Xmx1500m -XX:MaxMetaspaceSize=768m
18+
org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=768m
1919
org.gradle.parallel=true
2020
# Build cache can be disabled with --no-build-cache option
2121
org.gradle.caching=true

src/bshclient/src/main/java/org/apache/jmeter/util/BeanShellClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public class BeanShellClient {
3636

3737
private static final int MINARGS = 3;
3838

39-
public static void main(String [] args) throws Exception{
39+
public static void main(String [] args) throws Exception {
4040
if (args.length < MINARGS){
41-
System.out.println("Please provide "+MINARGS+" or more arguments:");
41+
System.out.println("Please provide " + MINARGS + " or more arguments:");
4242
System.out.println("serverhost serverport filename [arg1 arg2 ...]");
4343
System.out.println("e.g. ");
4444
System.out.println("localhost 9000 extras/remote.bsh apple blake 7");
@@ -50,9 +50,9 @@ public static void main(String [] args) throws Exception{
5050

5151
int port=Integer.parseInt(portString)+1;// convert to telnet port
5252

53-
System.out.println("Connecting to BSH server on "+host+":"+portString);
53+
System.out.println("Connecting to BSH server on " + host + ":" + portString);
5454

55-
try (Socket sock = new Socket(host,port);
55+
try (Socket sock = new Socket(host, port);
5656
InputStream is = sock.getInputStream();
5757
OutputStream os = sock.getOutputStream()) {
5858
SockRead sockRead = new SockRead(is);
@@ -79,7 +79,7 @@ public static void main(String [] args) throws Exception{
7979
}
8080
}
8181

82-
private static void sendLine( String line, OutputStream outPipe )
82+
private static void sendLine(String line, OutputStream outPipe)
8383
throws IOException
8484
{
8585
outPipe.write(line.getBytes(StandardCharsets.UTF_8));
@@ -96,7 +96,7 @@ public SockRead(InputStream _is) {
9696

9797
@Override
9898
@SuppressWarnings("CatchAndPrintStackTrace")
99-
public void run(){
99+
public void run() {
100100
System.out.println("Reading responses from server ...");
101101
int x = 0;
102102
try {

0 commit comments

Comments
 (0)