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

Use maven embedder #68

Draft
wants to merge 76 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
bcab57a
Extract test helper module
fabapp2 Mar 18, 2024
6edd20d
Cloned MavenCli compiles
fabapp2 Feb 8, 2024
e97d2a9
It seems to build a Maven project
fabapp2 Feb 8, 2024
1a415ba
here we go...
fabapp2 Feb 8, 2024
2cb3d1d
Project builds with custom MavenCi and events are listened to
fabapp2 Feb 9, 2024
91e0a94
Remove methods not required anymore
fabapp2 Feb 9, 2024
3c5c011
Successfully creates MavenMojoProjectParser
fabapp2 Feb 9, 2024
0fcff35
Replaced reflection with setter
fabapp2 Feb 9, 2024
6a372ac
Remove tests
fabapp2 Feb 9, 2024
a7eaa6e
Cleanup
fabapp2 Feb 9, 2024
ba17f27
Comment
fabapp2 Feb 9, 2024
32cf76a
Comment
fabapp2 Feb 9, 2024
3afc9f8
Comment
fabapp2 Feb 9, 2024
50f16d3
Cleanup
fabapp2 Feb 9, 2024
ee64fee
Cleanup
fabapp2 Feb 9, 2024
5129a92
Runs inside Spring Boot application
fabapp2 Feb 9, 2024
f05adbc
Move testcode into module
fabapp2 Feb 19, 2024
938ef6a
Test that settings are read
fabapp2 Feb 19, 2024
eaeb6f1
WIP
fabapp2 Feb 20, 2024
4e28119
Add test
fabapp2 Feb 20, 2024
221423a
Rename module
fabapp2 Feb 20, 2024
4fdef37
Rename module and add to reactor
fabapp2 Feb 20, 2024
175c66b
Add name to pom
fabapp2 Feb 20, 2024
a15004d
Format code
fabapp2 Feb 20, 2024
7bbfa2c
Introduce maven embedder to launcher
fabapp2 Feb 20, 2024
e8a875f
Format Java
fabapp2 Feb 21, 2024
c55a19b
Adjust limitations section in docs
fabapp2 Feb 21, 2024
d882df6
Remove unrelated docs
fabapp2 Feb 21, 2024
4c68ad1
Fix comment
fabapp2 Feb 21, 2024
1e24718
Replace deprecated class
fabapp2 Feb 21, 2024
7df7c0a
Retrieve PlexusContainer from Maven Session
fabapp2 Feb 21, 2024
c3d8c33
Remove default profile
fabapp2 Feb 21, 2024
5224dab
Format Java
fabapp2 Feb 21, 2024
c9b387d
Remove outdated MavenExecutor
fabapp2 Feb 21, 2024
779669a
Remove obsolete classes
fabapp2 Feb 21, 2024
7e3120c
Format Java
fabapp2 Feb 21, 2024
50abe34
Use soft assertions again
fabapp2 Feb 21, 2024
6a638c3
Add another OpenRewriteProjectParser reusing as much as possible
fabapp2 Feb 21, 2024
42b28d0
Format Java
fabapp2 Feb 22, 2024
8568e5c
License header
fabapp2 Feb 22, 2024
d0d3eba
Format Java
fabapp2 Feb 22, 2024
b5eb2f2
Fix tests
fabapp2 Feb 22, 2024
0a07ab8
Fix test, parsing in parallel not possible anymore
fabapp2 Feb 22, 2024
5933a36
Inject ArtifactDownloader
fabapp2 Feb 22, 2024
44b7a95
Fix Maven event handling for multi module projects
fabapp2 Feb 22, 2024
cce916b
Format Java
fabapp2 Feb 22, 2024
a39c53e
Use softAssertion
fabapp2 Feb 22, 2024
59f93cc
Fix dependency versions
fabapp2 Feb 22, 2024
6d0b606
MavenExecutor does not resolve dependencies in reactor build
fabapp2 Feb 22, 2024
a4811c6
Rename package
fabapp2 Feb 22, 2024
ea590f0
Fix test
fabapp2 Feb 22, 2024
28a6e80
Rename test
fabapp2 Feb 22, 2024
cee971d
Bump maven-embedder
fabapp2 Feb 22, 2024
0171aaf
USe Boot version property form root
fabapp2 Feb 22, 2024
90c8660
Use new parser in tests as comparing parser
fabapp2 Feb 23, 2024
ace559a
Use MavenInvoker to see if the dependencies are resolved.
fabapp2 Feb 23, 2024
1c27fa8
Fix MavenProject mapping
fabapp2 Feb 23, 2024
e8f3540
Add rewrite bom
fabapp2 Feb 23, 2024
97010c9
Format Java
fabapp2 Feb 23, 2024
ab01d3d
Remove version conflicts
fabapp2 Feb 23, 2024
85c46ec
Unified Maven dependency versions
fabapp2 Feb 26, 2024
a6f00f3
Add original author
fabapp2 Feb 26, 2024
de6bc91
Wip
fabapp2 Feb 28, 2024
65046fb
README
fabapp2 Mar 5, 2024
df3b532
Format
fabapp2 Mar 6, 2024
fb91a75
Make build (use-maven-embedder)
fabapp2 Mar 18, 2024
fac2030
Adjust API call
fabapp2 Mar 19, 2024
3f92c5b
Use dynamic port in test
fabapp2 Mar 22, 2024
e4c796a
Remove MavenProjectAnalyzer
fabapp2 Mar 22, 2024
1925e04
Fix test
fabapp2 Mar 22, 2024
8b44485
Fix execution listener in MavenInvoker
fabapp2 Mar 22, 2024
c78d86f
Add scope to dep
fabapp2 Mar 22, 2024
4fcf7d0
Add code to test project
fabapp2 Mar 22, 2024
5d7e39e
Use RuntimeInformation from Maven
fabapp2 Mar 22, 2024
4244f98
Fix tst project
fabapp2 Mar 22, 2024
0d535c4
Add info to println
fabapp2 Mar 25, 2024
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
50 changes: 50 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,56 @@ ____
compile 'org.springframework.rewrite:spring-rewrite-commons-launcher:{projectVersion}'
----

