From 21fb7b808a306b95d97a9baa0f2ac4fb50a9038c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:42:20 +0000 Subject: [PATCH 1/4] Initial plan From 55e0becb33a053f1928a08487e144de777382500 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:45:45 +0000 Subject: [PATCH 2/4] Add weekly Java-to-Kotlin conversion workflow Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com> --- .github/workflows/java-to-kotlin-weekly.yml | 94 +++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/java-to-kotlin-weekly.yml diff --git a/.github/workflows/java-to-kotlin-weekly.yml b/.github/workflows/java-to-kotlin-weekly.yml new file mode 100644 index 0000000..967e0ba --- /dev/null +++ b/.github/workflows/java-to-kotlin-weekly.yml @@ -0,0 +1,94 @@ +name: "Convert Java to Kotlin Weekly" +on: + schedule: + # Run every Wednesday at 0:09 GMT (cron format: minute hour day-of-month month day-of-week) + - cron: '9 0 * * 3' + workflow_dispatch: # Allow manual triggering for testing + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + convert-java-to-kotlin: + name: "Convert 1 Java class to Kotlin" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Find Java files to convert + id: find-java + run: | + # Find all Java files (excluding build directories) + JAVA_FILES=$(find src -type f -name "*.java" -not -path "*/build/*" | sort) + + # Count total Java files + TOTAL_COUNT=$(echo "$JAVA_FILES" | wc -l) + echo "Found $TOTAL_COUNT Java files" + + if [ $TOTAL_COUNT -eq 0 ]; then + echo "No Java files found to convert!" + echo "has_files=false" >> $GITHUB_OUTPUT + exit 0 + fi + + # Select a file based on the current week number (rotates through files) + WEEK_NUM=$(date +%V) + FILE_INDEX=$(( ($WEEK_NUM - 1) % $TOTAL_COUNT + 1 )) + + SELECTED_FILE=$(echo "$JAVA_FILES" | sed -n "${FILE_INDEX}p") + echo "Selected file: $SELECTED_FILE" + echo "selected_file=$SELECTED_FILE" >> $GITHUB_OUTPUT + echo "has_files=true" >> $GITHUB_OUTPUT + + # Extract class name for issue/PR title + CLASS_NAME=$(basename "$SELECTED_FILE" .java) + echo "class_name=$CLASS_NAME" >> $GITHUB_OUTPUT + + - name: Create issue for Copilot to convert + if: steps.find-java.outputs.has_files == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Create an issue and tag @copilot to perform the conversion + cat > /tmp/issue_body.md << 'ISSUE_EOF' + @copilot Please convert the following Java file to Kotlin and create a pull request: + + **File to convert:** `${{ steps.find-java.outputs.selected_file }}` + + ### Conversion Requirements: + 1. Preserve all functionality and logic from the Java implementation + 2. Use Kotlin idioms and best practices (null safety, data classes, properties, etc.) + 3. Maintain the same package structure + 4. Keep the same file location (just change extension from .java to .kt) + 5. Ensure null safety with proper Kotlin annotations + 6. Use Kotlin data classes where appropriate + 7. Replace Java patterns with Kotlin equivalents: + - Getters/setters → Kotlin properties + - Static methods → companion object or top-level functions + - Builders → Kotlin default parameters or apply/with + 8. Delete the original Java file after creating the Kotlin version + 9. Update any imports in other files if necessary + 10. Ensure all tests still pass + + ### Steps: + - [ ] Read the Java file + - [ ] Convert to Kotlin maintaining all functionality + - [ ] Save as .kt file in the same location + - [ ] Delete the original .java file + - [ ] Run tests to verify no regressions + - [ ] Create a pull request with the changes + + --- + *This issue was automatically created by the weekly Java-to-Kotlin conversion workflow.* + *Scheduled to run every Wednesday at 0:09 GMT.* + ISSUE_EOF + + gh issue create \ + --title "Convert ${{ steps.find-java.outputs.class_name }} from Java to Kotlin" \ + --body-file /tmp/issue_body.md \ + --label "automation,kotlin,refactoring" + + echo "Issue created successfully for Copilot to handle the conversion." From 8f2fc3357d682a05f792e876db733f935aa5d82f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:46:19 +0000 Subject: [PATCH 3/4] Add documentation for Java-to-Kotlin conversion workflow Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com> --- .github/README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 ++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/README.md diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000..8d8838a --- /dev/null +++ b/.github/README.md @@ -0,0 +1,51 @@ +# GitHub Actions Workflows + +This directory contains GitHub Actions workflows for the commons-java repository. + +## Workflows + +### `java-to-kotlin-weekly.yml` - Convert Java to Kotlin Weekly + +**Schedule:** Every Wednesday at 0:09 GMT + +**Purpose:** Automatically converts one Java class to Kotlin every week to gradually migrate the codebase. + +**How it works:** +1. The workflow runs on a weekly schedule (Wednesday at 0:09 GMT) +2. It scans the repository for Java files (excluding build directories) +3. Selects one Java file based on the current week number (rotates through all files) +4. Creates a GitHub issue with @copilot tagged to request the conversion +5. GitHub Copilot in Issues will then convert the file and create a pull request + +**Manual Triggering:** +You can manually trigger this workflow from the Actions tab in GitHub: +1. Go to Actions → "Convert Java to Kotlin Weekly" +2. Click "Run workflow" +3. Select the branch and click "Run workflow" + +**Labels:** The created issues are tagged with: +- `automation` - Indicates this is an automated task +- `kotlin` - Related to Kotlin migration +- `refactoring` - Code refactoring task + +**Algorithm:** The workflow uses a deterministic algorithm to select files: +- Files are sorted alphabetically +- The selection rotates based on week number: `(week_number - 1) % total_files + 1` +- This ensures all files will eventually be converted and prevents duplicates + +**Requirements:** The conversion process maintains: +- All functionality and logic from Java +- Kotlin idioms and best practices +- Same package structure +- Proper null safety annotations +- Compatibility with existing tests + +--- + +### `mt-build.yml` - MT Build + +Runs the main build workflow for MonTransit projects. + +### `mt-trigger-main-repo-build.yml` - MT Trigger Main Repo Build + +Triggers the build of the main MonTransit repository when changes are pushed to master. diff --git a/README.md b/README.md index 06dd81d..86eaa6c 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,11 @@ commons-java =============== Common source code used by MonTransit projects. + +## Development + +### Java to Kotlin Migration + +This repository is gradually migrating from Java to Kotlin. An automated workflow runs every Wednesday at 0:09 GMT to convert one Java class to Kotlin. The workflow creates issues that are handled by GitHub Copilot, which performs the conversion and creates pull requests. + +For more information about the workflows, see [.github/README.md](.github/README.md). From 8eaf5e4884bd372387e1ffb4dc78b8f3c294f9c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 15:51:35 +0000 Subject: [PATCH 4/4] Revert README changes, keep only workflow file Co-authored-by: mmathieum <177998+mmathieum@users.noreply.github.com> --- .github/README.md | 51 ----------------------------------------------- README.md | 8 -------- 2 files changed, 59 deletions(-) delete mode 100644 .github/README.md diff --git a/.github/README.md b/.github/README.md deleted file mode 100644 index 8d8838a..0000000 --- a/.github/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# GitHub Actions Workflows - -This directory contains GitHub Actions workflows for the commons-java repository. - -## Workflows - -### `java-to-kotlin-weekly.yml` - Convert Java to Kotlin Weekly - -**Schedule:** Every Wednesday at 0:09 GMT - -**Purpose:** Automatically converts one Java class to Kotlin every week to gradually migrate the codebase. - -**How it works:** -1. The workflow runs on a weekly schedule (Wednesday at 0:09 GMT) -2. It scans the repository for Java files (excluding build directories) -3. Selects one Java file based on the current week number (rotates through all files) -4. Creates a GitHub issue with @copilot tagged to request the conversion -5. GitHub Copilot in Issues will then convert the file and create a pull request - -**Manual Triggering:** -You can manually trigger this workflow from the Actions tab in GitHub: -1. Go to Actions → "Convert Java to Kotlin Weekly" -2. Click "Run workflow" -3. Select the branch and click "Run workflow" - -**Labels:** The created issues are tagged with: -- `automation` - Indicates this is an automated task -- `kotlin` - Related to Kotlin migration -- `refactoring` - Code refactoring task - -**Algorithm:** The workflow uses a deterministic algorithm to select files: -- Files are sorted alphabetically -- The selection rotates based on week number: `(week_number - 1) % total_files + 1` -- This ensures all files will eventually be converted and prevents duplicates - -**Requirements:** The conversion process maintains: -- All functionality and logic from Java -- Kotlin idioms and best practices -- Same package structure -- Proper null safety annotations -- Compatibility with existing tests - ---- - -### `mt-build.yml` - MT Build - -Runs the main build workflow for MonTransit projects. - -### `mt-trigger-main-repo-build.yml` - MT Trigger Main Repo Build - -Triggers the build of the main MonTransit repository when changes are pushed to master. diff --git a/README.md b/README.md index 86eaa6c..06dd81d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,3 @@ commons-java =============== Common source code used by MonTransit projects. - -## Development - -### Java to Kotlin Migration - -This repository is gradually migrating from Java to Kotlin. An automated workflow runs every Wednesday at 0:09 GMT to convert one Java class to Kotlin. The workflow creates issues that are handled by GitHub Copilot, which performs the conversion and creates pull requests. - -For more information about the workflows, see [.github/README.md](.github/README.md).