Skip to content

Replace CheerpJ with TeaVM for GitHub Pages deployment#67

Merged
Project516 merged 6 commits into
masterfrom
copilot/add-teavm-for-gh-pages
Oct 27, 2025
Merged

Replace CheerpJ with TeaVM for GitHub Pages deployment#67
Project516 merged 6 commits into
masterfrom
copilot/add-teavm-for-gh-pages

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 22, 2025

Overview

This PR replaces CheerpJ with TeaVM for compiling the Number Guessing Game GUI to JavaScript for GitHub Pages deployment. TeaVM provides a more modern, maintainable solution for running Java applications in the browser.

What is TeaVM?

TeaVM is an ahead-of-time compiler for Java bytecode that emits JavaScript. Unlike CheerpJ which emulates a JVM in the browser, TeaVM compiles Java code directly to optimized JavaScript, resulting in better performance and smaller output.

Changes Made

1. New WebGUI Class (WebGUI.java)

Created a browser-native implementation of the game UI using TeaVM's JSO (JavaScript Objects) APIs:

  • Uses DOM manipulation APIs instead of Swing
  • Reuses all existing game logic classes (RandomNumber, CheckGuess, GameInfo)
  • Provides the same gameplay experience as the Swing GUI
  • ~200 lines of well-documented code

2. Build System Updates

  • Added io.github.zebalu.teavm-gradle-plugin v1.0.0 to build.gradle
  • Added TeaVM JSO APIs as a compile-only dependency
  • Updated Java target from 8 to 11 (required by TeaVM 0.10.2)
  • Updated README.md to reflect Java 11 requirement

3. Build Script (teavm.sh)

Replaced cheerpj.sh with a new script that:

  1. Builds the project
  2. Compiles WebGUI.java to JavaScript using TeaVM
  3. Copies output to the javadoc directory for deployment

4. GitHub Actions Workflow

Updated .github/workflows/javadoc.yml:

- - name: Copy Cheerpj
-   run: ./cheerpj.sh
+ - name: Build TeaVM (JavaScript compilation)
+   run: ./teavm.sh

5. Documentation

  • Added teavm/README.md explaining the TeaVM setup
  • Included styled teavm/index.html with responsive CSS
  • Added comprehensive code comments
  • Updated .gitignore for TeaVM build artifacts

Technical Details

  • TeaVM Version: 0.10.2
  • Plugin: io.github.zebalu.teavm-gradle-plugin v1.0.0
  • Generated JavaScript: ~156KB (817 lines)
  • Java Version: Now requires Java 11+ (previously Java 8+)

Testing

  • ✅ All existing tests pass
  • ✅ Gradle build successful
  • ✅ TeaVM compilation generates valid JavaScript
  • ✅ No modifications to existing game logic

Code Quality

  • Minimal changes to existing code (only additions)
  • No breaking changes to the desktop application
  • All changes are well-documented with comments
  • Follows existing code style and conventions

Migration Notes

Breaking Change: The minimum Java version requirement has increased from 8 to 11. This is necessary because:

  • TeaVM 0.10.2+ requires Java 11 as the minimum compilation target
  • Modern Java ecosystem has largely moved beyond Java 8 (EOL 2019)
  • Java 11 is an LTS release with wide support

Users running the JAR file will need Java 11 or higher installed. The standalone packages with bundled JRE are unaffected.

Future Improvements

The TeaVM setup enables potential future enhancements:

  • Progressive Web App (PWA) capabilities
  • Offline gameplay support
  • Better mobile browser experience
  • Reduced load times compared to CheerpJ

Closes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>TeaVM</issue_title>
<issue_description>Add TeaVM for the gui add for gh pages - modify the javadoc task to auto deploy it (replace the cheerpj thing) make sure to keep the code modyifing to a mininum and document all changes</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #66


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits October 22, 2025 14:46
Co-authored-by: Project516 <138796702+Project516@users.noreply.github.com>
Co-authored-by: Project516 <138796702+Project516@users.noreply.github.com>
Co-authored-by: Project516 <138796702+Project516@users.noreply.github.com>
Co-authored-by: Project516 <138796702+Project516@users.noreply.github.com>
Copilot AI changed the title [WIP] Add TeaVM for GUI addition to GitHub Pages Replace CheerpJ with TeaVM for GitHub Pages deployment Oct 22, 2025
Copilot AI requested a review from Project516 October 22, 2025 15:25
@Project516 Project516 marked this pull request as ready for review October 27, 2025 17:47
@Project516 Project516 merged commit 9c10e77 into master Oct 27, 2025
3 checks passed
@Project516 Project516 deleted the copilot/add-teavm-for-gh-pages branch October 27, 2025 18:20
Project516 added a commit that referenced this pull request Feb 23, 2026
Replace CheerpJ with TeaVM for GitHub Pages deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TeaVM

2 participants