=== Select Parser
Currently, different ways to parse projects and execute recipes exist.
They all fulfill specific needs or fill gaps of other implementations.

==== `RewriteProjectParser`
WARNING: This implementation is affected by <ADD ISSUE HERE>.

Use MavenCli to parse a Maven project and a customized parser to create the OpenRewrite LST.
This implementation allows for customizations and provides access to OpenRewrite LST.

==== `OpenRewriteProjectParser`
WARNING: This implementation is affected by <ADD ISSUE HERE> and <ADD ISSUE HERE>.

Use MavenCli to parse Maven projects and instantiate OpenRewrite's `MAvenMojoProjectParser`.
The parser provides access to OpenRewrite's LST.
This implementation uses as much code as possible from OpenRewrite and Maven being the closest to the execution of OpenRewrite recipes inside OR's Maven plugin.

==== `OpenRewriteRecipeLauncher`
Use Maven Invoker to run OpenRewrite recipes in a separate process like from command line but started from inside a Java application.
It


[plantuml,"models",svg]
.....

class OpenRewritePluginLauncher

class RewriteProjectParser

class FlexRewriteProjectParser

class ProjectResourceSet

component srcMaven as "src-maven" {
component srcMavenInvoker as "src-maven-invoker" {
}
component srcMavenEmbedder as "src-maven-embedder" {
}
}

component srcGradle as "src-gradle" {
component srcGradleModel as "src-gradle-model" {
}
component srcGradleParser as "src-gradle-parser" {
}
component srcGradlePlugin as "src-gradle-plugin" {
}
}
}
.....

=== Implement a Recipe Launcher

Expand Down
141 changes: 136 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<module>spring-rewrite-commons-starters</module>
<module>spring-rewrite-commons-gradle</module>
<module>spring-rewrite-commons-plugin-invoker</module>
<module>spring-rewrite-commons-test</module>
<module>spring-rewrite-commons-utils</module>
<module>spring-rewrite-commons-maven-embedder</module>
</modules>

