diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f154a8f5..d4e11f4d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,7 +29,7 @@ jobs: - name: bump-rewrite-properties-to-releases run: | - ./mvnw versions:update-properties -DincludeProperties=rewrite.version,rewrite.python.version -DallowDowngrade=true + ./mvnw versions:update-properties -DincludeProperties=rewrite.version,rewrite.all.version,rewrite.python.version -DallowDowngrade=true git diff-index --quiet HEAD pom.xml || git commit -m "Bump rewrite.version properties" pom.xml && rm -f pom.xml.versionsBackup - name: publish-release diff --git a/pom.xml b/pom.xml index 8179bdc4..d16916fb 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,7 @@ 8.2.0-SNAPSHOT + 1.1.0-SNAPSHOT 1.1.0-SNAPSHOT @@ -159,6 +160,11 @@ + + org.openrewrite.recipe + rewrite-all + ${rewrite.all.version} + org.openrewrite rewrite-java diff --git a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java index 14b8a734..e0edcd98 100644 --- a/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java +++ b/src/main/java/org/openrewrite/maven/AbstractRewriteMojo.java @@ -39,7 +39,10 @@ import org.openrewrite.ipc.http.HttpUrlConnectionSender; import org.openrewrite.java.tree.JavaSourceFile; import org.openrewrite.marker.*; +import org.openrewrite.maven.ux.MavenLogProgressBar; +import org.openrewrite.maven.ux.ProgressBarParsingEventListener; import org.openrewrite.style.NamedStyles; +import org.openrewrite.tree.ParsingExecutionContextView; import org.openrewrite.xml.tree.Xml; import java.io.File; @@ -141,7 +144,10 @@ protected Environment environment(@Nullable ClassLoader recipeClassLoader) throw } protected ExecutionContext executionContext() { - return new InMemoryExecutionContext(t -> getLog().debug(t)); + InMemoryExecutionContext ctx = new InMemoryExecutionContext(t -> getLog().debug(t)); + ParsingExecutionContextView view = ParsingExecutionContextView.view(ctx); + view.setParsingListener(new ProgressBarParsingEventListener(new MavenLogProgressBar(getLog()))); + return view; } protected Path getBuildRoot() { diff --git a/src/main/java/org/openrewrite/maven/ux/MavenLogProgressBar.java b/src/main/java/org/openrewrite/maven/ux/MavenLogProgressBar.java new file mode 100644 index 00000000..5615ce6d --- /dev/null +++ b/src/main/java/org/openrewrite/maven/ux/MavenLogProgressBar.java @@ -0,0 +1,47 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.maven.ux; + +import org.apache.maven.plugin.logging.Log; +import org.openrewrite.NoopProgressBar; +import org.openrewrite.ProgressBar; +import org.openrewrite.internal.lang.Nullable; + +public class MavenLogProgressBar extends NoopProgressBar { + + private final Log log; + + public MavenLogProgressBar(Log log) { + this.log = log; + } + + @Override + public ProgressBar setExtraMessage(String extraMessage) { + log.info(extraMessage); + return this; + } + + @Override + public void intermediateResult(@Nullable String message) { + log.debug(message); + } + + @Override + public void finish(String message) { + log.info(message); + } + +} diff --git a/src/main/java/org/openrewrite/maven/ux/ProgressBarParsingEventListener.java b/src/main/java/org/openrewrite/maven/ux/ProgressBarParsingEventListener.java new file mode 100644 index 00000000..3b02c227 --- /dev/null +++ b/src/main/java/org/openrewrite/maven/ux/ProgressBarParsingEventListener.java @@ -0,0 +1,35 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.maven.ux; + +import org.openrewrite.Parser; +import org.openrewrite.ProgressBar; +import org.openrewrite.SourceFile; +import org.openrewrite.tree.ParsingEventListener; + +public class ProgressBarParsingEventListener implements ParsingEventListener { + + private final ProgressBar progressBar; + + public ProgressBarParsingEventListener(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + @Override + public void parsed(Parser.Input input, SourceFile sourceFile) { + progressBar.intermediateResult("Parsed " + input.getPath()); + } +}