Repository navigation
Finish implementing Gradle plugin #221
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
base: main
Are you sure you want to change the base?
Changes from all commits
d9195c7
f24b1be
e1e9dfb
7ac2d5c
c6008ff
f6f294c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # CI for the Gradle plugin (refactor-first-gradle-plugin), which is excluded from the | ||
| # Maven reactor and built with its own Gradle wrapper. | ||
| name: Gradle Plugin CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'refactor-first-gradle-plugin/**' | ||
| - 'report/**' | ||
| - '.github/workflows/gradle.yml' | ||
| pull_request: | ||
| branches: [ main ] | ||
| paths: | ||
| - 'refactor-first-gradle-plugin/**' | ||
| - 'report/**' | ||
| - '.github/workflows/gradle.yml' | ||
|
|
||
| jobs: | ||
| build: | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-latest, windows-latest ] | ||
| java-version: [ 17, 25 ] | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - name: Check out Git repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK ${{ matrix.java-version }} | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: ${{ matrix.java-version }} | ||
| distribution: 'zulu' | ||
| cache: maven | ||
|
|
||
| # setup-gradle caches the Gradle user home and validates any wrapper jars | ||
| # found in the repository (including refactor-first-gradle-plugin/gradlew). | ||
| - name: Set up Gradle | ||
| uses: gradle/actions/setup-gradle@v6 | ||
|
|
||
| # The plugin consumes the (SNAPSHOT during development) report module and its | ||
| # transitives as real jars via mavenLocal(); install them first. | ||
| - name: Install report module to Maven local | ||
| run: mvn -B -q install -DskipTests -pl report -am | ||
|
|
||
| # Guard against version drift: gradle.properties must track the Maven project version. | ||
| - name: Check gradle.properties version matches Maven project version | ||
| run: | | ||
| mvnVersion=$(grep -m1 '<version>' pom.xml | sed -E 's:\s*</?version>::g') | ||
| gradleVersion=$(grep '^refactorFirstVersion=' refactor-first-gradle-plugin/gradle.properties | cut -d= -f2-) | ||
| echo "Maven project.version=$mvnVersion, gradle.properties refactorFirstVersion=$gradleVersion" | ||
| if [ "$mvnVersion" != "$gradleVersion" ]; then | ||
| echo "FATAL: version mismatch between pom.xml and refactor-first-gradle-plugin/gradle.properties" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Build and test the Gradle plugin | ||
| working-directory: refactor-first-gradle-plugin | ||
| run: ./gradlew clean build | ||
|
Comment on lines
+21
to
+66
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,15 @@ jobs: | |
| distribution: 'temurin' | ||
| cache: maven | ||
| - name: Set release version | ||
| run: mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }} | ||
| # Gradle plugin version sync: refactor-first-gradle-plugin/gradle.properties | ||
| # (refactorFirstVersion) must be bumped to the same version in the commits | ||
| # produced by this workflow. The Gradle plugin is published separately | ||
| # (./gradlew publishPlugins, maintainer-only) and must only be published | ||
| # AFTER this workflow has landed the matching `report` artifact on Maven | ||
| # Central — the plugin jar is thin and resolves `report` at runtime. | ||
| run: | | ||
| mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }} | ||
| sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${{ github.event.inputs.version }}/" refactor-first-gradle-plugin/gradle.properties | ||
|
Comment on lines
+46
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- changed workflow hunks ---'
git diff --unified=20 16a65561ea2230e3177ae8951b1b215846bc667a f6f294c0902554af4def40fd6f8674cf10fb68ee -- .github/workflows/release.yml
printf '%s\n' '--- reviewed workflow, numbered ---'
cat -n .github/workflows/release.yml
printf '%s\n' '--- workflow file status at revisions ---'
git show --no-patch --format='%H' 16a65561ea2230e3177ae8951b1b215846bc667a
git show --no-patch --format='%H' f6f294c0902554af4def40fd6f8674cf10fb68eeRepository: refactorfirst/RefactorFirst Length of output: 10680 🤖 get_repo_knowledge executed:
Length of output: 23770 Injection Reachability: External Pass workflow inputs through
Proposed fix+ env:
+ RELEASE_VERSION: ${{ github.event.inputs.version }}
run: |
- mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.version }}
- sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${{ github.event.inputs.version }}/" refactor-first-gradle-plugin/gradle.properties
+ [[ "$RELEASE_VERSION" =~ ^[0-9A-Za-z._-]+$ ]] || { echo "Invalid version"; exit 1; }
+ mvn --no-transfer-progress --batch-mode versions:set -DnewVersion="$RELEASE_VERSION"
+ sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${RELEASE_VERSION}/" refactor-first-gradle-plugin/gradle.properties
...
+ env:
+ RELEASE_NEXT_VERSION: ${{ github.event.inputs.nextVersion }}
run: |
- mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT
- sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT/" refactor-first-gradle-plugin/gradle.properties
+ [[ "$RELEASE_NEXT_VERSION" =~ ^[0-9A-Za-z._-]+$ ]] || { echo "Invalid next version"; exit 1; }
+ mvn --no-transfer-progress --batch-mode versions:set -DnewVersion="${RELEASE_NEXT_VERSION}-SNAPSHOT"
+ sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${RELEASE_NEXT_VERSION}-SNAPSHOT/" refactor-first-gradle-plugin/gradle.properties🧰 Tools🪛 zizmor (1.30.0)[error] 46-46: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) [error] 47-47: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Commit & Push changes | ||
| uses: actions-js/push@master | ||
|
|
@@ -72,7 +80,9 @@ jobs: | |
| JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_RELEASE_DEPLOY_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD }} | ||
|
|
||
| - name: Set release version | ||
| run: mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT | ||
| run: | | ||
| mvn --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT | ||
| sed -i "s/^refactorFirstVersion=.*/refactorFirstVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT/" refactor-first-gradle-plugin/gradle.properties | ||
|
|
||
| - name: Commit & Push changes | ||
| uses: actions-js/push@master | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,9 @@ Constraints: | |||||||||
| 25 with no `--add-exports` workaround (older Spotless 2.x / | ||||||||||
| palantir-java-format builds failed on JDK 21+ without javac exports and | ||||||||||
| could not run on JDK 25 at all). | ||||||||||
| - CI (`maven.yml`, `maven-pr.yml`) builds a JDK 17 + JDK 25 matrix. | ||||||||||
| - CI (`maven.yml`, `maven-pr.yml`) builds a JDK 17 + JDK 25 matrix; the Gradle | ||||||||||
| plugin has its own workflow (`gradle.yml`) on the same JDK matrix plus | ||||||||||
| Windows. | ||||||||||
| - `CostBenefitCalculatorTest.testCostBenefitCalculation` runs on all JDKs; | ||||||||||
| its former `@DisabledOnJre(JRE.JAVA_25)` (OpenRewrite 8.90.4 fixture | ||||||||||
| failure, issue #8712 family) no longer reproduces now that | ||||||||||
|
|
@@ -114,6 +116,45 @@ back to returning the Java-only DTO with a `log.warn` | |||||||||
| (`"Kotlin analysis failed; falling back to Java-only graph"`). This fallback | ||||||||||
| is for build failures, not for "Kotlin is absent". | ||||||||||
|
|
||||||||||
| ## Gradle plugin | ||||||||||
|
|
||||||||||
| `refactor-first-gradle-plugin/` is **excluded from the Maven reactor** and built | ||||||||||
| by its own Gradle wrapper (Gradle 9.8.0 — 9.8+ required: the plugin classpath | ||||||||||
|
Comment on lines
+121
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Update the statement that the module is excluded from the Maven reactor. The root Proposed fix-`refactor-first-gradle-plugin/` is **excluded from the Maven reactor** and built
-by its own Gradle wrapper (Gradle 9.8.0 — 9.8+ required: the plugin classpath
+`refactor-first-gradle-plugin/` is a Maven reactor module whose POM invokes its
+own Gradle wrapper (Gradle 9.8.0 — 9.8+ required: the plugin classpath📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| carries the class-file-69 `rewrite-java-25` jar, whose bytecode Gradle ≤ 9.0 | ||||||||||
| cannot instrument): | ||||||||||
|
|
||||||||||
| - Build & test: `cd refactor-first-gradle-plugin && ./gradlew clean build` | ||||||||||
| - Plugin id: `org.hjug.refactorfirst`; tasks `refactorFirstHtmlReport`, | ||||||||||
| `refactorFirstSimpleHtmlReport`, `refactorFirstCsvReport`, | ||||||||||
| `refactorFirstJsonReport` (task/output contract: see | ||||||||||
| `plans/finish-pr-157-v2.md` §1; verified by `RefactorFirstPluginTest` | ||||||||||
| [ProjectBuilder] and `RefactorFirstPluginFunctionalTest` [TestKit]). | ||||||||||
| - **Thin jar — no shadow plugin, no `minimizeJar`.** The plugin resolves | ||||||||||
| `org.hjug.refactorfirst.report:report` and its transitives as real jars, so | ||||||||||
| `codebase-graph-builder`'s JEP 238 `META-INF/versions/25` entries stay intact | ||||||||||
| (shading with minimize would strip them and break Java 25 parsing). | ||||||||||
| - **No `getProject()` in `@TaskAction`** (Gradle 9 / configuration-cache | ||||||||||
| hygiene); values are captured at registration time. Tasks declare no | ||||||||||
| `@Input`/`@Output` and `getOutputs().upToDateWhen(t -> false)` — they always | ||||||||||
| run (guarded by `configurationCacheRunHasNoProblems` and `tasksRunEveryTime`). | ||||||||||
| - `refactorFirstJsonReport` must invoke | ||||||||||
| `org.hjug.refactorfirst.report.JsonGenerator` (the Maven plugin's generator), | ||||||||||
| **never** `org.hjug.refactorfirst.report.json.JsonReportExecutor`. | ||||||||||
| - Version sync: `refactor-first-gradle-plugin/gradle.properties` | ||||||||||
| `refactorFirstVersion` must equal the Maven `project.version`; `gradle.yml` | ||||||||||
| fails the build on drift, and `release.yml` bumps both in the same commit. | ||||||||||
| Release order: `report` et al. must be on Maven Central **before** | ||||||||||
| `./gradlew publishPlugins` (maintainer-only) publishes the thin plugin jar. | ||||||||||
| - Local dev: run `mvn install` (or `-pl report -am`) first so `mavenLocal()` | ||||||||||
| can resolve the SNAPSHOT `report` dependency, **then** `./gradlew | ||||||||||
| publishToMavenLocal` so consuming builds can resolve the plugin marker | ||||||||||
| `org.hjug.refactorfirst:org.hjug.refactorfirst.gradle.plugin` from | ||||||||||
| `mavenLocal()`. Consumers need `mavenLocal()` in `pluginManagement | ||||||||||
| repositories`; never point `resolutionStrategy.eachPlugin.useModule` at the | ||||||||||
| marker coordinates (that module is POM-only) — either omit | ||||||||||
| `resolutionStrategy` or point `useModule` at the implementation module | ||||||||||
| `org.hjug.refactorfirst.plugin:refactor-first-gradle-plugin`. | ||||||||||
|
|
||||||||||
| ## Testing Notes | ||||||||||
| - JUnit 5 with parameterized tests | ||||||||||
| - Test fixtures in `test-resources/src/test/resources` | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: refactorfirst/RefactorFirst
Length of output: 7715
🤖 get_repo_knowledge executed:
get_repo_knowledge refactorfirst/RefactorFirst /tmp/coderabbit-repo-knowledge/refactorfirst-refactorfirst-8ce6ec94/architecture /tmp/coderabbit-repo-knowledge/refactorfirst-refactorfirst-8ce6ec94/conventionsLength of output: 16507
Security Misconfiguration
Reachability: External
Exploitability: Difficult
CWE: CWE-250
Restrict the workflow token to read-only contents.
This workflow does not declare
permissions, soGITHUB_TOKENaccess depends on repository or organization defaults. It checks out repository code and runs Maven and Gradle commands. Limit the token tocontents: read. Setpersist-credentials: falsewhen later steps do not need Git authentication.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.30.0)
[warning] 20-67: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
View in Security blast radius
🤖 Prompt for AI Agents
Source: Linters/SAST tools