<organization>
Expand All @@ -33,19 +36,20 @@
<!-- prod dependencies -->
<spring-boot.version>3.2.1</spring-boot.version>
<rewrite.version>8.13.4</rewrite.version>
<rewrite-kotlin.version>1.8.4</rewrite-kotlin.version>
<rewrite-polyglot.version>1.8.11</rewrite-polyglot.version>
<rewrite-kotlin.version>1.10.0</rewrite-kotlin.version>
<rewrite-polyglot.version>1.9.2</rewrite-polyglot.version>
<rewrite-maven-plugin.version>5.20.0</rewrite-maven-plugin.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<gradle-tooling-api.version>8.4</gradle-tooling-api.version>
<maven.version>3.9.1</maven.version>
<maven.version>3.9.6</maven.version>
<maven-invoker.version>3.2.0</maven-invoker.version>
<maven-shared-utils.version>3.4.2</maven-shared-utils.version>

<!-- testing dependencies -->
<maven-resolver.version>1.9.13</maven-resolver.version>
<maven-resolver.version>1.9.18</maven-resolver.version>
<maven-embedder.version>3.9.6</maven-embedder.version>
<maven-wagon-http.version>3.5.3</maven-wagon-http.version>
<plexus-cypher.version>1.8</plexus-cypher.version>
<plexus-cypher.version>2.0</plexus-cypher.version>
<junit-pioneer.version>2.1.0</junit-pioneer.version>

