Skip to content

Commit c97f179

Browse files
authored
Independent Gradle Project Parser via GradleProjectData model (#874)
* Independent Gradle Project Parser via GradleProjectData model * Gradle Parser included
1 parent e8fcb8d commit c97f179

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2429
-0
lines changed
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
* text eol=lf
2+
3+
#
4+
# The above will handle all files NOT found below
5+
# https://help.github.com/articles/dealing-with-line-endings/
6+
# https://github.com/Danimoth/gitattributes
7+
8+
# These are explicitly windows files and should use crlf
9+
*.bat text eol=crlf
10+
11+
# These files are text and should be normalized (Convert crlf => lf)
12+
*.bash text eol=lf
13+
*.css text diff=css
14+
*.htm text diff=html
15+
*.html text diff=html
16+
*.java text diff=java
17+
*.sh text eol=lf
18+
19+
20+
# These files are binary and should be left untouched
21+
# (binary is a macro for -text -diff)
22+
*.a binary
23+
*.lib binary
24+
*.icns binary
25+
*.png binary
26+
*.jpg binary
27+
*.jpeg binary
28+
*.gif binary
29+
*.ico binary
30+
*.mov binary
31+
*.mp4 binary
32+
*.mp3 binary
33+
*.flv binary
34+
*.fla binary
35+
*.swf binary
36+
*.gz binary
37+
*.zip binary
38+
*.jar binary
39+
*.tar binary
40+
*.tar.gz binary
41+
*.7z binary
42+
*.ttf binary
43+
*.pyc binary
44+
*.gpg binary
45+
*.bin binary
46+
*.exe binary
47+
*.dll binary
48+
*.so binary
49+
*.dylib binary
50+
*.class binary
51+
*.jar binary
52+
*.war binary
53+
*.ear binary
54+
*.rar binary

sbm-gradle-tooling-model/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
.gradle/
3+
out/
4+
.idea/
5+
/spring-petclinic/

sbm-gradle-tooling-model/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SBM Gradle Project Parser
2+
The project consists of modules:
3+
- **model** - Defines data structures to be pulled from Gradle Build process via Gradle Tooling API. Also contains utility to query Gradle Build process for a specific model type
4+
- **plugin** - Registers the `GradelProject` data model builder and has logic for creating a serializable instance of the `GradleProjectData`
5+
- **parser** - Defines a `GradelProjectParser` which delegates to `DefaultProjectParser` which is very close to Rewrite's `org.openrewrite.gradle.isolated.DefaultProjectParser`which takes `GradleProjectData` obtained from **model** via **plugin** project as a parameter.
6+
7+
Use the `GradelProjectParser` as follows:
8+
```java
9+
GradleProjectParser.parse(new File("/Users/aboyko/Documents/STS4-arm/spring-petclinic"), new File("/Users/aboyko/Documents/STS4-arm/spring-petclinic/build.gradle"), new InMemoryExecutionContext(), new DefaultParserConfig()).collect(Collectors.toList());
10+
```
11+
Parameters:
12+
1. Project root folder
13+
2. Project build script file
14+
3. Rewrite's `ExecutionContext`
15+
4. `ParserConfig` object. (Typically one would use `DefaultParserConfig`)
16+
17+
Before making references to the project and using it as a library it is required to build it:
18+
```bash
19+
./gradlew clean build publishToMavenLocal
20+
```
21+
(It is important to publish to maven local such that when **model** project quries gradle process for the model the plugin is present in the local maven repo)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id("org.openrewrite.build.root") version("latest.release")
3+
}
4+
5+
6+
allprojects {
7+
group = "org.springframework.sbm.gradle.tooling"
8+
description = "A model for extracting semantic information out of Gradle build files necessary for refactoring them."
9+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
bin/
17+
!**/src/main/**/bin/
18+
!**/src/test/**/bin/
19+
20+
### IntelliJ IDEA ###
21+
.idea
22+
*.iws
23+
*.iml
24+
*.ipr
25+
out/
26+
!**/src/main/**/out/
27+
!**/src/test/**/out/
28+
29+
### NetBeans ###
30+
/nbproject/private/
31+
/nbbuild/
32+
/dist/
33+
/nbdist/
34+
/.nb-gradle/
35+
36+
### VS Code ###
37+
.vscode/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
java
3+
id("org.springframework.boot") version "3.1.2"
4+
id("io.spring.dependency-management") version "1.1.2"
5+
}
6+
7+
group = "com.example"
8+
version = "0.0.1-SNAPSHOT"
9+
10+
java {
11+
sourceCompatibility = JavaVersion.VERSION_17
12+
}
13+
14+
repositories {
15+
mavenCentral()
16+
}
17+
18+
dependencies {
19+
implementation("org.springframework.boot:spring-boot-starter")
20+
testImplementation("org.springframework.boot:spring-boot-starter-test")
21+
}
22+
23+
tasks.withType<Test> {
24+
useJUnitPlatform()
25+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)