|
2 | 2 |
|
3 | 3 | **Java has evolved. Your code can too.** |
4 | 4 |
|
5 | | -A collection of 86 side-by-side code comparisons showing old Java patterns next to their clean, modern replacements — from Java 8 all the way to Java 25. |
| 5 | +A collection of 85 side-by-side code comparisons showing old Java patterns next to their clean, modern replacements — from Java 8 all the way to Java 25. |
6 | 6 |
|
7 | 7 | 🔗 **[javaevolved.github.io](https://javaevolved.github.io)** |
8 | 8 |
|
@@ -32,37 +32,62 @@ Each comparison includes an explanation of *why* the modern approach is better, |
32 | 32 | | **Security** | TLS defaults, `SecureRandom`, PEM encoding, key derivation functions | |
33 | 33 | | **Tooling** | JShell, single-file execution, JFR profiling, compact source files, AOT | |
34 | 34 |
|
35 | | -## Tech stack |
| 35 | +## Architecture |
| 36 | + |
| 37 | +This site uses a **JSON-first** build pipeline: |
| 38 | + |
| 39 | +- **Source of truth**: Individual `category/slug.json` files (85 across 10 category folders) |
| 40 | +- **Template**: `slug-template.html` — shared HTML template with `{{placeholder}}` tokens |
| 41 | +- **Generator**: `Generate.java` — a [JBang](https://jbang.dev) script that produces all HTML detail pages and `data/snippets.json` |
| 42 | +- **Deploy**: GitHub Actions runs the generator and deploys to GitHub Pages |
| 43 | + |
| 44 | +Generated files (`category/*.html` and `data/snippets.json`) are in `.gitignore` — never edit them directly. |
| 45 | + |
| 46 | +## Build & run locally |
| 47 | + |
| 48 | +### Prerequisites |
36 | 49 |
|
37 | | -Plain HTML, CSS, and JavaScript — no frameworks, no build step. Hosted on GitHub Pages. |
| 50 | +- **Java 25+** (e.g. [Temurin](https://adoptium.net/)) |
| 51 | +- **[JBang](https://jbang.dev)** (`brew install jbang` / `sdk install jbang` / [other options](https://www.jbang.dev/download/)) |
38 | 52 |
|
39 | | -## Run locally |
| 53 | +### Generate and serve |
40 | 54 |
|
41 | 55 | ```bash |
42 | | -cd modern-java |
| 56 | +# Generate all HTML pages and data/snippets.json |
| 57 | +jbang Generate.java |
| 58 | + |
| 59 | +# Serve locally |
43 | 60 | python3 -m http.server 8090 |
44 | 61 | # Open http://localhost:8090 |
45 | 62 | ``` |
46 | 63 |
|
47 | | -## Modernize with GitHub Copilot |
| 64 | +The generator is a compact source file (Java 25) that uses Jackson for JSON parsing. On first run, JBang resolves the Jackson dependency (~2s); subsequent runs use a cached jar (~0.8s). |
48 | 65 |
|
49 | | -GitHub Copilot can help you migrate legacy Java codebases automatically: |
| 66 | +A Python equivalent (`generate.py`) is also available and produces identical output: |
50 | 67 |
|
51 | | -- [App Modernization](https://github.com/solutions/use-case/app-modernization) |
52 | | -- [Modernize Java Applications with Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/tutorials/modernize-java-applications) |
| 68 | +```bash |
| 69 | +python3 generate.py |
| 70 | +``` |
53 | 71 |
|
54 | 72 | ## Contributing |
55 | 73 |
|
56 | | -Contributions are welcome! If you'd like to add a new snippet, fix an inaccuracy, or improve the site: |
| 74 | +Contributions are welcome! Content is managed as JSON files — never edit generated HTML. |
57 | 75 |
|
58 | 76 | 1. Fork the repo |
59 | | -2. Add or edit snippets in `data/snippets.json` |
60 | | -3. Create the corresponding `.html` article page |
61 | | -4. Update `index.html` with the new card |
62 | | -5. Open a pull request |
| 77 | +2. Create or edit a JSON file in the appropriate category folder (e.g. `language/my-feature.json`) |
| 78 | +3. Follow the [snippet JSON schema](.github/copilot-instructions.md) for all required fields |
| 79 | +4. Run `jbang Generate.java` to verify your changes build correctly |
| 80 | +5. Update `index.html` with a new preview card if adding a new snippet |
| 81 | +6. Open a pull request |
63 | 82 |
|
64 | 83 | Please ensure JDK version labels only reference the version where a feature became **final** (non-preview). |
65 | 84 |
|
| 85 | +## Tech stack |
| 86 | + |
| 87 | +- Plain HTML, CSS, and JavaScript — no frontend frameworks |
| 88 | +- [JBang](https://jbang.dev) + [Jackson](https://github.com/FasterXML/jackson) for build-time generation |
| 89 | +- Hosted on GitHub Pages via GitHub Actions |
| 90 | + |
66 | 91 | ## Author |
67 | 92 |
|
68 | 93 | **Bruno Borges** |
|
0 commit comments