<!-- documentation dependencies -->
Expand Down Expand Up @@ -129,9 +133,75 @@
<artifactId>rewrite-core</artifactId>
<version>${rewrite.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.rewrite</groupId>
<artifactId>spring-rewrite-commons-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>${maven-embedder.version}</version> <!-- Use the latest version available -->
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</exclusion>
<!-- org.apache.maven:maven-embedder:jar:3.9.6 brings maven-shared-utils:3.3.4 while 3.4.2 is right -->
<exclusion>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-cipher</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>${maven-invoker.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<exclusions>
<!--
[ERROR] Dependency convergence error for org.apache.maven.shared:maven-shared-utils:jar:3.4.2 paths to dependency are:
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-plugin-invoker-maven:jar:0.1.0-SNAPSHOT
[ERROR] +-org.apache.maven.shared:maven-shared-utils:jar:3.4.2:compile
[ERROR] and
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-plugin-invoker-maven:jar:0.1.0-SNAPSHOT
[ERROR] +-org.apache.maven:maven-compat:jar:3.9.6:compile
[ERROR] +-org.apache.maven:maven-core:jar:3.9.6:compile
[ERROR] +-org.apache.maven.shared:maven-shared-utils:jar:3.3.4:compile
-->
<exclusion>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-bom</artifactId>
<version>${rewrite.version}</version>
<type>pom</type>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -239,6 +309,7 @@ limitations under the License.
<!-- @formatter:on -->
</inlineHeader>
<excludes>
<exclude>**/CLIReportingUtils.java</exclude>
<exclude>**/internal/**</exclude>
<exclude>**/demo/**</exclude>
<exclude>**/.sdkmanrc</exclude>
Expand Down Expand Up @@ -272,6 +343,66 @@ limitations under the License.
</licenseSets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<dependencyConvergence>
<excludes>
<exclude>org.jetbrains:annotations</exclude>
<exclude>org.ow2.asm:asm</exclude> <!-- through org.openrewrite.maven:rewrite-maven-plugin:jar:5.20.0:compile -->
<!--
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-maven-embedder:jar:0.1.0-SNAPSHOT
[ERROR] +-org.apache.maven:maven-embedder:jar:3.9.3:compile
[ERROR] +-javax.annotation:javax.annotation-api:jar:1.3.2:compile
[ERROR] and
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-maven-embedder:jar:0.1.0-SNAPSHOT
[ERROR] +-org.apache.maven:maven-embedder:jar:3.9.3:compile
[ERROR] +-org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.5:compile
[ERROR] +-javax.annotation:javax.annotation-api:jar:1.2:compile
-->
<exclude>javax.annotation:javax.annotation-api</exclude>
<!--

-->
<exclude>org.codehaus.plexus:plexus-utils</exclude>
<exclude>org.codehaus.plexus:plexus-classworlds</exclude>
<exclude>com.google.guava:guava</exclude> <!-- from org.apache.maven:maven-embedder -->
<exclude>org.xerial.snappy:snappy-java</exclude> <!-- from org.openrewrite.maven:rewrite-maven-plugin -->
<exclude>org.ow2.asm:asm-util</exclude> <!-- from org.openrewrite:rewrite-java -->
<!--
[ERROR] Dependency convergence error for commons-io:commons-io:jar:2.11.0 paths to dependency are:
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-starter-boot-upgrade:jar:0.1.0-SNAPSHOT
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-launcher:jar:0.1.0-SNAPSHOT:compile
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-test:jar:0.1.0-SNAPSHOT:compile
[ERROR] +-commons-io:commons-io:jar:2.11.0:compile
[ERROR] and
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-starter-boot-upgrade:jar:0.1.0-SNAPSHOT
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-launcher:jar:0.1.0-SNAPSHOT:compile
[ERROR] +-org.openrewrite.maven:rewrite-maven-plugin:jar:5.20.0:compile
[ERROR] +-org.apache.maven.shared:maven-filtering:jar:3.3.1:compile
[ERROR] +-commons-io:commons-io:jar:2.11.0:compile
[ERROR] and
[ERROR] +-org.springframework.rewrite:spring-rewrite-commons-starter-boot-upgrade:jar:0.1.0-SNAPSHOT
[ERROR] +-org.openrewrite.recipe:rewrite-migrate-java:jar:2.7.1:compile
[ERROR] +-commons-io:commons-io:jar:2.15.1:compile
-->
<exclude>commons-io:commons-io</exclude>
</excludes>
</dependencyConvergence>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ All examples can be found file://spring-rewrite-commons-examples[here].
== Limitations
The project has currently some limitations.

. Only JDK 17 supported and required
. No Gradle support. +
OpenRewrite provides a build tool plugin for Gradle projects.
This project currently only parses Maven projects.
. No Kotlin support. +
OpenRewrite can parse other languages than Java, especially Kotlin. This is not yet supported.
. Inherited version will just be read from direct parent. Meaning a version from a parent with distance > 1 will be empty (`null`)
. Maven profiles are currently ignored and 'default' profile is used
. Styles are not supported +
OpenRewrite styles are currently not supported.
. Migrating projects for Maven plugins might fail +
Maven plugin projects (modules) are currently ignored when building the reactor order.
. JDK 17 is a requirement
. Kotlin is not supported.
. Styles are not supported
. Migrating projects for Maven plugins might fail
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ The `RewriteProjectParser`
== Test Helper

=== TestProjectHelper

The `TestProjectHelper` allows reading test projects from disk or to create them in memory.

==== Clone a Git Repository
[source,java]
....

.toAbsolutePath().normalize();
TestProjectHelper.createTestProject(projectRoot)
.deleteDirIfExists()
.cloneGitProject("https://github.com/corona-warn-app/cwa-server.git")
.checkoutTag("v3.2.0")
.writeToFilesystem();
....

==== Read a project from testcode dir

Projects used for testing can be provided in a `testcode` directory.
Maven projects are read from `testcode/maven-projects`.

Example: Get Path to `./testcode/maven-projects/my-test-project`:
[source, java]
....
Path baseDir = TestProjectHelper.TestProjectHelper.getMavenProject("my-test-project");
....

=== ParserParityTestHelper
=== ParserExecutionHelper
=== RewriteMavenProjectParser
15 changes: 0 additions & 15 deletions spring-rewrite-commons-docs/src/main/asciidoc/aiclient.adoc

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions spring-rewrite-commons-docs/src/main/asciidoc/domain.adoc

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions spring-rewrite-commons-docs/src/main/asciidoc/glossary.adoc

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions spring-rewrite-commons-docs/src/main/asciidoc/index-single.adoc

This file was deleted.

Loading
Loading