setup-tea-party 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # setup-tea-party
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Scaffold a [solaire-core](https://github.com/FerdaKoplo/solaire-core) (`io.github.ferdakoplo:solaire-core`) web app powered by **TeaVM**, **Vite**, and **Tailwind CSS v4**.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npx setup-tea-party my-app
9
+ ```
10
+
11
+ Or non-interactively with flags:
12
+
13
+ ```bash
14
+ npx setup-tea-party my-app --package com.example.myapp --theme tea --yes
15
+ ```
16
+
17
+ ### Options
18
+
19
+ - `-p, --package <pkg>`: Java base package (default: `com.example.<project>`)
20
+ - `-t, --theme <tea|tailwind|css>`: `Classnames` preset (`tea`, `tailwind`, or `css`)
21
+ - `--solaire-version <version>`: `solaire-core` Maven version (default: `1.4.0`)
22
+ - `-y, --yes`: Accept defaults without prompting
23
+ - `-f, --force`: Scaffold into a non-empty directory
24
+ - `-h, --help`: Show usage
25
+ - `-v, --version`: Show CLI version
26
+
27
+ ## What it creates
28
+
29
+ - Gradle project (`build.gradle`, `settings.gradle`, and bundled `./gradlew` wrapper) configured with `org.teavm` `0.15.0` (`ES2015` output) and `io.github.ferdakoplo:solaire-core`
30
+ - Starter `App.java` + `Main.java` using `JReact.mount`, `AppShell`, `Ui`, and `Classnames`
31
+ - JVM unit test (`AppTest.java`) using `Renderer.RenderScope` + JUnit 5
32
+ - Vite dev/build setup (`package.json`, `vite.config.js`, `index.html`, `src/main/web/main.js`, `src/main/web/style.css`)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { run } from '../src/cli.js';
4
+
5
+ try {
6
+ const code = await run(process.argv.slice(2));
7
+ process.exitCode = code;
8
+ } catch (err) {
9
+ if (err?.name === 'AbortError') {
10
+ console.error('\nAborted.');
11
+ process.exitCode = 130;
12
+ } else {
13
+ console.error(`Error: ${err?.message ?? String(err)}`);
14
+ process.exitCode = 1;
15
+ }
16
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "setup-tea-party",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a solaire-core (jreact) TeaVM + Vite + Tailwind web application",
5
+ "type": "module",
6
+ "bin": {
7
+ "setup-tea-party": "./bin/setup-tea-party.js"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "src",
12
+ "templates",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "test": "node --test test/*.test.js"
17
+ },
18
+ "keywords": [
19
+ "solaire-core",
20
+ "jreact",
21
+ "teavm",
22
+ "vite",
23
+ "tailwind",
24
+ "tea-party",
25
+ "create",
26
+ "cli"
27
+ ],
28
+ "author": "FerdaKoplo",
29
+ "license": "MIT",
30
+ "homepage": "https://github.com/FerdaKoplo/solaire-core/tree/main/setup-tea-party",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/FerdaKoplo/solaire-core.git",
34
+ "directory": "setup-tea-party"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/FerdaKoplo/solaire-core/issues"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ }
42
+ }
package/src/args.js ADDED
@@ -0,0 +1,119 @@
1
+ /** Valid UI styling themes supported by solaire-core Classnames. */
2
+ export const THEMES = ['tea', 'tailwind', 'css'];
3
+
4
+ export const DEFAULT_PROJECT_NAME = 'my-tea-party';
5
+ export const DEFAULT_THEME = 'tea';
6
+ export const DEFAULT_SOLAIRE_VERSION = '1.4.0';
7
+
8
+ const JAVA_KEYWORDS = new Set([
9
+ 'abstract', 'assert', 'boolean', 'break', 'byte', 'case', 'catch', 'char',
10
+ 'class', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum',
11
+ 'extends', 'final', 'finally', 'float', 'for', 'goto', 'if', 'implements',
12
+ 'import', 'instanceof', 'int', 'interface', 'long', 'native', 'new',
13
+ 'package', 'private', 'protected', 'public', 'return', 'short', 'static',
14
+ 'strictfp', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws',
15
+ 'transient', 'try', 'void', 'volatile', 'while', '_',
16
+ ]);
17
+
18
+ const PACKAGE_SEGMENT_RE = /^[a-z_][a-z0-9_]*$/;
19
+
20
+ /**
21
+ * Parse CLI arguments into an options object.
22
+ * Throws an Error on invalid flags or missing option values.
23
+ */
24
+ export function parseArgs(argv) {
25
+ const opts = {
26
+ targetDir: null,
27
+ packageName: null,
28
+ theme: null,
29
+ solaireVersion: DEFAULT_SOLAIRE_VERSION,
30
+ yes: false,
31
+ force: false,
32
+ help: false,
33
+ version: false,
34
+ };
35
+
36
+ for (let i = 0; i < argv.length; i++) {
37
+ const arg = argv[i];
38
+ if (arg === '-h' || arg === '--help') {
39
+ opts.help = true;
40
+ } else if (arg === '-v' || arg === '--version') {
41
+ opts.version = true;
42
+ } else if (arg === '-y' || arg === '--yes') {
43
+ opts.yes = true;
44
+ } else if (arg === '-f' || arg === '--force') {
45
+ opts.force = true;
46
+ } else if (arg === '-p' || arg === '--package') {
47
+ opts.packageName = requireValue(argv, ++i, arg);
48
+ } else if (arg.startsWith('--package=')) {
49
+ opts.packageName = arg.slice('--package='.length);
50
+ } else if (arg === '-t' || arg === '--theme') {
51
+ opts.theme = requireValue(argv, ++i, arg);
52
+ } else if (arg.startsWith('--theme=')) {
53
+ opts.theme = arg.slice('--theme='.length);
54
+ } else if (arg === '--solaire-version') {
55
+ opts.solaireVersion = requireValue(argv, ++i, arg);
56
+ } else if (arg.startsWith('--solaire-version=')) {
57
+ opts.solaireVersion = arg.slice('--solaire-version='.length);
58
+ } else if (arg.startsWith('-')) {
59
+ throw new Error(`Unknown option: ${arg}`);
60
+ } else if (opts.targetDir === null) {
61
+ opts.targetDir = arg;
62
+ } else {
63
+ throw new Error(`Unexpected extra argument: ${arg}`);
64
+ }
65
+ }
66
+
67
+ if (opts.theme !== null && !THEMES.includes(opts.theme)) {
68
+ throw new Error(`Invalid theme "${opts.theme}". Expected one of: ${THEMES.join(', ')}`);
69
+ }
70
+ if (opts.packageName !== null) {
71
+ validatePackageName(opts.packageName);
72
+ }
73
+ return opts;
74
+ }
75
+
76
+ function requireValue(argv, index, flag) {
77
+ if (index >= argv.length || argv[index].startsWith('-')) {
78
+ throw new Error(`Missing value for ${flag}`);
79
+ }
80
+ return argv[index];
81
+ }
82
+
83
+ /** Validate a Java package name (e.g. "com.example.myapp"). */
84
+ export function validatePackageName(pkg) {
85
+ if (!pkg || typeof pkg !== 'string') {
86
+ throw new Error('Java package name cannot be empty.');
87
+ }
88
+ const segments = pkg.split('.');
89
+ for (const seg of segments) {
90
+ if (!PACKAGE_SEGMENT_RE.test(seg) || JAVA_KEYWORDS.has(seg)) {
91
+ throw new Error(
92
+ `Invalid Java package segment "${seg}" in "${pkg}". Use lowercase identifiers (e.g. com.example.teaparty).`
93
+ );
94
+ }
95
+ }
96
+ return pkg;
97
+ }
98
+
99
+ /** Derive a valid Java base package name from a project directory name. */
100
+ export function toDefaultPackage(projectName) {
101
+ const cleaned = String(projectName || '')
102
+ .toLowerCase()
103
+ .replace(/[^a-z0-9]/g, '');
104
+ let leaf = cleaned || 'teaparty';
105
+ if (/^[0-9]/.test(leaf) || JAVA_KEYWORDS.has(leaf)) {
106
+ leaf = `app${leaf}`;
107
+ }
108
+ return `com.example.${leaf}`;
109
+ }
110
+
111
+ /** Derive a human-readable app title from a project directory name. */
112
+ export function toAppTitle(projectName) {
113
+ const words = String(projectName || 'Tea Party')
114
+ .trim()
115
+ .split(/[-_\s]+/)
116
+ .filter(Boolean);
117
+ if (words.length === 0) return 'Tea Party';
118
+ return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
119
+ }
package/src/cli.js ADDED
@@ -0,0 +1,73 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { stdout } from 'node:process';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { DEFAULT_SOLAIRE_VERSION, THEMES, parseArgs } from './args.js';
6
+ import { resolveConfig } from './prompts.js';
7
+ import { scaffoldProject } from './scaffold.js';
8
+ import { c, printBanner } from './ui.js';
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+
12
+ /** Print CLI usage help. */
13
+ export function formatHelp() {
14
+ return `Usage: setup-tea-party [project-name] [options]
15
+
16
+ Scaffold a solaire-core (jreact) TeaVM + Vite web application.
17
+
18
+ Options:
19
+ -p, --package <pkg> Java base package (e.g. com.example.teaparty)
20
+ -t, --theme <theme> UI theme preset: ${THEMES.join(' | ')} (default: tea)
21
+ --solaire-version <v> solaire-core Maven version (default: ${DEFAULT_SOLAIRE_VERSION})
22
+ -y, --yes Skip prompts and use defaults
23
+ -f, --force Allow writing into a non-empty directory
24
+ -h, --help Show this help message
25
+ -v, --version Show CLI version
26
+ `;
27
+ }
28
+
29
+ async function readCliVersion() {
30
+ const pkgRaw = await readFile(path.resolve(__dirname, '../package.json'), 'utf8');
31
+ return JSON.parse(pkgRaw).version;
32
+ }
33
+
34
+ /** Run the setup-tea-party CLI. Returns an integer exit code. */
35
+ export async function run(argv) {
36
+ const opts = parseArgs(argv);
37
+
38
+ if (opts.help) {
39
+ console.log(formatHelp());
40
+ return 0;
41
+ }
42
+
43
+ const version = await readCliVersion();
44
+
45
+ if (opts.version) {
46
+ console.log(version);
47
+ return 0;
48
+ }
49
+
50
+ if (stdout.isTTY && !opts.yes) {
51
+ printBanner(version);
52
+ }
53
+
54
+ const config = await resolveConfig(opts, {
55
+ basenameOfCwd: path.basename(process.cwd()),
56
+ });
57
+
58
+ const result = await scaffoldProject(config);
59
+ const cdHint = config.targetDir === '.' ? '' : ` ${c.cyan(`cd ${config.targetDir}`)}\n`;
60
+
61
+ console.log('');
62
+ console.log(` ${c.sage('✔')} ${c.bold('Tea Party ready!')} ${c.dim(result.targetDir)}`);
63
+ console.log(` ${c.dim('package')} ${config.packageName}`);
64
+ console.log(` ${c.dim('theme')} ${config.theme}`);
65
+ console.log(` ${c.dim('core')} io.github.ferdakoplo:solaire-core:${config.solaireVersion}`);
66
+ console.log('');
67
+ console.log(` ${c.bold('Next steps:')}`);
68
+ process.stdout.write(cdHint);
69
+ console.log(` ${c.cyan('npm install')}`);
70
+ console.log(` ${c.cyan('npm run tea-party')}`);
71
+ console.log('');
72
+ return 0;
73
+ }
package/src/prompts.js ADDED
@@ -0,0 +1,194 @@
1
+ import readline from 'node:readline';
2
+ import { createInterface } from 'node:readline/promises';
3
+ import { stdin, stdout } from 'node:process';
4
+ import {
5
+ DEFAULT_PROJECT_NAME,
6
+ DEFAULT_THEME,
7
+ THEMES,
8
+ toDefaultPackage,
9
+ validatePackageName,
10
+ } from './args.js';
11
+ import { c } from './ui.js';
12
+
13
+ const THEME_OPTIONS = [
14
+ {
15
+ value: 'tea',
16
+ title: 'Tea Party',
17
+ hint: 'Warm amber, cream & sage palette (Tailwind v4)',
18
+ },
19
+ {
20
+ value: 'tailwind',
21
+ title: 'Tailwind',
22
+ hint: 'Clean slate & blue utility classes (Tailwind v4)',
23
+ },
24
+ {
25
+ value: 'css',
26
+ title: 'Plain CSS',
27
+ hint: 'Semantic CSS stylesheet without Tailwind',
28
+ },
29
+ ];
30
+
31
+ /**
32
+ * Pure navigation helper for arrow-key / j-k / numeric selection menus.
33
+ * Returns { index, submit, cancel }.
34
+ */
35
+ export function handleMenuKey(currentIndex, key, total) {
36
+ if (!key || total <= 0) return { index: currentIndex, submit: false, cancel: false };
37
+ if (key.ctrl && key.name === 'c') return { index: currentIndex, submit: false, cancel: true };
38
+ if (key.name === 'escape') return { index: currentIndex, submit: false, cancel: true };
39
+ if (key.name === 'return' || key.name === 'enter') {
40
+ return { index: currentIndex, submit: true, cancel: false };
41
+ }
42
+ if (key.name === 'up' || key.name === 'k') {
43
+ return { index: (currentIndex - 1 + total) % total, submit: false, cancel: false };
44
+ }
45
+ if (key.name === 'down' || key.name === 'j') {
46
+ return { index: (currentIndex + 1) % total, submit: false, cancel: false };
47
+ }
48
+ const num = Number.parseInt(key.sequence ?? '', 10);
49
+ if (num >= 1 && num <= total) {
50
+ return { index: num - 1, submit: false, cancel: false };
51
+ }
52
+ return { index: currentIndex, submit: false, cancel: false };
53
+ }
54
+
55
+ /**
56
+ * Resolve configuration interactively when running in a TTY without --yes,
57
+ * or non-interactively using flags + defaults.
58
+ */
59
+ export async function resolveConfig(opts, { basenameOfCwd } = {}) {
60
+ const interactive = Boolean(stdin.isTTY && stdout.isTTY && !opts.yes);
61
+
62
+ if (!interactive) {
63
+ const targetDir = opts.targetDir ?? DEFAULT_PROJECT_NAME;
64
+ const projectName = targetDir === '.' ? (basenameOfCwd || DEFAULT_PROJECT_NAME) : leafName(targetDir);
65
+ const packageName = opts.packageName ?? toDefaultPackage(projectName);
66
+ const theme = opts.theme ?? DEFAULT_THEME;
67
+ return {
68
+ targetDir,
69
+ projectName,
70
+ packageName,
71
+ theme,
72
+ solaireVersion: opts.solaireVersion,
73
+ force: opts.force,
74
+ };
75
+ }
76
+
77
+ const targetDir =
78
+ opts.targetDir ?? (await promptText('Project directory', DEFAULT_PROJECT_NAME));
79
+ const projectName =
80
+ targetDir === '.' ? (basenameOfCwd || DEFAULT_PROJECT_NAME) : leafName(targetDir);
81
+ const defaultPkg = toDefaultPackage(projectName);
82
+
83
+ const packageName =
84
+ opts.packageName ??
85
+ (await promptText('Java base package', defaultPkg, validatePackageName));
86
+
87
+ const theme = opts.theme ?? (await promptSelect('Choose a UI theme', THEME_OPTIONS, DEFAULT_THEME));
88
+
89
+ return {
90
+ targetDir,
91
+ projectName,
92
+ packageName,
93
+ theme,
94
+ solaireVersion: opts.solaireVersion,
95
+ force: opts.force,
96
+ };
97
+ }
98
+
99
+ async function promptText(label, fallback, validate) {
100
+ while (true) {
101
+ const rl = createInterface({ input: stdin, output: stdout });
102
+ let raw;
103
+ try {
104
+ raw = await rl.question(
105
+ ` ${c.amber('◇')} ${c.bold(label)} ${c.dim(`(${fallback})`)}: `
106
+ );
107
+ } finally {
108
+ rl.close();
109
+ }
110
+
111
+ const value = raw.trim() || fallback;
112
+ try {
113
+ if (validate) validate(value);
114
+ // Replace prompt line with clean confirmed summary line
115
+ stdout.write(`\x1b[1A\x1b[2K ${c.sage('◆')} ${c.bold(label)} ${c.dim('·')} ${c.cyan(value)}\n`);
116
+ return value;
117
+ } catch (err) {
118
+ console.log(` ${c.red('!')} ${err.message}`);
119
+ }
120
+ }
121
+ }
122
+
123
+ function promptSelect(label, options, defaultValue) {
124
+ let index = Math.max(0, options.findIndex((o) => o.value === defaultValue));
125
+ const totalLines = options.length + 2; // header + options + hint
126
+
127
+ return new Promise((resolve, reject) => {
128
+ let rendered = false;
129
+
130
+ const render = () => {
131
+ if (rendered) {
132
+ stdout.write(`\x1b[${totalLines}A\x1b[0J`);
133
+ }
134
+ rendered = true;
135
+ stdout.write(` ${c.amber('◇')} ${c.bold(label)}\n`);
136
+ options.forEach((opt, i) => {
137
+ const active = i === index;
138
+ const pointer = active ? c.amber('❯') : ' ';
139
+ const radio = active ? c.amber('●') : c.dim('○');
140
+ const title = active ? c.bold(c.amber(opt.title)) : opt.title;
141
+ const hint = c.dim(` — ${opt.hint}`);
142
+ stdout.write(` ${pointer} ${radio} ${title}${hint}\n`);
143
+ });
144
+ stdout.write(` ${c.dim('Use ↑/↓ arrows (or 1-3) and Enter to confirm')}\n`);
145
+ };
146
+
147
+ const cleanup = () => {
148
+ stdin.removeListener('keypress', onKeypress);
149
+ if (stdin.isTTY) stdin.setRawMode(false);
150
+ stdin.pause();
151
+ stdout.write('\x1b[?25h');
152
+ };
153
+
154
+ const onKeypress = (_str, key) => {
155
+ const action = handleMenuKey(index, key, options.length);
156
+ if (action.cancel) {
157
+ stdout.write(`\x1b[${totalLines}A\x1b[0J`);
158
+ cleanup();
159
+ const err = new Error('Cancelled');
160
+ err.name = 'AbortError';
161
+ reject(err);
162
+ return;
163
+ }
164
+ if (action.submit) {
165
+ const chosen = options[index];
166
+ stdout.write(`\x1b[${totalLines}A\x1b[0J`);
167
+ stdout.write(
168
+ ` ${c.sage('◆')} ${c.bold(label)} ${c.dim('·')} ${c.cyan(chosen.title)} ${c.dim(`(${chosen.value})`)}\n`
169
+ );
170
+ cleanup();
171
+ resolve(chosen.value);
172
+ return;
173
+ }
174
+ if (action.index !== index) {
175
+ index = action.index;
176
+ render();
177
+ }
178
+ };
179
+
180
+ readline.emitKeypressEvents(stdin);
181
+ if (stdin.isTTY) stdin.setRawMode(true);
182
+ stdin.resume();
183
+ stdout.write('\x1b[?25l');
184
+ render();
185
+ stdin.on('keypress', onKeypress);
186
+ });
187
+ }
188
+
189
+ function leafName(targetDir) {
190
+ const parts = targetDir.replace(/[/\\]+$/, '').split(/[/\\]/).filter(Boolean);
191
+ return parts[parts.length - 1] || DEFAULT_PROJECT_NAME;
192
+ }
193
+
194
+ export { THEME_OPTIONS, THEMES };
@@ -0,0 +1,42 @@
1
+ import { chmod, cp, mkdir, readdir, writeFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { renderTemplates } from './templates.js';
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ const WRAPPER_DIR = path.resolve(__dirname, '../templates/wrapper');
8
+
9
+ /**
10
+ * Scaffold a new Tea Party project into targetDir.
11
+ * Throws if targetDir exists and is non-empty unless force is true.
12
+ */
13
+ export async function scaffoldProject(config) {
14
+ const absDir = path.resolve(config.targetDir);
15
+ await ensureTargetDir(absDir, config.force);
16
+
17
+ const files = renderTemplates(config);
18
+ for (const [relPath, content] of Object.entries(files)) {
19
+ const dest = path.join(absDir, relPath);
20
+ await mkdir(path.dirname(dest), { recursive: true });
21
+ await writeFile(dest, content, 'utf8');
22
+ }
23
+
24
+ await cp(WRAPPER_DIR, absDir, { recursive: true });
25
+ await chmod(path.join(absDir, 'gradlew'), 0o755);
26
+
27
+ return {
28
+ targetDir: absDir,
29
+ files: Object.keys(files),
30
+ };
31
+ }
32
+
33
+ async function ensureTargetDir(absDir, force) {
34
+ await mkdir(absDir, { recursive: true });
35
+ const entries = await readdir(absDir);
36
+ const meaningful = entries.filter((name) => name !== '.DS_Store' && name !== '.git');
37
+ if (meaningful.length > 0 && !force) {
38
+ throw new Error(
39
+ `Target directory "${absDir}" is not empty. Choose another directory or pass --force.`
40
+ );
41
+ }
42
+ }
@@ -0,0 +1,424 @@
1
+ import { toAppTitle } from './args.js';
2
+
3
+ const CLASSNAMES_CALL = {
4
+ tea: 'Classnames.tea()',
5
+ tailwind: 'Classnames.tailwind()',
6
+ css: 'Classnames.css()',
7
+ };
8
+
9
+ /**
10
+ * Generate all text files for a scaffolded Tea Party app.
11
+ * Returns a map of relative file path -> UTF-8 string contents.
12
+ */
13
+ export function renderTemplates({ projectName, packageName, theme, solaireVersion }) {
14
+ const appTitle = toAppTitle(projectName);
15
+ const pkgPath = packageName.replaceAll('.', '/');
16
+ const usesTailwind = theme === 'tea' || theme === 'tailwind';
17
+ const classnamesCall = CLASSNAMES_CALL[theme];
18
+
19
+ return {
20
+ '.gitignore': renderGitignore(),
21
+ 'settings.gradle': renderSettingsGradle(projectName),
22
+ 'build.gradle': renderBuildGradle({ packageName, solaireVersion }),
23
+ 'package.json': renderPackageJson({ projectName, usesTailwind }),
24
+ 'vite.config.js': renderViteConfig(usesTailwind),
25
+ 'index.html': renderIndexHtml(appTitle),
26
+ 'README.md': renderReadme({ projectName, appTitle, packageName, theme, solaireVersion }),
27
+ 'src/main/web/main.js': renderMainJs(),
28
+ 'src/main/web/style.css': renderStyleCss(usesTailwind),
29
+ [`src/main/java/${pkgPath}/Main.java`]: renderMainJava({ packageName, classnamesCall }),
30
+ [`src/main/java/${pkgPath}/App.java`]: renderAppJava({ packageName, appTitle, theme }),
31
+ [`src/test/java/${pkgPath}/AppTest.java`]: renderAppTestJava({ packageName, appTitle, classnamesCall }),
32
+ };
33
+ }
34
+
35
+ function renderGitignore() {
36
+ return `.gradle/
37
+ build/
38
+ dist/
39
+ node_modules/
40
+ .DS_Store
41
+ .idea/
42
+ *.iml
43
+ `;
44
+ }
45
+
46
+ function renderSettingsGradle(projectName) {
47
+ return `rootProject.name = '${projectName}'
48
+ `;
49
+ }
50
+
51
+ function renderBuildGradle({ packageName, solaireVersion }) {
52
+ return `plugins {
53
+ id 'java'
54
+ id 'org.teavm' version '0.15.0'
55
+ }
56
+
57
+ group = '${packageName}'
58
+ version = '0.1.0'
59
+
60
+ java {
61
+ sourceCompatibility = JavaVersion.VERSION_21
62
+ targetCompatibility = JavaVersion.VERSION_21
63
+ }
64
+
65
+ repositories {
66
+ mavenCentral()
67
+ }
68
+
69
+ dependencies {
70
+ implementation 'io.github.ferdakoplo:solaire-core:${solaireVersion}'
71
+ testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
72
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
73
+ }
74
+
75
+ testing {
76
+ suites {
77
+ test {
78
+ useJUnitJupiter()
79
+ }
80
+ }
81
+ }
82
+
83
+ teavm {
84
+ all {
85
+ mainClass = '${packageName}.Main'
86
+ }
87
+ js {
88
+ addedToWebApp = false
89
+ targetFileName = 'classes.js'
90
+ moduleType = org.teavm.gradle.api.JSModuleType.ES2015
91
+ sourceMap = true
92
+ }
93
+ }
94
+ `;
95
+ }
96
+
97
+ function renderPackageJson({ projectName, usesTailwind }) {
98
+ const pkg = {
99
+ name: projectName,
100
+ private: true,
101
+ version: '0.1.0',
102
+ type: 'module',
103
+ scripts: {
104
+ 'build:java': './gradlew generateJavaScript',
105
+ 'tea-party': 'npm run build:java && vite',
106
+ dev: 'npm run tea-party',
107
+ build: 'npm run build:java && vite build',
108
+ preview: 'vite preview',
109
+ test: './gradlew test',
110
+ },
111
+ dependencies: {
112
+ vite: '^8.3.0',
113
+ ...(usesTailwind ? { '@tailwindcss/vite': '^4.3.3' } : {}),
114
+ },
115
+ ...(usesTailwind ? { devDependencies: { tailwindcss: '^4.3.3' } } : {}),
116
+ };
117
+ return JSON.stringify(pkg, null, 2) + '\n';
118
+ }
119
+
120
+ function renderViteConfig(usesTailwind) {
121
+ if (usesTailwind) {
122
+ return `import { defineConfig } from 'vite';
123
+ import tailwindcss from '@tailwindcss/vite';
124
+
125
+ export default defineConfig({
126
+ plugins: [tailwindcss()],
127
+ });
128
+ `;
129
+ }
130
+ return `import { defineConfig } from 'vite';
131
+
132
+ export default defineConfig({});
133
+ `;
134
+ }
135
+
136
+ function renderIndexHtml(appTitle) {
137
+ return `<!doctype html>
138
+ <html lang="en">
139
+ <head>
140
+ <meta charset="UTF-8" />
141
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
142
+ <title>${appTitle}</title>
143
+ </head>
144
+ <body>
145
+ <div id="app"></div>
146
+ <script type="module" src="/src/main/web/main.js"></script>
147
+ </body>
148
+ </html>
149
+ `;
150
+ }
151
+
152
+ function renderMainJs() {
153
+ return `import './style.css';
154
+ import { main } from '../../../build/generated/teavm/js/classes.js';
155
+
156
+ main();
157
+ `;
158
+ }
159
+
160
+ function renderStyleCss(usesTailwind) {
161
+ if (usesTailwind) {
162
+ // Include TeaVM output & Java sources so Tailwind v4 scans classes inside
163
+ // solaire-core's TeaClassnames/TailwindClassnames even though build/ is gitignored.
164
+ return `@import "tailwindcss";
165
+ @source "../java";
166
+ @source "../../../build/generated/teavm/js/classes.js";
167
+ `;
168
+ }
169
+ return `:root {
170
+ font-family: system-ui, -apple-system, sans-serif;
171
+ color: #1f2937;
172
+ background: #f9fafb;
173
+ }
174
+
175
+ body {
176
+ margin: 0;
177
+ }
178
+
179
+ .app-shell {
180
+ min-height: 100vh;
181
+ display: flex;
182
+ }
183
+
184
+ .sidebar {
185
+ width: 14rem;
186
+ flex-shrink: 0;
187
+ background: #111827;
188
+ color: #f9fafb;
189
+ padding: 1rem;
190
+ }
191
+
192
+ .sidebar .brand {
193
+ font-weight: 700;
194
+ margin-bottom: 1rem;
195
+ }
196
+
197
+ .nav-item {
198
+ display: block;
199
+ padding: 0.5rem 0.75rem;
200
+ border-radius: 0.375rem;
201
+ color: #d1d5db;
202
+ text-decoration: none;
203
+ font-size: 0.875rem;
204
+ }
205
+
206
+ .nav-item.active,
207
+ .nav-item:hover {
208
+ background: #1f2937;
209
+ color: #ffffff;
210
+ }
211
+
212
+ .main {
213
+ flex: 1;
214
+ padding: 1.5rem;
215
+ display: flex;
216
+ flex-direction: column;
217
+ gap: 1rem;
218
+ }
219
+
220
+ .card {
221
+ background: #ffffff;
222
+ border: 1px solid #e5e7eb;
223
+ border-radius: 0.5rem;
224
+ padding: 1rem 1.25rem;
225
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
226
+ }
227
+
228
+ .btn {
229
+ display: inline-flex;
230
+ align-items: center;
231
+ justify-content: center;
232
+ border-radius: 0.375rem;
233
+ padding: 0.45rem 0.85rem;
234
+ font-size: 0.875rem;
235
+ font-weight: 500;
236
+ border: 1px solid #d1d5db;
237
+ background: #ffffff;
238
+ cursor: pointer;
239
+ }
240
+
241
+ .btn-primary {
242
+ background: #2563eb;
243
+ border-color: #2563eb;
244
+ color: #ffffff;
245
+ }
246
+
247
+ .btn-danger {
248
+ background: #dc2626;
249
+ border-color: #dc2626;
250
+ color: #ffffff;
251
+ }
252
+
253
+ .btn-ghost {
254
+ background: transparent;
255
+ border-color: transparent;
256
+ }
257
+
258
+ .badge {
259
+ display: inline-block;
260
+ border-radius: 9999px;
261
+ padding: 0.125rem 0.5rem;
262
+ font-size: 0.75rem;
263
+ font-weight: 500;
264
+ background: #f3f4f6;
265
+ color: #1f2937;
266
+ }
267
+
268
+ .badge-success {
269
+ background: #dcfce7;
270
+ color: #166534;
271
+ }
272
+
273
+ .badge-warning {
274
+ background: #fef3c7;
275
+ color: #92400e;
276
+ }
277
+
278
+ .badge-danger {
279
+ background: #fee2e2;
280
+ color: #991b1b;
281
+ }
282
+
283
+ .empty {
284
+ padding: 1.5rem;
285
+ text-align: center;
286
+ color: #6b7280;
287
+ font-size: 0.875rem;
288
+ }
289
+ `;
290
+ }
291
+
292
+ function renderMainJava({ packageName, classnamesCall }) {
293
+ return `package ${packageName};
294
+
295
+ import dev.jreact.dom.JReact;
296
+ import dev.jreact.ui.Classnames;
297
+ import org.teavm.jso.dom.html.HTMLDocument;
298
+
299
+ public final class Main {
300
+
301
+ public static void main(String[] args) {
302
+ Classnames.use(${classnamesCall});
303
+ JReact.mount(new App(), HTMLDocument.current().getElementById("app"));
304
+ }
305
+
306
+ private Main() {}
307
+ }
308
+ `;
309
+ }
310
+
311
+ function renderAppJava({ packageName, appTitle, theme }) {
312
+ const rowCls = theme === 'css' ? 'actions' : 'flex items-center gap-2 mt-3';
313
+ const metaCls = theme === 'css' ? 'meta' : 'flex items-center gap-2 mb-2';
314
+
315
+ return `package ${packageName};
316
+
317
+ import dev.jreact.dom.FC;
318
+ import dev.jreact.dom.Renderer;
319
+ import dev.jreact.dom.State;
320
+ import dev.jreact.dom.nodes.VNode;
321
+ import dev.jreact.ui.AppShell;
322
+ import dev.jreact.ui.Ui;
323
+
324
+ import java.util.List;
325
+
326
+ import static dev.jreact.dom.H.el;
327
+
328
+ public final class App implements FC.NoProps {
329
+
330
+ @Override
331
+ public VNode render(Renderer.RenderScope scope) {
332
+ State<Integer> cups = scope.useState(1);
333
+
334
+ return AppShell.appShell(
335
+ scope,
336
+ "${appTitle}",
337
+ List.of(AppShell.NavItem.item("/", "Tea Party")),
338
+ () -> Ui.card(
339
+ "Welcome to ${appTitle}",
340
+ el("div").cls("${metaCls}").kids(
341
+ Ui.badge("solaire-core", "success"),
342
+ Ui.badge("${theme} theme", "warning")
343
+ ).end(),
344
+ el("p").kids("Cups poured: ", cups.get()).end(),
345
+ el("div").cls("${rowCls}").kids(
346
+ Ui.buttonPrimary("Pour another cup", () -> cups.set(c -> c + 1)),
347
+ Ui.button("Reset", "ghost", () -> cups.set(0))
348
+ ).end()
349
+ )
350
+ );
351
+ }
352
+ }
353
+ `;
354
+ }
355
+
356
+ function renderAppTestJava({ packageName, appTitle, classnamesCall }) {
357
+ return `package ${packageName};
358
+
359
+ import dev.jreact.dom.Renderer;
360
+ import dev.jreact.dom.nodes.ElementVNode;
361
+ import dev.jreact.dom.nodes.TextVNode;
362
+ import dev.jreact.dom.nodes.VNode;
363
+ import dev.jreact.ui.Classnames;
364
+ import org.junit.jupiter.api.AfterEach;
365
+ import org.junit.jupiter.api.Test;
366
+
367
+ import static org.junit.jupiter.api.Assertions.assertEquals;
368
+ import static org.junit.jupiter.api.Assertions.assertTrue;
369
+
370
+ class AppTest {
371
+
372
+ @AfterEach
373
+ void cleanup() {
374
+ Classnames.use(null);
375
+ }
376
+
377
+ @Test
378
+ void appRendersWelcomeCard() {
379
+ Classnames.use(${classnamesCall});
380
+ Renderer.RenderScope scope = new Renderer.RenderScope(new Renderer.Instance());
381
+
382
+ ElementVNode root = (ElementVNode) new App().render(scope);
383
+
384
+ assertEquals("div", root.tagName());
385
+ assertEquals(2, root.children().size());
386
+ assertTrue(collectText(root).contains("${appTitle}"));
387
+ }
388
+
389
+ private static String collectText(VNode node) {
390
+ if (node instanceof TextVNode t) return t.text();
391
+ if (node instanceof ElementVNode e) {
392
+ StringBuilder sb = new StringBuilder();
393
+ for (VNode child : e.children()) sb.append(collectText(child));
394
+ return sb.toString();
395
+ }
396
+ return "";
397
+ }
398
+ }
399
+ `;
400
+ }
401
+
402
+ function renderReadme({ projectName, appTitle, packageName, theme, solaireVersion }) {
403
+ return `# ${appTitle}
404
+
405
+ A [solaire-core](https://github.com/FerdaKoplo/solaire-core) (\`io.github.ferdakoplo:solaire-core:${solaireVersion}\`) TeaVM + Vite application scaffolded with \`setup-tea-party\`.
406
+
407
+ - **Java package**: \`${packageName}\`
408
+ - **Theme preset**: \`${theme}\`
409
+
410
+ ## Getting started
411
+
412
+ \`\`\`bash
413
+ npm install
414
+ npm run tea-party
415
+ \`\`\`
416
+
417
+ ## Scripts
418
+
419
+ - \`npm run tea-party\` — Compile Java to JS with TeaVM (\`./gradlew generateJavaScript\`) and start the Vite dev server
420
+ - \`npm run build:java\` — Run \`./gradlew generateJavaScript\` only
421
+ - \`npm run build\` — Compile Java and build the production Vite bundle into \`dist/\`
422
+ - \`npm test\` — Run JUnit 5 JVM tests (\`./gradlew test\`)
423
+ `;
424
+ }
package/src/ui.js ADDED
@@ -0,0 +1,30 @@
1
+ import { env, stdout } from 'node:process';
2
+
3
+ const useColor = Boolean(
4
+ !env.NO_COLOR && (env.FORCE_COLOR || stdout.isTTY)
5
+ );
6
+
7
+ const wrap = (open, close) => (text) =>
8
+ useColor ? `\x1b[${open}m${text}\x1b[${close}m` : String(text);
9
+
10
+ export const c = {
11
+ bold: wrap('1', '22'),
12
+ dim: wrap('2', '22'),
13
+ amber: wrap('33', '39'),
14
+ sage: wrap('32', '39'),
15
+ cyan: wrap('36', '39'),
16
+ red: wrap('31', '39'),
17
+ bgAmber: wrap('43;30', '49;39'),
18
+ inverse: wrap('7', '27'),
19
+ };
20
+
21
+ export function printBanner(version) {
22
+ console.log('');
23
+ console.log(
24
+ ` ${c.bgAmber(' TEA PARTY ')} ${c.bold('setup-tea-party')} ${c.dim(`v${version}`)}`
25
+ );
26
+ console.log(
27
+ ` ${c.dim('Scaffold a solaire-core (TeaVM + Vite) web app')}`
28
+ );
29
+ console.log('');
30
+ }
@@ -0,0 +1,9 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
4
+ networkTimeout=10000
5
+ retries=0
6
+ retryBackOffMs=500
7
+ validateDistributionUrl=true
8
+ zipStoreBase=GRADLE_USER_HOME
9
+ zipStorePath=wrapper/dists
@@ -0,0 +1,248 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
20
+
21
+ ##############################################################################
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
65
+ ##############################################################################
66
+
67
+ # Attempt to set APP_HOME
68
+
69
+ # Resolve links: $0 may be a link
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
83
+ done
84
+
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90
+
91
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
92
+ MAX_FD=maximum
93
+
94
+ warn () {
95
+ echo "$*"
96
+ } >&2
97
+
98
+ die () {
99
+ echo
100
+ echo "$*"
101
+ echo
102
+ exit 1
103
+ } >&2
104
+
105
+ # OS specific support (must be 'true' or 'false').
106
+ cygwin=false
107
+ msys=false
108
+ darwin=false
109
+ nonstop=false
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
115
+ esac
116
+
117
+
118
+
119
+ # Determine the Java command to use to start the JVM.
120
+ if [ -n "$JAVA_HOME" ] ; then
121
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
122
+ # IBM's JDK on AIX uses strange locations for the executables
123
+ JAVACMD=$JAVA_HOME/jre/sh/java
124
+ else
125
+ JAVACMD=$JAVA_HOME/bin/java
126
+ fi
127
+ if [ ! -x "$JAVACMD" ] ; then
128
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
129
+
130
+ Please set the JAVA_HOME variable in your environment to match the
131
+ location of your Java installation."
132
+ fi
133
+ else
134
+ JAVACMD=java
135
+ if ! command -v java >/dev/null 2>&1
136
+ then
137
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
138
+
139
+ Please set the JAVA_HOME variable in your environment to match the
140
+ location of your Java installation."
141
+ fi
142
+ fi
143
+
144
+ # Increase the maximum file descriptors if we can.
145
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
146
+ case $MAX_FD in #(
147
+ max*)
148
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
149
+ # shellcheck disable=SC2039,SC3045
150
+ MAX_FD=$( ulimit -H -n ) ||
151
+ warn "Could not query maximum file descriptor limit"
152
+ esac
153
+ case $MAX_FD in #(
154
+ '' | soft) :;; #(
155
+ *)
156
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157
+ # shellcheck disable=SC2039,SC3045
158
+ ulimit -n "$MAX_FD" ||
159
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
160
+ esac
161
+ fi
162
+
163
+ # Collect all arguments for the java command, stacking in reverse order:
164
+ # * args from the command line
165
+ # * the main class name
166
+ # * -classpath
167
+ # * -D...appname settings
168
+ # * --module-path (only if needed)
169
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
170
+
171
+ # For Cygwin or MSYS, switch paths to Windows format before running java
172
+ if "$cygwin" || "$msys" ; then
173
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
174
+
175
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
176
+
177
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
178
+ for arg do
179
+ if
180
+ case $arg in #(
181
+ -*) false ;; # don't mess with options #(
182
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183
+ [ -e "$t" ] ;; #(
184
+ *) false ;;
185
+ esac
186
+ then
187
+ arg=$( cygpath --path --ignore --mixed "$arg" )
188
+ fi
189
+ # Roll the args list around exactly as many times as the number of
190
+ # args, so each arg winds up back in the position where it started, but
191
+ # possibly modified.
192
+ #
193
+ # NB: a `for` loop captures its iteration list before it begins, so
194
+ # changing the positional parameters here affects neither the number of
195
+ # iterations, nor the values presented in `arg`.
196
+ shift # remove old arg
197
+ set -- "$@" "$arg" # push replacement arg
198
+ done
199
+ fi
200
+
201
+
202
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
+
205
+ # Collect all arguments for the java command:
206
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207
+ # and any embedded shellness will be escaped.
208
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209
+ # treated as '${Hostname}' itself on the command line.
210
+
211
+ set -- \
212
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
213
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
214
+ "$@"
215
+
216
+ # Stop when "xargs" is not available.
217
+ if ! command -v xargs >/dev/null 2>&1
218
+ then
219
+ die "xargs is not available"
220
+ fi
221
+
222
+ # Use "xargs" to parse quoted args.
223
+ #
224
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225
+ #
226
+ # In Bash we could simply go:
227
+ #
228
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229
+ # set -- "${ARGS[@]}" "$@"
230
+ #
231
+ # but POSIX shell has neither arrays nor command substitution, so instead we
232
+ # post-process each arg (as a line of input to sed) to backslash-escape any
233
+ # character that might be a shell metacharacter, then use eval to reverse
234
+ # that process (while maintaining the separation between arguments), and wrap
235
+ # the whole thing up as a single "set" statement.
236
+ #
237
+ # This will of course break if any of these variables contains a newline or
238
+ # an unmatched quote.
239
+ #
240
+
241
+ eval "set -- $(
242
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243
+ xargs -n1 |
244
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245
+ tr '\n' ' '
246
+ )" '"$@"'
247
+
248
+ exec "$JAVACMD" "$@"
@@ -0,0 +1,82 @@
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
18
+
19
+ @if "%DEBUG%"=="" @echo off
20
+ @rem ##########################################################################
21
+ @rem
22
+ @rem Gradle startup script for Windows
23
+ @rem
24
+ @rem ##########################################################################
25
+
26
+ @rem Set local scope for the variables, and ensure extensions are enabled
27
+ setlocal EnableExtensions
28
+
29
+ set DIRNAME=%~dp0
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
32
+ set APP_BASE_NAME=%~n0
33
+ set APP_HOME=%DIRNAME%
34
+
35
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
+
38
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
+
41
+ @rem Find java.exe
42
+ if defined JAVA_HOME goto findJavaFromJavaHome
43
+
44
+ set JAVA_EXE=java.exe
45
+ %JAVA_EXE% -version >NUL 2>&1
46
+ if %ERRORLEVEL% equ 0 goto execute
47
+
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
53
+
54
+ "%COMSPEC%" /c exit 1
55
+
56
+ :findJavaFromJavaHome
57
+ set JAVA_HOME=%JAVA_HOME:"=%
58
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
+
60
+ if exist "%JAVA_EXE%" goto execute
61
+
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
67
+
68
+ "%COMSPEC%" /c exit 1
69
+
70
+ :execute
71
+ @rem Setup the command line
72
+
73
+
74
+
75
+ @rem Execute Gradle
76
+ @rem endlocal doesn't take effect until after the line is parsed and variables are expanded
77
+ @rem which allows us to clear the local environment before executing the java command
78
+ endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
79
+
80
+ :exitWithErrorLevel
81
+ @rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
82
+ "%COMSPEC%" /c exit %ERRORLEVEL%