diff --git a/.github/workflows/ant.yml b/.github/workflows/ant.yml index 31f94891b5..c1e05f4cee 100644 --- a/.github/workflows/ant.yml +++ b/.github/workflows/ant.yml @@ -27,22 +27,19 @@ jobs: cache: 'maven' - name: Install dependencies run: sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb - - name: Build with Maven + - name: Build with Maven (core + in-tree archetypes) run: | + # The cn1{app,lib}-archetype modules are part of the maven/ reactor, + # so this single install also stages them into the local repo. + # -Darchetype.test.skip=true keeps the build fast; the heavier + # archetype ITs run in the release workflow. cd maven - xvfb-run -a mvn install -Plocal-dev-javase - + xvfb-run -a mvn install -Plocal-dev-javase -Darchetype.test.skip=true - - name: Fetch archetype projects - uses: carlosperate/download-file-action@v1.0.3 - with: - file-url: https://github.com/shannah/cn1-maven-archetypes/archive/refs/heads/master.zip - file-name: cn1-maven-archetypes.zip - - name: Install archetype projects + - name: Refresh archetype catalog run: | - unzip cn1-maven-archetypes.zip - cd cn1-maven-archetypes-master - xvfb-run -a mvn install archetype:update-local-catalog -Plocal-dev-javase + cd maven + xvfb-run -a mvn archetype:update-local-catalog -Plocal-dev-javase xvfb-run -a mvn archetype:crawl -Plocal-dev-javase - name: Run Maven Unit Tests run: | diff --git a/.github/workflows/archetype-smoke.yml b/.github/workflows/archetype-smoke.yml index f5ad615384..9d934ffc14 100644 --- a/.github/workflows/archetype-smoke.yml +++ b/.github/workflows/archetype-smoke.yml @@ -16,6 +16,8 @@ on: - 'CodenameOneDesigner/**' - 'CodenameOne/src/com/codename1/ui/plaf/UIManager.java' - 'maven/codenameone-maven-plugin/**' + - 'maven/cn1app-archetype/**' + - 'maven/cn1lib-archetype/**' - 'maven/integration-tests/cn1app-archetype-test.sh' - 'maven/integration-tests/inc/**' - '.github/workflows/archetype-smoke.yml' @@ -26,6 +28,8 @@ on: - 'CodenameOneDesigner/**' - 'CodenameOne/src/com/codename1/ui/plaf/UIManager.java' - 'maven/codenameone-maven-plugin/**' + - 'maven/cn1app-archetype/**' + - 'maven/cn1lib-archetype/**' - 'maven/integration-tests/cn1app-archetype-test.sh' - 'maven/integration-tests/inc/**' - '.github/workflows/archetype-smoke.yml' @@ -43,20 +47,19 @@ jobs: cache: 'maven' - name: Install xvfb run: sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb - - name: Build Codename One Maven artifacts + - name: Build Codename One Maven artifacts (includes archetypes) run: | + # The cn1{app,lib}-archetype modules are inlined into the maven/ + # reactor since the migration, so this single install also stages + # the archetypes into the local repo for `archetype:generate`. + # -Darchetype.test.skip=true keeps the smoke fast — the per-tag + # ITs already run in the release workflow. cd maven - xvfb-run -a mvn install -Plocal-dev-javase -DskipTests -Dmaven.javadoc.skip=true - - name: Fetch and install archetype projects - uses: carlosperate/download-file-action@v1.0.3 - with: - file-url: https://github.com/shannah/cn1-maven-archetypes/archive/refs/heads/master.zip - file-name: cn1-maven-archetypes.zip - - name: Install archetype to local repo + xvfb-run -a mvn install -Plocal-dev-javase -DskipTests -Darchetype.test.skip=true -Dmaven.javadoc.skip=true + - name: Refresh archetype catalog run: | - unzip cn1-maven-archetypes.zip - cd cn1-maven-archetypes-master - xvfb-run -a mvn install archetype:update-local-catalog -Plocal-dev-javase + cd maven + xvfb-run -a mvn archetype:update-local-catalog -Plocal-dev-javase xvfb-run -a mvn archetype:crawl -Plocal-dev-javase - name: Run archetype simulator smoke (auto-bundle pref forced on) run: | diff --git a/.github/workflows/release-on-maven-central.yml b/.github/workflows/release-on-maven-central.yml index 385ac426b6..e06b37e6a3 100644 --- a/.github/workflows/release-on-maven-central.yml +++ b/.github/workflows/release-on-maven-central.yml @@ -30,113 +30,62 @@ jobs: - name: Check Maven Version run: mvn -v - - name: Deploy main Maven artifacts - id: deploy-main + - name: Deploy Maven artifacts (core + archetypes) + id: deploy continue-on-error: true run: | cat $HOME/.m2/settings.xml cd maven bash update-version.sh "$GITHUB_REF_NAME" export GPG_TTY=$(tty) - xvfb-run -a mvn deploy -Psign-artifacts -Dgpg.passphrase=$MAVEN_GPG_PASSPHRASE -Plocal-dev-javase + # The cn1{app,lib}-archetype modules are part of the main reactor + # since the in-tree migration, so a single mvn deploy publishes + # everything (core + maven plugin + both archetypes). + # -Darchetype.test.skip=true: the archetypes' ITs generate a + # project pinned to the current cn1Version and invoke the + # codenameone-maven-plugin against it; that plugin is being + # published in this same reactor so it's not yet on Central + # when the ITs run. -DskipTests covers the matching surefire pass. + xvfb-run -a mvn deploy -Psign-artifacts -Dgpg.passphrase=$MAVEN_GPG_PASSPHRASE -Plocal-dev-javase -Darchetype.test.skip=true -DskipTests env: MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - name: Confirm main artifacts on Maven Central (only after deploy failure) - id: confirm-main - if: steps.deploy-main.outcome == 'failure' + - name: Confirm artifacts on Maven Central (only after deploy failure) + id: confirm + if: steps.deploy.outcome == 'failure' continue-on-error: true run: | - # central-publishing-maven-plugin 0.8.0 occasionally reports + # central-publishing-maven-plugin occasionally reports # "Deployment failed while publishing" even when the bundle was # actually accepted and published. As a safety net for that - # false-positive case, poll Maven Central for the artifact. - # Skipped when the deploy already reported success (the artifact - # may still be propagating from Sonatype Central to repo1; that - # propagation can take 30+ minutes and isn't worth blocking on). + # false-positive case, poll Maven Central for the key artifacts: + # the codenameone-maven-plugin (proxy for the core release) plus + # both archetypes. Skipped when the deploy already reported + # success (the artifact may still be propagating from Sonatype + # Central to repo1; that propagation can take 30+ minutes and + # isn't worth blocking on). set +e for i in $(seq 1 90); do - code=$(curl -s -o /dev/null -w "%{http_code}" \ + plugin_code=$(curl -s -o /dev/null -w "%{http_code}" \ "https://repo1.maven.org/maven2/com/codenameone/codenameone-maven-plugin/${GITHUB_REF_NAME}/codenameone-maven-plugin-${GITHUB_REF_NAME}.pom") - if [ "$code" = "200" ]; then - echo "Confirmed codenameone-maven-plugin ${GITHUB_REF_NAME} on Maven Central" - exit 0 - fi - echo "[$i/90] Waiting for codenameone-maven-plugin ${GITHUB_REF_NAME} on Maven Central (last code=$code)" - sleep 20 - done - echo "codenameone-maven-plugin ${GITHUB_REF_NAME} did not appear on Maven Central within 30 minutes" - exit 1 - - - name: Fail when main release did not complete - if: steps.deploy-main.outcome != 'success' && steps.confirm-main.outcome != 'success' - run: | - echo "Main release failed: deploy reported failure and the artifact never appeared on Maven Central." - exit 1 - - - name: Deploy archetypes to Maven Central - id: deploy-archetypes - if: steps.deploy-main.outcome == 'success' || steps.confirm-main.outcome == 'success' - continue-on-error: true - run: | - git clone https://github.com/shannah/cn1-maven-archetypes - cd cn1-maven-archetypes - # Pin maven-resources-plugin: Maven Central currently advertises - # maven-resources-plugin 4.0.0-beta-1 as the latest release, and - # that build requires Java 17 + Maven 4. The cn1-maven-archetypes - # parent pom does not pin a version, so the deploy resolves the - # beta and fails on this Java 8 / Maven 3.9 runner. Inject a - # pluginManagement entry into the first block (top-level, - # not the sign-artifacts profile build) before the deploy. - sed -i '1,//s||org.apache.maven.pluginsmaven-resources-plugin3.3.1|' pom.xml - if ! grep -q 'maven-resources-plugin3.3.1' pom.xml; then - echo "Failed to inject maven-resources-plugin pin into archetypes pom.xml" >&2 - exit 1 - fi - bash update-version.sh "$GITHUB_REF_NAME" - export GPG_TTY=$(tty) - # Skip the maven-archetype-plugin integration tests during release. - # The cn1-maven-archetypes repo's ITs (added 2026-05-07) generate - # a project pinned to cn1Version=8.0-SNAPSHOT and then invoke the - # codenameone-maven-plugin against it. That plugin SNAPSHOT is not - # on Maven Central, so the ITs fail in CI even though the archetype - # itself packages cleanly. -DskipTests covers the surefire pass too. - xvfb-run -a mvn deploy -Psign-artifacts -Dgpg.passphrase=$MAVEN_GPG_PASSPHRASE -Plocal-dev-javase -Darchetype.test.skip=true -DskipTests - env: - MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - - - name: Confirm archetypes on Maven Central (only after deploy failure) - id: confirm-archetypes - if: steps.deploy-archetypes.outcome == 'failure' - continue-on-error: true - run: | - # cn1-maven-archetypes uses an even older central-publishing-maven-plugin - # (0.7.0) and is susceptible to the same false-positive failure. - set +e - for i in $(seq 1 90); do app_code=$(curl -s -o /dev/null -w "%{http_code}" \ "https://repo1.maven.org/maven2/com/codenameone/cn1app-archetype/${GITHUB_REF_NAME}/cn1app-archetype-${GITHUB_REF_NAME}.pom") lib_code=$(curl -s -o /dev/null -w "%{http_code}" \ "https://repo1.maven.org/maven2/com/codenameone/cn1lib-archetype/${GITHUB_REF_NAME}/cn1lib-archetype-${GITHUB_REF_NAME}.pom") - if [ "$app_code" = "200" ] && [ "$lib_code" = "200" ]; then - echo "Confirmed cn1app-archetype and cn1lib-archetype ${GITHUB_REF_NAME} on Maven Central" + if [ "$plugin_code" = "200" ] && [ "$app_code" = "200" ] && [ "$lib_code" = "200" ]; then + echo "Confirmed codenameone-maven-plugin + cn1{app,lib}-archetype ${GITHUB_REF_NAME} on Maven Central" exit 0 fi - echo "[$i/90] Waiting for archetypes ${GITHUB_REF_NAME} on Maven Central (cn1app=$app_code, cn1lib=$lib_code)" + echo "[$i/90] Waiting on Maven Central (plugin=$plugin_code, cn1app=$app_code, cn1lib=$lib_code)" sleep 20 done - echo "Archetypes ${GITHUB_REF_NAME} did not appear on Maven Central within 30 minutes" + echo "Artifacts ${GITHUB_REF_NAME} did not appear on Maven Central within 30 minutes" exit 1 - - name: Fail when archetype release did not complete - if: | - (steps.deploy-main.outcome == 'success' || steps.confirm-main.outcome == 'success') && - steps.deploy-archetypes.outcome != 'success' && steps.confirm-archetypes.outcome != 'success' + - name: Fail when release did not complete + if: steps.deploy.outcome != 'success' && steps.confirm.outcome != 'success' run: | - echo "Archetype release failed: deploy reported failure and the artifacts never appeared on Maven Central." + echo "Release failed: deploy reported failure and the artifacts never appeared on Maven Central." exit 1 - diff --git a/README.md b/README.md index ccecde3525..c5fe089bf5 100644 --- a/README.md +++ b/README.md @@ -192,17 +192,7 @@ mvn install -Plocal-dev-javase NOTE: The `-Plocal-dev-javase` profile is necessary for building the javase port. Without it, you'll get build errors. -This will build and install Codename One in your local Maven repository. This process can take a while since it automatically downloads dependencies with a size of ~1GB. - - -To build the archetype projects from source, you should check out the [cn1-maven-archetypes](https://github.com/shannah/cn1-maven-archetypes) repository and build it also: - -~~~~ -git clone https://github.com/shannah/cn1-maven-archetypes -cd cn1-maven-archetypes -mvn install -Plocal-dev-javase -~~~~ - +This will build and install Codename One in your local Maven repository, including the `cn1app-archetype` and `cn1lib-archetype` Maven archetypes. This process can take a while since it automatically downloads dependencies with a size of ~1GB. Now that Codename One is installed in your local Maven repository, you can use that version in a project instead of the release version. A new testing project can be quickly generated with the [Codename One initializr](https://start.codenameone.com). diff --git a/maven/README.adoc b/maven/README.adoc index 76fd1ebc3f..555c67d248 100644 --- a/maven/README.adoc +++ b/maven/README.adoc @@ -18,12 +18,10 @@ mvn install ---- === Building Archetype Projects -[source, bash] ----- -git clone https://github.com/shannah/cn1-maven-archetypes -cd cn1-maven-archetypes -mvn install ----- + +The `cn1app-archetype` and `cn1lib-archetype` Maven archetypes are part of this +reactor (under `maven/cn1app-archetype/` and `maven/cn1lib-archetype/`). They +build alongside the rest of the project — no separate checkout is needed. === Deploying to Maven Central @@ -53,27 +51,7 @@ bash update-version.sh $NEXTVERSION && git push ---- -==== Step 3: Checkout cn1-maven-archetypes Repository - -Then do the same for the https://github.com/shannah/cn1-maven-archetypes[cn1-maven-archetypes] repository. - -[source, bash] ----- -git clone https://github.com/shannah/cn1-maven-archetypes -cd cn1-maven-archetypes -mvn update-version.sh $NEWVERSION && git push && git push --tags ----- - -Then check the build log on Github to make sure that the https://github.com/shannah/cn1-maven-archetypes/actions/workflows/sonatype.yml[Deploy to Maven Central] workflow completes successfully. - -If this was successful, update the cn1-maven-archetypes version to the new snapshot version. - -[source, bash] ----- -mvn update-version.sh 7.0.16-SNAPSHOT && git push && git push --tags ----- - -==== Step 4: Close and Release Staging Repository +==== Step 3: Close and Release Staging Repository If these steps complete succesfully, then a staging repository has been created on Sonatype. Log into the https://oss.sonatype.org/#stagingRepositories[Nexus Repository Manager] and click on "Staging Repositories". diff --git a/maven/cn1app-archetype/README.adoc b/maven/cn1app-archetype/README.adoc new file mode 100644 index 0000000000..5338929039 --- /dev/null +++ b/maven/cn1app-archetype/README.adoc @@ -0,0 +1,101 @@ += Codename One Application Archetype + +This project is a Maven archetype for a basic Codename One application project. This project is the basis for all other Codename One application archetypes. + +IMPORTANT: If you make any changes to this archetype, you should run the link:../archetype-generator[archetype-generator] project to regenerate all of the derived archetypes which are defined in the link:../templates[../templates directory], and generated to the link:../generated-archetypes/[../generated-archetypes directory]. + +== Project Structure + +This builds a multi-module maven project with the following sub-modules: + +common:: +The cross-platform Codename One project. Most of your application source will go in here. ++ +[TIP] +==== +The "common" module is the nearest thing to the legacy Codename One ANT project. It is where the codenameone_settings.properties file is found, and all of the source that used to be found in your Codename One project's "src" directory will be found inside the src/main/java directory of the common project. +==== + +javase:: +JavaSE-specific source files. This is where you would place native interface implementations for the javase platform (i.e. the CN1 simulator and desktop builds). If you're familiar with the legacy Codename One ANT project format, then the source files that you used to place in the native/javase directory will now be found in the "src/main/java" directory of the javase module. + +ios:: +IOS-specific source files. Your native interface implementations for the iOS platform will be found in the src/main/objectivec directory of this module. + +android:: +Android-specific source files. Your native interface implementations for the Android platform should be placed inside the src/main/java directory of this module. + +javascript:: +Your native interface implementations for the javascript platform should be placed inside the src/main/javascript directory of this module. + +win:: +Your native interface implementations for the Windows (UWP) platform should be placed inside the src/main/csharp directory of this module. + +== CSS Files + +This archetype uses CSS for its theme. CSS files should be placed inside the "src/main/css/theme.css" file of the "common" module. + +== GUIBuilder Files + +GUIBuilder files should be placed inside the "src/main/guibuilder" directory of the "common" module. + +**Creating GUI Forms** + +Use the `cn1:create-gui-form` goal to create a new GUI Builder form. + +[source,bash] +---- +mvn cn1:create-gui-form -DclassName=com.example.MyForm +---- + +TIP: See link:../../codenameone-maven-plugin/src/main/asciidoc/mojos/create-gui-form.adoc[create-gui-form] for usage instructions of the `create-gui-form` goal. + +The above example will generate a GUIBuilder form with the provided class name. It effectively generates two files: + +. `common/src/main/guibuilder/com/example/MyForm.gui` +. `common/src/main/java/com/example/MyForm.java` + +You can then open the guibuilder to edit this form using the `cn1:guibuilder` goal. + +[source,bash] +---- +mvn cn1:guibuilder -DclassName=com.example.MyForm +---- + +== Running the Project In Simulator + +To run the project in the Codename One simulator use the `verify` goal with additional command-line parameters `-P simulator -Dcodename1.platform=javase`. + +I.e. + +[source,bash] +---- +mvn verify -P simulator -Dcodename1.platform=javase` +---- + +The `-P simulator` parameter activates the simulator, and the `-Dcodename1.platform=javase` property ensures that dependencies for the "javase" platform are included. + +NOTE: We are still working on refining this goal to remove the need for parameters. The instructions for running in simulator will likely change. + +== Dependencies + +Dependencies should be added in the common/pom.xml file. JavaSE-specific dependencies (i.e. for use only in JavaSE native interfaces) may be added to the javase/pom.xml file. + + +[WARNING] +==== +The "common" module should include only code that uses APIs that is supported by Codename One. Codename One supports a subset of JavaSE 8 currently. For a full list of supported APIs, see https://www.codenameone.com/javadoc/[Codename One's javadocs]. + +If you add a dependency to a library that uses unsupported APIs, you may receive a build error when you go to build your project. If the library uses unsupported APIs, but the code that you use in your project doesn't "trigger" any of that code, then you still may be fine, as Codename One uses proguard (and similar libraries) to strip out unused code. + +==== + +[TIP] +==== +There is a large selection of Codename One libraries (i.e. cn1libs) that you can use in your projects that are guaranteed to support the Codename One API. It is recommended that you use to these libraries rather than "any old java library" you find on Maven central because they have been specially designed to work well on mobile. +==== + + + + + diff --git a/maven/cn1app-archetype/pom.xml b/maven/cn1app-archetype/pom.xml new file mode 100644 index 0000000000..f68297c9ad --- /dev/null +++ b/maven/cn1app-archetype/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + com.codenameone + codenameone + 8.0-SNAPSHOT + + cn1app-archetype + maven-archetype + + cn1app-archetype + Codename One bare-bones app project archetype. + + + + true + + + + + + org.apache.maven.archetype + archetype-packaging + 3.2.0 + + + + + + + src/main/resources + + + ${project.basedir}/../../scripts/initializr/common/src/main/resources/skill + archetype-resources/.claude/skills/codename-one + false + + + + + + + maven-archetype-plugin + 3.2.0 + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/META-INF/archetype-post-generate.groovy b/maven/cn1app-archetype/src/main/resources/META-INF/archetype-post-generate.groovy new file mode 100644 index 0000000000..19b33eb5e6 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/META-INF/archetype-post-generate.groovy @@ -0,0 +1,234 @@ +import static groovy.io.FileType.* +import java.nio.file.Path + +def rootDir = new java.io.File(request.getOutputDirectory() + "/" + request.getArtifactId()) +def rootPom = new java.io.File(rootDir, "pom.xml") +setupModules(rootPom); +def resolvedJava = resolveJavaVersion(rootDir); +applyJavaVersionTransforms(rootDir, rootPom, resolvedJava); + +/** + * There are a few scripts that need to be executable (or should be) + */ + +// The maven wrapper scripts should be executable +def mvnw = new java.io.File(rootDir, "mvnw") +mvnw.setExecutable(true, false) + +// run.sh should be executable +def runSh = new java.io.File(rootDir, "run.sh") +runSh.setExecutable(true, false) + +// The build.sh should be executable +def buildSh = new java.io.File(rootDir, "build.sh") +buildSh.setExecutable(true, false) + +if (request.getProperties().getProperty("ide", null) == "netbeans") { + def netbeansDir = new java.io.File(rootDir, "tools/netbeans"); + if (netbeansDir.exists()) { + netbeansDir.listFiles().each { + def destFile = new java.io.File(rootDir, it.getName()) + java.nio.file.Files.copy(it.toPath(), destFile.toPath()) + } + } +} + +/** + * For some reason archetype automatically enables ALL modules definied in the archetype-metadata + * even if we only want some of them conditionally enabled. In our case, we only want the common + * module enabled by default. The rest are enabled according to the codename1.platform property. + * @param pomFile + * @return + */ +/** + * The archetype ships codenameone_settings.properties and common/pom.xml with + * `${javaVersion}` Velocity placeholders. With the default `javaVersion=auto` + * those placeholders resolve to the literal string "auto" - we replace it here + * with 17 when the archetype is invoked on a JDK >= 17 and with 8 otherwise. + * If the user passed `-DjavaVersion=8` or `-DjavaVersion=17` explicitly, the + * Velocity pass already substituted that value and there is nothing to do. + * + * Returns the resolved version ("17" or "8") as a string so callers can branch + * on it for non-text-substitution transforms (e.g. dropping the win/ tree). + */ +def resolveJavaVersion(rootDir) { + def settingsFile = new java.io.File(rootDir, "common/codenameone_settings.properties") + def commonPom = new java.io.File(rootDir, "common/pom.xml") + def hasAutoSettings = settingsFile.exists() && settingsFile.text.contains("codename1.arg.java.version=auto") + def hasAutoPom = commonPom.exists() && commonPom.text.contains("auto") + def explicit = readExplicitJavaVersion(settingsFile, commonPom) + + if (!hasAutoSettings && !hasAutoPom) { + return explicit + } + + def resolved = pickJavaVersionFromCurrentJvm() + + if (hasAutoSettings) { + def content = settingsFile.text.replace("codename1.arg.java.version=auto", + "codename1.arg.java.version=" + resolved) + settingsFile.newWriter("UTF-8").withWriter { w -> w << content } + } + if (hasAutoPom) { + def content = commonPom.text + .replace("auto", "" + resolved + "") + .replace("auto", "" + resolved + "") + commonPom.newWriter("UTF-8").withWriter { w -> w << content } + } + return resolved +} + +/** + * When javaVersion is passed explicitly (-DjavaVersion=8 or =17), the Velocity + * pass has already substituted the value into the templates. Read whichever + * source still carries it so applyJavaVersionTransforms can branch correctly. + */ +def readExplicitJavaVersion(settingsFile, commonPom) { + if (settingsFile.exists()) { + def m = (settingsFile.text =~ /(?m)^codename1\.arg\.java\.version=(\d+)$/) + if (m.find()) { + return m.group(1) + } + } + if (commonPom.exists()) { + def m = (commonPom.text =~ /(\d+)<\/source>/) + if (m.find()) { + return m.group(1) + } + } + return "8" +} + +/** + * @return "17" when running on JDK 17 or newer, "8" otherwise. + */ +def pickJavaVersionFromCurrentJvm() { + def specVersion = System.getProperty("java.specification.version", "1.8") + def major + try { + if (specVersion.startsWith("1.")) { + major = Integer.parseInt(specVersion.substring(2)) + } else { + major = Integer.parseInt(specVersion.split("\\.")[0]) + } + } catch (NumberFormatException ignored) { + major = 8 + } + return major >= 17 ? "17" : "8" +} + +/** + * Apply the Java-17-only transforms that the initializr does on its + * server-rendered templates: + * - drop the win/ UWP source tree and the matching block + * from the root pom (the legacy Windows / UWP cloud target is retired for + * Java 17 builds) + * - keep .claude/skills/codename-one/** (the Codename One authoring skill) + * + * For Java 8 projects we do the inverse: keep win/, strip .claude/ so older + * projects don't suddenly grow an AI-agent skill they never opted into. + * + * Also rewrites the IntelliJ misc.xml languageLevel attribute to match the + * resolved JDK (universal cleanup: the project-jdk-name/-type attributes + * are already stripped in the archetype template itself). + */ +def applyJavaVersionTransforms(rootDir, rootPom, resolvedJava) { + if (resolvedJava == "17") { + def winDir = new java.io.File(rootDir, "win") + if (winDir.exists()) { + deleteRecursively(winDir) + } + stripWindowsModuleProfile(rootPom) + } else { + def claudeDir = new java.io.File(rootDir, ".claude") + if (claudeDir.exists()) { + deleteRecursively(claudeDir) + } + } + setIntellijLanguageLevel(rootDir, resolvedJava) +} + +/** + * Match initializr's normalizeIntellijMiscXml: rewrite the `languageLevel` + * attribute on the element to + * JDK_17 for Java 17 projects and JDK_1_8 for Java 8. No-op if misc.xml + * doesn't exist (e.g. user generated without IntelliJ-style .idea files). + */ +def setIntellijLanguageLevel(rootDir, resolvedJava) { + def miscXml = new java.io.File(rootDir, ".idea/misc.xml") + if (!miscXml.exists()) { + return + } + def desired = resolvedJava == "17" ? "JDK_17" : "JDK_1_8" + def content = miscXml.text + def pattern = 'languageLevel="' + def pos = content.indexOf(pattern) + if (pos < 0) { + return + } + def valueStart = pos + pattern.length() + def valueEnd = content.indexOf('"', valueStart) + if (valueEnd < 0) { + return + } + def rewritten = content.substring(0, valueStart) + desired + content.substring(valueEnd) + miscXml.newWriter("UTF-8").withWriter { w -> w << rewritten } +} + +/** + * Mirror of initializr's GeneratorModel.stripWindowsModuleProfile: locate the + * block whose win identifies the UWP profile and remove + * the whole block (and trailing newline) from the root pom. Tolerant of + * indentation. No-op if the profile is not present. + */ +def stripWindowsModuleProfile(pomFile) { + if (!pomFile.exists()) { + return + } + def pom = pomFile.text + def idIdx = pom.indexOf("win") + if (idIdx < 0) { + return + } + def profileStart = pom.lastIndexOf("", idIdx) + if (profileStart < 0) { + return + } + def profileEnd = pom.indexOf("", idIdx) + if (profileEnd < 0) { + return + } + profileEnd += "".length() + while (profileEnd < pom.length() && (pom.charAt(profileEnd) == (char) '\n' || pom.charAt(profileEnd) == (char) '\r')) { + profileEnd++ + } + while (profileStart > 0 && (pom.charAt(profileStart - 1) == (char) ' ' || pom.charAt(profileStart - 1) == (char) '\t')) { + profileStart-- + } + def rewritten = pom.substring(0, profileStart) + pom.substring(profileEnd) + pomFile.newWriter("UTF-8").withWriter { w -> w << rewritten } +} + +def deleteRecursively(file) { + if (file.isDirectory()) { + file.listFiles().each { deleteRecursively(it) } + } + file.delete() +} + +def setupModules(pomFile) { + def content = pomFile.text; + def modulesPos = content.indexOf(""); + def endTag = ""; + + def modulesEndPos = content.indexOf(endTag) + endTag.length(); + def modulesSection = "\ncommon\n"; + + content = content.substring(0, modulesPos) + modulesSection + content.substring(modulesEndPos); + pomFile.newWriter("UTF-8").withWriter { w -> + w << content + } + + +} + diff --git a/maven/cn1app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven/cn1app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..2a9d2e55ab --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,247 @@ + + + + + + 8.0-SNAPSHOT + + + 8.0-SNAPSHOT + + + 1.3.72 + + + + auto + + + + ^[A-Z][a-zA-Z0-9]+$ + + + + + + + + .mvn + + **/*.config + + + + .mvn/wrapper + + ** + + + + .idea + + ** + + + + .vscode + + ** + + + + + .claude + + ** + + + + tools/netbeans + + nb-configuration.xml + nbactions.xml + nbactions-*.xml + + + + + + + .gitignore + *.sh + *.bat + *.adoc + mvnw + mvnw.cmd + + + + + tools/eclipse + + *.launch + + + + + + + + + src/main/java + + **/*.java + + + + src/main/guibuilder + + **/*.gui + + + + src/main/css + + **/*.css + + + + src/main/l10n + + **/*.properties + + + + src/test/java + + **/*.java + + + + + + + + + codenameone_settings.properties + + + + + + icon.png + + + + + + + + src/main/java + + + **/*.java + + + + src/desktop/java + + + **/*.java + + + + src/main/resources + + ** + + + + src/desktop/resources + + ** + + + + + + + + src/main/resources + + ** + + + + src/main/javascript + + ** + + + + + + + + src/main/resources + + ** + + + + src/main/objectivec + + ** + + + + + + + + + src/main/resources + + ** + + + + src/main/java + + **/*.java + + + + + + + + src/main/resources + + ** + + + + src/main/csharp + + **/*.cs + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/.gitignore new file mode 100644 index 0000000000..778c733372 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/.gitignore @@ -0,0 +1,3 @@ +target +build +common/src/main/rad/**.xsd \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/jvm.config b/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/jvm.config new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/MavenWrapperDownloader.java b/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..b901097f2d --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties b/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..642d572ce9 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/extensions.json b/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/extensions.json new file mode 100644 index 0000000000..24d1c3c854 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/extensions.json @@ -0,0 +1 @@ +{"recommendations": ["vscjava.vscode-java-pack"]} \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/settings.json b/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/settings.json new file mode 100644 index 0000000000..a079bcd2cc --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/.vscode/settings.json @@ -0,0 +1,58 @@ +{"maven.terminal.favorites": [ + { + "alias": "Cloud > iOS Release Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=ios\" \"-Dcodename1.buildTarget=ios-device-release\" \"-U\" \"-e\"" + }, + { + "alias": "Tools > Codename One Settings", + "command": "\"cn1:settings\" \"-U\" \"-e\"" + }, + { + "alias": "Run in Simulator", + "command": "\"verify\" \"-Psimulator\" \"-DskipTests\" \"-Dcodename1.platform=javase\" \"-e\"" + }, + { + "alias": "Cloud > Mac Desktop Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=javase\" \"-Dcodename1.buildTarget=mac-os-x-desktop\" \"-U\" \"-e\"" + }, + { + "alias": "Cloud > Android Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=android\" \"-Dcodename1.buildTarget=android-device\" \"-U\" \"-e\"" + }, + { + "alias": "Tools > Update Codename One", + "command": "\"cn1:update\" \"-U\" \"-e\"" + }, + { + "alias": "Cloud > iOS Debug Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=ios\" \"-Dcodename1.buildTarget=ios-device\" \"-U\" \"-e\"" + }, + { + "alias": "Local > Xcode iOS Project", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=ios\" \"-Dcodename1.buildTarget=ios-source\" \"-U\" \"-e\"" + }, + { + "alias": "Cloud > Javascript Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=javascript\" \"-Dcodename1.buildTarget=javascript\" \"-U\" \"-e\"" + }, + { + "alias": "Cloud > Windows Desktop Build", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=javase\" \"-Dcodename1.buildTarget=windows-desktop\" \"-U\" \"-e\"" + }, + { + "alias": "Run as Desktop App", + "command": "\"verify\" \"-Prun-desktop\" \"-DskipTests\" \"-Dcodename1.platform=javase\" \"-e\"" + }, + { + "alias": "Cloud > Windows Device Build (UWP)", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=win\" \"-Dcodename1.buildTarget=windows-device\" \"-U\" \"-e\"" + }, + { + "alias": "Local > Gradle Android Project", + "command": "\"package\" \"-DskipTests\" \"-Dcodename1.platform=android\" \"-Dcodename1.buildTarget=android-source\" \"-U\" \"-e\"" + }, + { + "alias": "Local > Cross-platform (JavaSE) Desktop App", + "command": "\"-Pexecutable-jar\" \"package\" \"-Dcodename1.platform=javase\" \"-DskipTests\" \"-U\" \"-e\"" + } +]} \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/README.adoc b/maven/cn1app-archetype/src/main/resources/archetype-resources/README.adoc new file mode 100644 index 0000000000..3c48268908 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/README.adoc @@ -0,0 +1,43 @@ += Codename One Project + +This is a multi-module maven project for building a Codename One application. Codename One applications written in Java and/or Kotlin, and are built as native apps and can be built and deployed to iOS, Android, Mac, Windows, Linux, and also to the Web. + +== Getting Started + +=== Java + +If you plan to use Java as your primary language, https://shannah.github.io/cn1-maven-archetypes/cn1app-archetype-tutorial/getting-started.html[start here]. + +=== Kotlin + +If you plan to use Kotlin as your primary language, https://shannah.github.io/cn1app-archetype-kotlin-template/getting-started.html[start here]. + + +== Eclipse Users + +IMPORTANT: If you use Eclipse as your IDE, **read this first** + +The _tools/eclipse_ directory contains eclipse ".launch" files that will add common Maven goals as menu items inside Eclipse. + +**After importing this project into Eclipse, you should import the launch files.** + +=== Additional Steps for CodeRAD projects + +CodeRAD includes an annotation processor that needs to be activated. There are a few additional steps required to enable this in Eclipse. + +. Add `org.eclipse.m2e.apt.mode=jdt_apt` to the `./common/.settings/org.eclipse.m2e.apt.prefs` +. Add `target/generated-sources/rad-views` to the .classpath. + +See https://github.com/codenameone/CodenameOne/issues/3724[this issue] for more details. + +== NetBeans Users + +This project is a multi-module Maven project that was generated from a Maven archetype. + +== IntelliJ Users + +The project should work in IntelliJ out of the box. No need to copy any files. + +== Help and Support + +See the https://www.codenameone.com[Codename One Web Site]. \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/android/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/android/pom.xml new file mode 100644 index 0000000000..4b7a2281df --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/android/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + 1.8 + 1.8 + android + android + android-device + + + src/main/empty + + + + src/main/java + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.1 + + + default-jar + none + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + build-android + package + + build + + + + + + + + + + + com.codenameone + codenameone-core + provided + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + tests + test + + + + + + + run-android + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/../common/codenameone_settings.properties + + + + + + + + maven-antrun-plugin + + + adb-install + verify + + run + + + + Running adb install + + + + + + + Trying to start app on device using adb + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/android/src/main/java/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/android/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/android/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/android/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/build.bat b/maven/cn1app-archetype/src/main/resources/archetype-resources/build.bat new file mode 100755 index 0000000000..b7ccc0e212 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/build.bat @@ -0,0 +1,108 @@ +@echo off +setlocal EnableDelayedExpansion +setlocal EnableExtensions + + + +set MVNW=mvnw.cmd + +SET CMD=%1 +if "%CMD%"=="" ( + set CMD=jar +) +goto %CMD% + +goto :EOF +:mac_desktop +!MVNW! package -DskipTests -Dcodename1.platform^=javase -Dcodename1.buildTarget^=mac-os-x-desktop -U -e + +goto :EOF +:windows_desktop +!MVNW! package -DskipTests -Dcodename1.platform^=javase -Dcodename1.buildTarget^=windows-desktop -U -e + +goto :EOF +:windows_device +!MVNW! package -DskipTests -Dcodename1.platform^=win -Dcodename1.buildTarget^=windows-device -U -e + +goto :EOF +:uwp +set /a _0_%~2=^(1 + %~2^) +call :windows_device _1_%~2 !_0_%~2! +echo | set /p ^=!_1_%~2! + +goto :EOF +:javascript +!MVNW! package -DskipTests -Dcodename1.platform^=javascript -Dcodename1.buildTarget^=javascript -U -e + +goto :EOF +:android +!MVNW! package -DskipTests -Dcodename1.platform^=android -Dcodename1.buildTarget^=android-device -U -e + +goto :EOF +:xcode +!MVNW! package -DskipTests -Dcodename1.platform^=ios -Dcodename1.buildTarget^=ios-source -U -e + +goto :EOF +:ios_source +set /a _0_%~2=^(1 + %~2^) +call :xcode _1_%~2 !_0_%~2! +echo | set /p ^=!_1_%~2! + +goto :EOF +:android_source +!MVNW! package -DskipTests -Dcodename1.platform^=android -Dcodename1.buildTarget^=android-source -U -e + +goto :EOF +:ios +!MVNW! package -DskipTests -Dcodename1.platform^=ios -Dcodename1.buildTarget^=ios-device -U -e + +goto :EOF +:ios_release +!MVNW! package -DskipTests -Dcodename1.platform^=ios -Dcodename1.buildTarget^=ios-device-release -U -e + +goto :EOF +:jar +!MVNW! -Pexecutable-jar package -Dcodename1.platform^=javase -DskipTests -U -e + +goto :EOF +:help +echo build.sh [COMMAND] +echo Local Build Commands: +echo The following commands will build the app locally ^(i.e. does NOT use the Codename One build server^) +echo +echo jar +echo Builds app as desktop app executable jar file to javase/target directory +echo android_source +echo Generates an android gradle project that can be opened in Android studio +echo *Requires android development tools installed. +echo *Requires ANDROID_HOME environment variable +echo *Requires either GRADLE_HOME environment variable^, or for gradle to be in PATH +echo ios_source +echo Generates an Xcode Project that you can open and build using Apple^'s development tools +echo *Requires a Mac with Xcode installed +echo +echo Build Server Commands: +echo The following commands will build the app using the Codename One build server^, and require +echo a Codename One account. See https://www.codenameone.com +echo +echo ios +echo Builds iOS app. +echo ios_release +echo Builds iOS app for submission to Apple appstore. +echo android +echo Builds android app. +echo mac_desktop +echo Builds Mac OS desktop app. +echo *Mac OS Desktop builds are a Pro user feature. +echo windows_desktop +echo Builds Windows desktop app. +echo *Windows Desktop builds are a Pro user feature. +echo windows_device +echo Builds UWP Windows app. +echo javascript +echo Builds as a web app. +echo *Javascript builds are an Enterprise user feature + +goto :EOF +:settings +!MVNW! cn:settings -U -e diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/build.sh b/maven/cn1app-archetype/src/main/resources/archetype-resources/build.sh new file mode 100755 index 0000000000..8a99f56684 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/build.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -e +MVNW="./mvnw" + +function mac_desktop { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=javase" "-Dcodename1.buildTarget=mac-os-x-desktop" "-U" "-e" +} +function windows_desktop { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=javase" "-Dcodename1.buildTarget=windows-desktop" "-U" "-e" +} +function windows_device { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=win" "-Dcodename1.buildTarget=windows-device" "-U" "-e" +} +function uwp { + + "windows_device" +} +function javascript { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=javascript" "-Dcodename1.buildTarget=javascript" "-U" "-e" +} +function android { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=android" "-Dcodename1.buildTarget=android-device" "-U" "-e" +} +function xcode { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=ios" "-Dcodename1.buildTarget=ios-source" "-U" "-e" +} +function ios_source { + "xcode" +} +function android_source { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=android" "-Dcodename1.buildTarget=android-source" "-U" "-e" +} +function ios { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=ios" "-Dcodename1.buildTarget=ios-device" "-U" "-e" +} +function ios_release { + + "$MVNW" "package" "-DskipTests" "-Dcodename1.platform=ios" "-Dcodename1.buildTarget=ios-device-release" "-U" "-e" +} +function jar { + + "$MVNW" "-Pexecutable-jar" "package" "-Dcodename1.platform=javase" "-DskipTests" "-U" "-e" +} +function help { + "echo" "-e" "build.sh [COMMAND]" + "echo" "-e" "Local Build Commands:" + "echo" "-e" " The following commands will build the app locally (i.e. does NOT use the Codename One build server)" + "echo" "-e" "" + "echo" "-e" " jar" + "echo" "-e" " Builds app as desktop app executable jar file to javase/target directory" + "echo" "-e" " android_source" + "echo" "-e" " Generates an android gradle project that can be opened in Android studio" + "echo" "-e" " *Requires android development tools installed." + "echo" "-e" " *Requires ANDROID_HOME environment variable" + "echo" "-e" " *Requires either GRADLE_HOME environment variable, or for gradle to be in PATH" + "echo" "-e" " ios_source" + "echo" "-e" " Generates an Xcode Project that you can open and build using Apple's development tools" + "echo" "-e" " *Requires a Mac with Xcode installed" + "echo" "-e" "" + "echo" "-e" "Build Server Commands:" + "echo" "-e" " The following commands will build the app using the Codename One build server, and require" + "echo" "-e" " a Codename One account. See https://www.codenameone.com" + "echo" "-e" "" + "echo" "-e" " ios" + "echo" "-e" " Builds iOS app." + "echo" "-e" " ios_release" + "echo" "-e" " Builds iOS app for submission to Apple appstore." + "echo" "-e" " android" + "echo" "-e" " Builds android app." + "echo" "-e" " mac_desktop" + "echo" "-e" " Builds Mac OS desktop app." + "echo" "-e" " *Mac OS Desktop builds are a Pro user feature." + "echo" "-e" " windows_desktop" + "echo" "-e" " Builds Windows desktop app." + "echo" "-e" " *Windows Desktop builds are a Pro user feature." + "echo" "-e" " windows_device" + "echo" "-e" " Builds UWP Windows app." + "echo" "-e" " javascript" + "echo" "-e" " Builds as a web app." + "echo" "-e" " *Javascript builds are an Enterprise user feature" +} +function settings { + + "$MVNW" "cn:settings" "-U" "-e" +} +CMD="$1" + +if [ "$CMD" == "" ]; then + CMD="jar" +fi +"$CMD" \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/cn1libs/index.txt b/maven/cn1app-archetype/src/main/resources/archetype-resources/cn1libs/index.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/codenameone_settings.properties b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/codenameone_settings.properties new file mode 100644 index 0000000000..0c97f8d197 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/codenameone_settings.properties @@ -0,0 +1,36 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +codename1.android.keystore= +codename1.android.keystoreAlias= +codename1.android.keystorePassword= +codename1.arg.ios.newStorageLocation=true +# Modern native themes (iOS liquid-glass + Material 3) - opt-in. +codename1.arg.nativeTheme=modern +codename1.arg.ios.themeMode=modern +codename1.arg.and.themeMode=modern +codename1.arg.java.version=${javaVersion} +codename1.displayName=${mainName} +codename1.icon=icon.png +codename1.ios.appid=Q5GHSKAL2F.${package} +codename1.ios.certificate= +codename1.ios.certificatePassword= +codename1.ios.debug.certificate= +codename1.ios.debug.certificatePassword= +codename1.ios.debug.provision= +codename1.ios.provision= +codename1.ios.release.certificate= +codename1.ios.release.certificatePassword= +codename1.ios.release.provision= +codename1.j2me.nativeTheme=nbproject/nativej2me.res +codename1.kotlin=false +codename1.languageLevel=5 +codename1.mainName=${mainName} +codename1.packageName=${package} +codename1.rim.certificatePassword= +codename1.rim.signtoolCsk= +codename1.rim.signtoolDb= +codename1.secondaryTitle=Hello World +codename1.vendor=CodenameOne +codename1.version=1.0 +codename1.cssTheme=true diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/icon.png b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/icon.png new file mode 100644 index 0000000000..1f4fa5dd25 Binary files /dev/null and b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/icon.png differ diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml new file mode 100644 index 0000000000..8e7bb8b8c6 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml @@ -0,0 +1,376 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + jar + + + + + com.codenameone + codenameone-core + provided + + + + + + + + + + + install-codenameone + ${user.home}/.codenameone/guibuilder.jar + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + validate + + run + + + + + + + + + + + + + + + + + + + + + + + + + kotlin + + + + ${basedir}/src/main/kotlin + + + + ${kotlinVersion} + true + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/codenameone_settings.properties + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + -no-reflect + -no-jdk + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + -no-reflect + -no-jdk + + + + + + + + + + + + + javase + + + codename1.platform + javase + + + + javase + + + + + org.codehaus.mojo + exec-maven-plugin + + java + true + + -Xmx1024M + + -classpath + + ${exec.mainClass} + ${cn1.mainClass} + + + + + + + + + + simulator + + javase + + + + + + ios-debug + + + iphone + + + ios + + + + + ios-release + + + iphone + true + + + ios + true + + + + + javascript + + javascript + javascript + + + + + android + + android + android + + + + + uwp + + windows + win + + + + + windows + + desktop_windows + javase + + + + + mac + + desktop_macosx + javase + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${javaVersion} + ${javaVersion} + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/codenameone_settings.properties + + + + + + + + com.codenameone + codenameone-maven-plugin + + + + generate-gui-sources + process-sources + + generate-gui-sources + + + + cn1-process-classes + process-classes + + compliance-check + css + + + + + attach-test-artifact + test + + attach-test-artifact + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css new file mode 100644 index 0000000000..83dc6eb8ff --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css @@ -0,0 +1,69 @@ +/** Define Theme Constants here */ +#Constants { + includeNativeBool: true; + defaultSourceDPIInt: "0"; +} + +/** Style for Button class */ +Button { + font-family: "native:MainLight"; + font-size: 3mm; +} + +/** Style for App Title Bar Text */ +Title { + font-family: "native:MainLight"; + font-size: 6mm; +} + +/** Style for Dialog body */ +DialogBody { + font-family: "native:MainLight"; + font-size: 2.8mm; +} + +/** Style for Dialog title bar text */ +DialogTitle { + font-family: "native:MainLight"; + font-size: 4.5mm; +} + +/** Style for the side menu */ +SideNavigationPanel { + background: white; + padding: 2mm 1mm 1mm 1mm; +} + +@media platform-ios { + /** iOS Only styles for side menu. */ + SideNavigationPanel { + /** Extra top padding to deal with notch on iPhoneX */ + padding: 6mm 1mm 1mm 1mm; + } +} + +/** Style for commands in side menu. */ +SideCommand { + padding: 1mm; + border: none; + text-decoration: none; + color: black; + font-family: "native:MainLight"; + font-size: 4mm; + border-bottom: 2px solid #cccccc; +} + +/* Dark mode example - uncomment to override styles when the + * device is in dark mode: + * + * @media (prefers-color-scheme: dark) { + * SideNavigationPanel { + * background: #0f172a; + * } + * SideCommand { + * color: #e2e8f0; + * background: #0f172a; + * border-bottom: 2px solid #334155; + * } + * } + */ diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/java/__mainName__.java b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/java/__mainName__.java new file mode 100644 index 0000000000..a415a02bd8 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/java/__mainName__.java @@ -0,0 +1,34 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import static com.codename1.ui.CN.*; +import com.codename1.system.Lifecycle; +import com.codename1.ui.*; +import com.codename1.ui.layouts.*; +import com.codename1.io.*; +import com.codename1.ui.plaf.*; +import com.codename1.ui.util.Resources; + +/** + * This file was generated by Codename One for the purpose + * of building native mobile applications using Java. + */ +public class ${mainName} extends Lifecycle { + @Override + public void runApp() { + Form hi = new Form("Hi World", BoxLayout.y()); + Button helloButton = new Button("Hello World"); + hi.add(helloButton); + helloButton.addActionListener(e -> hello()); + hi.getToolbar().addMaterialCommandToSideMenu("Hello Command", + FontImage.MATERIAL_CHECK, 4, e -> hello()); + hi.show(); + } + + private void hello() { + Dialog.show("Hello Codename One", "Welcome to Codename One", "OK", null); + } + +} diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/l10n/Bundle.properties b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/l10n/Bundle.properties new file mode 100644 index 0000000000..c07a695976 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/l10n/Bundle.properties @@ -0,0 +1,3 @@ +# Workaround for the simulator AutoLocalizationBundle @im fabrication crash +# in Codename One <= 7.0.236. Once the framework fix ships, this file can be removed. +@im= diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/test/java/MyFirstTest.java b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/test/java/MyFirstTest.java new file mode 100644 index 0000000000..8d8a935e15 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/src/test/java/MyFirstTest.java @@ -0,0 +1,26 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ${groupId}; + +import com.codename1.testing.AbstractTest; + +/** + * + * @author shannah + */ +public class MyFirstTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + return true; + } + + +} diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/pom.xml new file mode 100644 index 0000000000..e27c975512 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + 1.8 + 1.8 + ios + ios + ios-device + + + + + src/main/objectivec + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.1 + + + default-jar + none + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + build-ios + package + + build + + + + + + + + + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + tests + test + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/java/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/objectivec/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/objectivec/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/ios/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/pom.xml new file mode 100644 index 0000000000..b10a83171e --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + 1.8 + 1.8 + javascript + javascript + javascript + + + + + src/main/javascript + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.4.1 + + + default-jar + none + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + build-javascript + package + + build + + + + + + + + + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + tests + test + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/java/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/javascript/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/javascript/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/javascript/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/pom.xml new file mode 100644 index 0000000000..e7204a9aa8 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/pom.xml @@ -0,0 +1,788 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + 1.8 + 1.8 + javase + javase + + + ${project.basedir}/../common/src/test/java + + + codenameone-maven-plugin + com.codenameone + ${cn1.plugin.version} + + + add-se-sources + + generate-javase-sources + + generate-sources + + + + + + + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + tests + test + + + com.codenameone + codenameone-core + test + + + com.codenameone + codenameone-core + provided + + + com.codenameone + codenameone-javase + test + + + com.codenameone + codenameone-javase + provided + + + + + + + + executable-jar + + javase + ${package}.${mainName}Stub + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + src/main/resources + src/desktop/resources + + + + org.codehaus.mojo + properties-maven-plugin + 1.0.0 + + + initialize + + read-project-properties + + + + ${basedir}/../common/codenameone_settings.properties + + + + + + + com.codenameone + codenameone-maven-plugin + + + generate-icons + generate-sources + + generate-desktop-app-wrapper + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + prepare-package + + copy-dependencies + + + + ${project.build.directory}/libs + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + libs/ + + ${codename1.packageName}.${codename1.mainName}Stub + + + + + + + maven-antrun-plugin + + + generate-javase-zip + package + + + + + + + + + + + + + + + + + run + + + + + + + + + + + run-desktop + + javase + ${package}.${mainName}Stub + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + src/main/resources + src/desktop/resources + + + + com.codenameone + codenameone-maven-plugin + + + generate-icons + generate-sources + + generate-desktop-app-wrapper + + + + + + org.codehaus.mojo + exec-maven-plugin + + + run-desktop + verify + + java + + + + + + + + + + desktop_build + + + codename1.buildTarget + + + + + com.codenameone + codenameone-core + provided + + + com.codenameone + codenameone-javase + provided + + + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + build-desktop-macosx + package + + build + + + + + + + + + + + test + + + true + + + + javase + com.codename1.impl.javase.Simulator + + + + com.codenameone + codenameone-core + compile + + + + com.codenameone + codenameone-javase + compile + + + + + + com.codenameone + codenameone-maven-plugin + + + + + cn1-tests + test + + test + + + + + + + + + + + + debug-simulator + + javase + com.codename1.impl.javase.Simulator + true + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + + com.codenameone + codenameone-maven-plugin + + + prepare-simulator-environment + initialize + + prepare-simulator-classpath + + + + + + + org.codehaus.mojo + exec-maven-plugin + + ${basedir}/../common + + java + true + + + -Xdebug + -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} + -Xmx1024M + -Xmx1024M + + + + + -Dcef.dir=${cef.dir} + + + -Dcodename1.designer.jar=${codename1.designer.jar} + + + -Dcodename1.css.compiler.args.input=${codename1.css.compiler.args.input} + + + -Dcodename1.css.compiler.args.output=${codename1.css.compiler.args.output} + + + -Dcodename1.css.compiler.args.merge=${codename1.css.compiler.args.merge} + ${codename1.exec.args.debug} + ${codename1.exec.args.runjdwp.transport} + -classpath + + ${exec.mainClass} + ${codename1.mainClass} + + + + + run-in-simulator + verify + + exec + + + + + + + + + + + debug-eclipse + + javase + com.codename1.impl.javase.Simulator + true + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + + com.codenameone + codenameone-maven-plugin + + + prepare-simulator-environment + initialize + + prepare-simulator-classpath + + + + + + + org.codehaus.mojo + exec-maven-plugin + + ${basedir}/../common + + java + true + + + -Xdebug + -Xrunjdwp:transport=dt_socket,server=y,address=${jpda.address},suspend=y + -Xmx1024M + -Xmx1024M + + + + + -Dcef.dir=${cef.dir} + + + -Dcodename1.designer.jar=${codename1.designer.jar} + + + -Dcodename1.css.compiler.args.input=${codename1.css.compiler.args.input} + + + -Dcodename1.css.compiler.args.output=${codename1.css.compiler.args.output} + + + -Dcodename1.css.compiler.args.merge=${codename1.css.compiler.args.merge} + ${codename1.exec.args.debug} + ${codename1.exec.args.runjdwp.transport} + -classpath + + ${exec.mainClass} + ${codename1.mainClass} + + + + + run-in-simulator + verify + + exec + + + + + + + + + + simulator + + javase + com.codename1.impl.javase.Simulator + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + com.codenameone + codenameone-maven-plugin + + + prepare-simulator-environment + initialize + + prepare-simulator-classpath + + + + + + + org.codehaus.mojo + exec-maven-plugin + + ${basedir}/../common + + java + true + + -Xmx1024M + + + -Dcef.dir=${cef.dir} + + + -Dcodename1.designer.jar=${codename1.designer.jar} + + + -Dcodename1.css.compiler.args.input=${codename1.css.compiler.args.input} + + + -Dcodename1.css.compiler.args.output=${codename1.css.compiler.args.output} + + + -Dcodename1.css.compiler.args.merge=${codename1.css.compiler.args.merge} + ${codename1.exec.args.debug} + ${codename1.exec.args.runjdwp.transport} + -classpath + + ${exec.mainClass} + ${codename1.mainClass} + + + + + run-in-simulator + verify + + exec + + + + + + + + + + idea-simulator + + javase + com.codename1.impl.javase.Simulator + true + + + + com.codenameone + codenameone-core + compile + + + com.codenameone + codenameone-javase + compile + + + + + + + com.codenameone + codenameone-maven-plugin + + + prepare-simulator-environment + initialize + + + prepare-simulator-classpath + + + + + + + org.codehaus.mojo + exec-maven-plugin + + + + ${basedir}/../common + + true + + ${codename1.mainClass} + + + + + + cef.dir + ${cef.dir} + + + + codename1.designer.jar + ${codename1.designer.jar} + + + + codename1.css.compiler.args.input + ${codename1.css.compiler.args.input} + + + + codename1.css.compiler.args.output + ${codename1.css.compiler.args.output} + + + + codename1.css.compiler.args.merge + ${codename1.css.compiler.args.merge} + + + + + cn1.class.path + ${cn1.class.path} + + + + + + + + run-in-simulator-idea + verify + + java + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/java/__mainName__Stub.java b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/java/__mainName__Stub.java new file mode 100644 index 0000000000..b867938c88 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/java/__mainName__Stub.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Codename One designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Codename One through http://www.codenameone.com/ if you + * need additional information or have any questions. + */ + +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import com.codename1.impl.javase.JavaSEPort; +import com.codename1.ui.Display; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Toolkit; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.io.File; +import java.util.Arrays; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/** + * A wrapper class around a Codename One app, allows building desktop Java + * applications. + * + * @author Shai Almog + */ +public class ${mainName}Stub implements Runnable, WindowListener { + private static final String APP_TITLE = "Hi World"; + private static final String APP_NAME = "${mainName}"; + private static final String APP_VERSION = "1.0"; + private static final int APP_WIDTH = 800; + private static final int APP_HEIGHT = 600; + private static final boolean APP_ADAPT_TO_RETINA = true; + private static final boolean APP_RESIZEABLE = true; + private static final boolean APP_FULLSCREEN = false; + public static final String BUILD_KEY = ""; + public static final String PACKAGE_NAME = ""; + public static final String BUILT_BY_USER = ""; + private static final boolean isWindows; + static { + isWindows = File.separatorChar == '\\'; + } + + private static final String[] fontFaces = null; + + private static JFrame frm; + private ${mainName} mainApp; + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + try { + Class.forName("org.cef.CefApp"); + System.setProperty("cn1.javase.implementation", "cef"); + //System.setProperty("cn1.cef.bundled", "true"); + } catch (Throwable ex){} + + JavaSEPort.setNativeTheme("/NativeTheme.res"); + JavaSEPort.blockMonitors(); + JavaSEPort.setAppHomeDir("." + APP_NAME); + JavaSEPort.setExposeFilesystem(true); + JavaSEPort.setTablet(true); + JavaSEPort.setUseNativeInput(true); + JavaSEPort.setShowEDTViolationStacks(false); + JavaSEPort.setShowEDTWarnings(false); + JavaSEPort.setFullScreen(APP_FULLSCREEN); + + if(fontFaces != null) { + JavaSEPort.setFontFaces(fontFaces[0], fontFaces[1], fontFaces[2]); + } else { + // workaround for a bug in Windows where Arials unicode version isn't used + if(isWindows) { + JavaSEPort.setFontFaces("ArialUnicodeMS", "SansSerif", "Monospaced"); + } else { + JavaSEPort.setFontFaces("Arial", "SansSerif", "Monospaced"); + } + } + + + frm = new JFrame(APP_TITLE); + Toolkit tk = Toolkit.getDefaultToolkit(); + JavaSEPort.setDefaultPixelMilliRatio(tk.getScreenResolution() / 25.4 * JavaSEPort.getRetinaScale()); + Display.init(frm.getContentPane()); + Display.getInstance().setProperty("build_key", BUILD_KEY); + Display.getInstance().setProperty("package_name", PACKAGE_NAME); + Display.getInstance().setProperty("built_by_user", BUILT_BY_USER); + //placeholder + Display.getInstance().setProperty("AppName", APP_NAME); + Display.getInstance().setProperty("AppVersion", APP_VERSION); + Display.getInstance().setProperty("Platform", System.getProperty("os.name")); + Display.getInstance().setProperty("OSVer", System.getProperty("os.version")); + + SwingUtilities.invokeLater(new ${mainName}Stub()); + } + + public void run() { + frm.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + frm.addWindowListener(this); + ImageIcon ic16 = new ImageIcon(getClass().getResource("/applicationIconImage_16x16.png")); + ImageIcon ic20 = new ImageIcon(getClass().getResource("/applicationIconImage_16x16.png")); + ImageIcon ic32 = new ImageIcon(getClass().getResource("/applicationIconImage_16x16.png")); + ImageIcon ic40 = new ImageIcon(getClass().getResource("/applicationIconImage_16x16.png")); + ImageIcon ic64 = new ImageIcon(getClass().getResource("/applicationIconImage_16x16.png")); + frm.setIconImages(Arrays.asList(ic16.getImage(), ic20.getImage(), ic32.getImage(), ic40.getImage(), ic64.getImage())); + GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + if(APP_FULLSCREEN && gd.isFullScreenSupported()) { + frm.setResizable(false); + frm.setUndecorated(true); + gd.setFullScreenWindow(frm); + + } else { + frm.setLocationByPlatform(true); + frm.setResizable(APP_RESIZEABLE); + int w = APP_WIDTH; + int h = APP_HEIGHT; + + frm.getContentPane().setPreferredSize(new java.awt.Dimension(w, h)); + frm.getContentPane().setMinimumSize(new java.awt.Dimension(w, h)); + frm.getContentPane().setMaximumSize(new java.awt.Dimension(w, h)); + + // replaceable with the build hint desktop.framePrepare + framePrepare(frm); + } + Display.getInstance().callSerially(new Runnable() { + @Override + public void run() { + if(Display.getInstance().isEdt()) { + mainApp = new ${mainName}(); + mainApp.init(this); + mainApp.start(); + SwingUtilities.invokeLater(this); + } else { + + // replaceable with the build hint desktop.frameShow + frameShow(frm); + } + } + }); + } + + private void framePrepare(JFrame frm) { + frm.pack(); + } + + private void frameShow(JFrame frm) { + frm.setVisible(true); + } + + @Override + public void windowOpened(WindowEvent e) { + } + + @Override + public void windowClosing(WindowEvent e) { + Display.getInstance().callSerially(new Runnable() { + @Override + public void run() { + mainApp.stop(); + mainApp.destroy(); + Display.getInstance().exitApplication(); + } + }); + } + + @Override + public void windowClosed(WindowEvent e) { + } + + @Override + public void windowIconified(WindowEvent e) { + } + + @Override + public void windowDeiconified(WindowEvent e) { + } + + @Override + public void windowActivated(WindowEvent e) { + } + + @Override + public void windowDeactivated(WindowEvent e) { + // fix for https://stackoverflow.com/questions/6178132/fullscreen-java-app-minimizes-when-screensaver-turns-on + if(APP_FULLSCREEN) { + GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + frm.setExtendedState(JFrame.MAXIMIZED_BOTH); + if(gd.isFullScreenSupported()) { + frm.setResizable(false); + frm.setUndecorated(true); + gd.setFullScreenWindow(frm); + } + } + } +} diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/resources/NativeTheme.res b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/resources/NativeTheme.res new file mode 100644 index 0000000000..83e067b696 Binary files /dev/null and b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/desktop/resources/NativeTheme.res differ diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/main/java/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/javase/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnconfig.toml b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnconfig.toml new file mode 100644 index 0000000000..a3cda4472e --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnconfig.toml @@ -0,0 +1,72 @@ +[simulator] +command=["$MVNW", "verify", "-Psimulator", "-DskipTests", "-Dcodename1.platform=javase", "-e"] +label="Run in Simulator" +run=true + +[desktop] +command=["$MVNW", "verify", "-Prun-desktop", "-DskipTests", "-Dcodename1.platform=javase" "-e"] +label="Run as Desktop App" +run=true + +[android] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=android", "-Dcodename1.buildTarget=android-device", "-U", "-e"] +label="Android Build" +group="Cloud" + +[ios] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=ios", "-Dcodename1.buildTarget=ios-device", "-U", "-e"] +label="iOS Debug Build" +group="Cloud" + +[ios_release] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=ios", "-Dcodename1.buildTarget=ios-device-release", "-U", "-e"] +label="iOS Release Build" +group="Cloud" + +[javascript] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=javascript", "-Dcodename1.buildTarget=javascript", "-U", "-e"] +label="Javascript Build" +group="Cloud" + +[mac_desktop] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=javase", "-Dcodename1.buildTarget=mac-os-x-desktop", "-U", "-e"] +label="Mac Desktop Build" +group="Cloud" + +[windows_desktop] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=javase", "-Dcodename1.buildTarget=windows-desktop", "-U", "-e"] +label="Windows Desktop Build" +group="Cloud" + +[windows_device] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=win", "-Dcodename1.buildTarget=windows-device", "-U", "-e"] +label="Windows Device Build (UWP)" +group="Cloud" + + +[xcode] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=ios", "-Dcodename1.buildTarget=ios-source", "-U", "-e"] +label="Xcode iOS Project" +group="Local" + + +[android_source] +command=["$MVNW", "package", "-DskipTests", "-Dcodename1.platform=android", "-Dcodename1.buildTarget=android-source", "-U", "-e"] +label="Gradle Android Project" +group="Local" + +[jar] +command=["$MVNW", "-Pexecutable-jar", "package", "-Dcodename1.platform=javase", "-DskipTests", "-U", "-e"] +label="Cross-platform (JavaSE) Desktop App" +group="Local" +build=true + +[settings] +command=["$MVNW", "cn1:settings", "-U", "-e"] +label="Codename One Settings" +group="Tools" + +[update] +command=["$MVNW", "cn1:update", "-U", "-e"] +label="Update Codename One" +group="Tools" diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw new file mode 100755 index 0000000000..41c0f0c23d --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw.cmd b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw.cmd new file mode 100644 index 0000000000..86115719e5 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..a743a2ecbf --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,211 @@ + + + 4.0.0 + + ${groupId} + ${artifactId} + ${version} + pom + + ${artifactId} + ${artifactId} + https://www.codenameone.com + + + + GPL v2 With Classpath Exception + https://openjdk.java.net/legal/gplv2+ce.html + repo + A business-friendly OSS license + + + + + common + + + + ${cn1PluginVersion} + ${cn1Version} + UTF-8 + + 1.8 + 11 + 1.7.11 + 3.8.0 + 1.8 + 1.8 + 1.8 + ${artifactId} + + + + + + + + + + com.codenameone + java-runtime + ${cn1.version} + + + com.codenameone + codenameone-core + ${cn1.version} + + + com.codenameone + codenameone-javase + ${cn1.version} + + + + com.codenameone + codenameone-buildclient + ${cn1.version} + system + ${user.home}/.codenameone/CodeNameOneBuildClient.jar + + + + + + + + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + maven-antrun-plugin + org.apache.maven.plugins + 3.1.0 + + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + + + + + + + + + + + + + + + javascript + + + codename1.platform + javascript + + + + javascript + + + + ios + + + codename1.platform + ios + + + + ios + + + + win + + + codename1.platform + win + + + + win + + + + android + + + codename1.platform + android + + + + android + + + + javase + + + codename1.platform + javase + + true + + + javase + + + + cn1libs + + + ${basedir}/cn1libs/pom.xml + + + + cn1libs + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/run.bat b/maven/cn1app-archetype/src/main/resources/archetype-resources/run.bat new file mode 100755 index 0000000000..f8b979c32a --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/run.bat @@ -0,0 +1,40 @@ +@echo off +setlocal EnableDelayedExpansion +setlocal EnableExtensions + + +set MVNW=mvnw.cmd + +SET CMD=%1 +if "%CMD%"=="" ( + set CMD=simulator +) +goto %CMD% + +:simulator +!MVNW! verify -Psimulator -DskipTests -Dcodename1.platform^=javase -e + +goto :EOF +:desktop +!MVNW! verify -Prun-desktop -DskipTests -Dcodename1.platform^=javase -e + +goto :EOF +:settings +!MVNW! cn1:settings -e + +goto :EOF +:update +!MVNW! cn1:update -U -e + +goto :EOF +:help +echo run.bat [COMMAND] +echo Commands: +echo simulator +echo Runs app using Codename One Simulator +echo desktop +echo Runs app as a desktop app. +echo settings +echo Opens Codename One settings +echo update +echo Update Codename One libraries diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/run.sh b/maven/cn1app-archetype/src/main/resources/archetype-resources/run.sh new file mode 100755 index 0000000000..ef0a12cbe5 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/run.sh @@ -0,0 +1,37 @@ +#!/bin/bash +MVNW="./mvnw" + +function simulator { + + "$MVNW" "verify" "-Psimulator" "-DskipTests" "-Dcodename1.platform=javase" "-e" +} +function desktop { + + "$MVNW" "verify" "-Prun-desktop" "-DskipTests" "-Dcodename1.platform=javase" "-e" +} +function settings { + + "$MVNW" "cn1:settings" "-e" +} +function update { + + "$MVNW" "cn1:update" "-U" "-e" +} +function help { + "echo" "-e" "run.sh [COMMAND]" + "echo" "-e" "Commands:" + "echo" "-e" " simulator" + "echo" "-e" " Runs app using Codename One Simulator" + "echo" "-e" " desktop" + "echo" "-e" " Runs app as a desktop app." + "echo" "-e" " settings" + "echo" "-e" " Opens Codename One settings" + "echo" "-e" " update" + "echo" "-e" " Update Codename One libraries" +} +CMD=$1 + +if [ "$CMD" == "" ]; then + CMD="simulator" +fi +"$CMD" \ No newline at end of file diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/ECLIPSE_README.adoc b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/ECLIPSE_README.adoc new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build Android Studio Project.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build Android Studio Project.launch new file mode 100644 index 0000000000..cf583a463f --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build Android Studio Project.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build JavaSE Desktop App.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build JavaSE Desktop App.launch new file mode 100644 index 0000000000..0cd0764a8b --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build JavaSE Desktop App.launch @@ -0,0 +1,25 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build iOS Xcode Project.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build iOS Xcode Project.launch new file mode 100644 index 0000000000..151112f3ac --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Build iOS Xcode Project.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug Simulator.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug Simulator.launch new file mode 100644 index 0000000000..b36d4f0efc --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug Simulator.launch @@ -0,0 +1,24 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug in Simulator.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug in Simulator.launch new file mode 100644 index 0000000000..b5479c7335 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Debug in Simulator.launch @@ -0,0 +1,18 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Remote Debug Simulator.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Remote Debug Simulator.launch new file mode 100644 index 0000000000..c90df783e0 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Remote Debug Simulator.launch @@ -0,0 +1,17 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Desktop.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Desktop.launch new file mode 100644 index 0000000000..983709bec7 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Desktop.launch @@ -0,0 +1,25 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Simulator.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Simulator.launch new file mode 100644 index 0000000000..41e0d022a5 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Run Simulator.launch @@ -0,0 +1,25 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Android Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Android Build.launch new file mode 100644 index 0000000000..c458d55425 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Android Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Javascript Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Javascript Build.launch new file mode 100644 index 0000000000..a39094edd9 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Javascript Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Mac Desktop Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Mac Desktop Build.launch new file mode 100644 index 0000000000..b9e370f054 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Mac Desktop Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows Desktop Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows Desktop Build.launch new file mode 100644 index 0000000000..caa1d2b0f0 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows Desktop Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows UWP Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows UWP Build.launch new file mode 100644 index 0000000000..275f539587 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send Windows UWP Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Debug Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Debug Build.launch new file mode 100644 index 0000000000..b72a51a9ac --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Debug Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Release Build.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Release Build.launch new file mode 100644 index 0000000000..659650a44a --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Send iOS Release Build.launch @@ -0,0 +1,26 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Update Codename One.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Update Codename One.launch new file mode 100644 index 0000000000..808bbca179 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ - Update Codename One.launch @@ -0,0 +1,23 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ Settings.launch b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ Settings.launch new file mode 100644 index 0000000000..fb2a9b0a3c --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/eclipse/__mainName__ Settings.launch @@ -0,0 +1,23 @@ +#set ( $d = "$") + + + + + + + + + + + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nb-configuration.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nb-configuration.xml new file mode 100644 index 0000000000..cddcc7d75f --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nb-configuration.xml @@ -0,0 +1,55 @@ + + + + + + + android-device + android + + + android-source + android + + + javase + + + javascript + javascript + + + mac-os-x-desktop + javase + + + javase + + + windows-desktop + javase + + + windows-device + win + + + ios-device + ios + + + ios-device-release + ios + + + ios-source + ios + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Desktop App.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Desktop App.xml new file mode 100644 index 0000000000..53068a1728 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Desktop App.xml @@ -0,0 +1,12 @@ + + + + run + + verify + + + true + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-JavaSE Desktop App.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-JavaSE Desktop App.xml new file mode 100644 index 0000000000..f1c86c5acb --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-JavaSE Desktop App.xml @@ -0,0 +1,112 @@ + + + + run + + verify + + + true + + + run-desktop + + + + build + + * + + + package + + + true + + + executable-jar + + + + rebuild + + * + + + clean + package + + + true + + + executable-jar + + + + test + + * + + + test + + + simulator + + + + + clean + + * + + + clean + + + executable-jar + + + + build-with-dependencies + also-make + + * + + + package + + + executable-jar + + + + CUSTOM-Generate iOS Xcode Project + Generate iOS Xcode Project + + package + + + ios + ios-source + true + + + !run-desktop + + + + debug + + verify + + + true + true + + + debug-simulator + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Simulator.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Simulator.xml new file mode 100644 index 0000000000..b9707637fc --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions-Simulator.xml @@ -0,0 +1,90 @@ + + + + run + + verify + + + true + + + simulator + + + + debug + + verify + + + + javase + true + true + + + debug-simulator + !simulator + + + + build + + * + + + package + + + true + + + executable-jar + !simulator + + + + rebuild + + * + + + clean + package + + + true + + + executable-jar + !simulator + + + + build-with-dependencies + also-make + + * + + + package + + + true + + + executable-jar + !simulator + + + + test + + * + + + test + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions.xml new file mode 100644 index 0000000000..eab8d61a95 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/tools/netbeans/nbactions.xml @@ -0,0 +1,149 @@ + + + + run + + verify + + + true + javase + + + simulator + + + + debug + + verify + + + true + javase + true + + + + + + + + + + + debug-simulator + + + + CUSTOM-Open Control Center + Open Control Center + + cn1:settings + + + + build + + * + + + package + + + true + + android-device + + + + clean + + * + + + clean + + + true + + + + + + rebuild + + * + + + clean + package + + + true + + android-device + + + + build-with-dependencies + also-make + + * + + + package + + + true + + android-device + + + + test + + * + + + test + + + + javase + + + + simulator + + + + CUSTOM-Open in GUI Builder + Open in GUI Builder + + cn1:guibuilder + + + ${packageClassName} + + + + + + + CUSTOM-Update Codename One + Update Codename One + + cn1:update + + + + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/win/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/win/pom.xml new file mode 100644 index 0000000000..43ca76a724 --- /dev/null +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/win/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + 1.8 + 1.8 + win + win + windows-device + + + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + build-android + package + + build + + + + + + + + + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + + + ${project.groupId} + ${cn1app.name}-common + ${project.version} + tests + test + + + + + + + + + diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/win/src/main/csharp/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/win/src/main/csharp/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/win/src/main/resources/.gitignore b/maven/cn1app-archetype/src/main/resources/archetype-resources/win/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/archetype.properties b/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/archetype.properties new file mode 100644 index 0000000000..70358376f5 --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/archetype.properties @@ -0,0 +1,10 @@ +#Wed May 07 10:30:00 IDT 2026 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=auto-jdk +cn1Version=8.0-SNAPSHOT +cn1PluginVersion=8.0-SNAPSHOT +mainName=HelloWorldAutoJdk +kotlinVersion=1.4.32 +javaVersion=auto diff --git a/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/goal.txt b/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/goal.txt new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/auto-jdk/goal.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/maven/cn1app-archetype/src/test/resources/projects/basic/archetype.properties b/maven/cn1app-archetype/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..39822b0e83 --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,10 @@ +#Fri Jan 15 05:57:03 PST 2021 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +cn1Version=8.0-SNAPSHOT +cn1PluginVersion=8.0-SNAPSHOT +mainName=HelloWorldBasic +kotlinVersion=1.4.32 +javaVersion=8 diff --git a/maven/cn1app-archetype/src/test/resources/projects/basic/goal.txt b/maven/cn1app-archetype/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/basic/goal.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/maven/cn1app-archetype/src/test/resources/projects/netbeans/archetype.properties b/maven/cn1app-archetype/src/test/resources/projects/netbeans/archetype.properties new file mode 100644 index 0000000000..9c2d2f685d --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/netbeans/archetype.properties @@ -0,0 +1,11 @@ +#Fri Jan 15 05:57:03 PST 2021 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=netbeans +cn1Version=8.0-SNAPSHOT +cn1PluginVersion=8.0-SNAPSHOT +mainName=HelloWorldBasic +kotlinVersion=1.4.32 +javaVersion=8 +ide=netbeans diff --git a/maven/cn1app-archetype/src/test/resources/projects/netbeans/goal.txt b/maven/cn1app-archetype/src/test/resources/projects/netbeans/goal.txt new file mode 100644 index 0000000000..30d74d2584 --- /dev/null +++ b/maven/cn1app-archetype/src/test/resources/projects/netbeans/goal.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/maven/cn1lib-archetype/pom.xml b/maven/cn1lib-archetype/pom.xml new file mode 100644 index 0000000000..ef32b5a104 --- /dev/null +++ b/maven/cn1lib-archetype/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + com.codenameone + codenameone + 8.0-SNAPSHOT + + cn1lib-archetype + maven-archetype + + cn1lib-archetype + Codename One cn1lib (library) project archetype. + + + + true + + + + + + org.apache.maven.archetype + archetype-packaging + 3.2.0 + + + + + + + maven-archetype-plugin + 3.2.0 + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/META-INF/archetype-post-generate.groovy b/maven/cn1lib-archetype/src/main/resources/META-INF/archetype-post-generate.groovy new file mode 100644 index 0000000000..0db55db3a5 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/META-INF/archetype-post-generate.groovy @@ -0,0 +1,156 @@ +import static groovy.io.FileType.* + +def rootDir = new java.io.File(request.getOutputDirectory() + "/" + request.getArtifactId()) +def rootPom = new java.io.File(rootDir, "pom.xml") +def resolvedJava = resolveJavaVersion(rootDir) +applyJavaVersionTransforms(rootDir, rootPom, resolvedJava) + +/** + * Mirrors cn1app-archetype's resolveJavaVersion: when the archetype was + * invoked with javaVersion=auto (the default), Velocity will have left the + * literal "auto" string in the rewritten templates. Replace those with the + * resolved version ("17" on JDK >= 17, else "8") so the generated project + * compiles out of the box. + * + * When -DjavaVersion=8 or =17 is passed explicitly, Velocity has already + * substituted the value and there is nothing here to rewrite — but we still + * read the value back from the templates so applyJavaVersionTransforms can + * branch on it. + */ +def resolveJavaVersion(rootDir) { + def requiredProps = new java.io.File(rootDir, "common/codenameone_library_required.properties") + def commonPom = new java.io.File(rootDir, "common/pom.xml") + def rootPom = new java.io.File(rootDir, "pom.xml") + def javasePom = new java.io.File(rootDir, "javase/pom.xml") + def libPom = new java.io.File(rootDir, "lib/pom.xml") + + def autoSettings = requiredProps.exists() && requiredProps.text.contains("codename1.arg.java.version=auto") + def autoCommonPom = commonPom.exists() && commonPom.text.contains("auto") + def autoRootPom = rootPom.exists() && rootPom.text.contains("auto") + def autoJavasePom = javasePom.exists() && javasePom.text.contains("auto") + def autoLibPom = libPom.exists() && libPom.text.contains("auto") + + if (!autoSettings && !autoCommonPom && !autoRootPom && !autoJavasePom && !autoLibPom) { + return readExplicitJavaVersion(requiredProps, commonPom) + } + + def resolved = pickJavaVersionFromCurrentJvm() + + if (autoSettings) { + rewriteFile(requiredProps, + requiredProps.text.replace("codename1.arg.java.version=auto", + "codename1.arg.java.version=" + resolved)) + } + [rootPom, commonPom, javasePom, libPom].each { f -> + if (f.exists() && f.text.contains("auto")) { + def rewritten = f.text + .replace("auto", + "" + resolved + "") + .replace("auto", + "" + resolved + "") + .replace("auto", "" + resolved + "") + .replace("auto", "" + resolved + "") + if (rewritten != f.text) { + rewriteFile(f, rewritten) + } + } + } + return resolved +} + +/** + * When javaVersion is passed explicitly (-DjavaVersion=8 or =17), Velocity + * has already substituted the literal value into the templates. Read it back + * so applyJavaVersionTransforms can branch correctly. + */ +def readExplicitJavaVersion(requiredProps, commonPom) { + if (requiredProps.exists()) { + def m = (requiredProps.text =~ /(?m)^codename1\.arg\.java\.version=(\d+)$/) + if (m.find()) { + return m.group(1) + } + } + if (commonPom.exists()) { + def m = (commonPom.text =~ /(\d+)<\/maven\.compiler\.source>/) + if (m.find()) { + return m.group(1) + } + } + return "8" +} + +/** "17" when running on JDK 17 or newer, "8" otherwise. */ +def pickJavaVersionFromCurrentJvm() { + def specVersion = System.getProperty("java.specification.version", "1.8") + def major + try { + if (specVersion.startsWith("1.")) { + major = Integer.parseInt(specVersion.substring(2)) + } else { + major = Integer.parseInt(specVersion.split("\\.")[0]) + } + } catch (NumberFormatException ignored) { + major = 8 + } + return major >= 17 ? "17" : "8" +} + +/** + * For Java 17 library projects: drop the win/ source tree and the + * `win` line from the root pom. Note the cn1lib root pom + * lists win as a direct module rather than a profile (unlike cn1app), so + * the strip pattern is line-removal rather than block-removal. + * + * Always: rewrite the IntelliJ misc.xml languageLevel attribute to match + * the resolved JDK. + */ +def applyJavaVersionTransforms(rootDir, rootPom, resolvedJava) { + if (resolvedJava == "17") { + def winDir = new java.io.File(rootDir, "win") + if (winDir.exists()) { + deleteRecursively(winDir) + } + if (rootPom.exists()) { + def content = rootPom.text + def pattern = "\n win" + if (content.contains(pattern)) { + rewriteFile(rootPom, content.replace(pattern, "")) + } else { + // Fall back to a regex-tolerant strip if indentation changes. + rewriteFile(rootPom, (content =~ /\n\s*win<\/module>/).replaceFirst("")) + } + } + } + setIntellijLanguageLevel(rootDir, resolvedJava) +} + +def setIntellijLanguageLevel(rootDir, resolvedJava) { + def miscXml = new java.io.File(rootDir, ".idea/misc.xml") + if (!miscXml.exists()) { + return + } + def desired = resolvedJava == "17" ? "JDK_17" : "JDK_1_8" + def content = miscXml.text + def pattern = 'languageLevel="' + def pos = content.indexOf(pattern) + if (pos < 0) { + return + } + def valueStart = pos + pattern.length() + def valueEnd = content.indexOf('"', valueStart) + if (valueEnd < 0) { + return + } + rewriteFile(miscXml, content.substring(0, valueStart) + desired + content.substring(valueEnd)) +} + +def deleteRecursively(file) { + if (file.isDirectory()) { + file.listFiles().each { deleteRecursively(it) } + } + file.delete() +} + +def rewriteFile(file, content) { + file.newWriter("UTF-8").withWriter { w -> w << content } +} diff --git a/maven/cn1lib-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/maven/cn1lib-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..3f469af790 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,134 @@ + + + + + + 8.0-SNAPSHOT + + + 8.0-SNAPSHOT + + + 1.3.72 + + + + auto + + + + + + + .idea + + ** + + + + + + + + + + + + + src/main/java + + **/*.java + + + + src/main/css + + **/*.txt + + + + src/main/resources + + ** + + + + src/main/css + + **/*.css + + + + src/test/java + + **/*.java + + + + + + codenameone_library_required.properties + codenameone_library_appended.properties + + + + + + + + src/main/java + + **/*.java + + + + + + + + src/main/javascript + + **/*.js + + + + + + + + src/main/objectivec + + **/*.h + **/*.m + + + + + + + + src/main/csharp + + **/*.cs + + + + + + + + src/main/java + + **/*.java + + + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/android/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/android/pom.xml new file mode 100644 index 0000000000..817b73bcf2 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/android/pom.xml @@ -0,0 +1,125 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + src/main/dummy + + + src/main/java + + + src/main/resources + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + package + + + + + + + + + + + + + + run + + + + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + + kotlin + + + + codenameone_kotlin.properties + + + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/android/src/main/java/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/android/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_appended.properties b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_appended.properties new file mode 100644 index 0000000000..712a6a3ac7 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_appended.properties @@ -0,0 +1,3 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_required.properties b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_required.properties new file mode 100644 index 0000000000..92a9d62183 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/codenameone_library_required.properties @@ -0,0 +1,6 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +${symbol_pound} +${symbol_pound}Thu Aug 25 16:25:22 PDT 2016 +codename1.arg.java.version=${javaVersion} diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/pom.xml new file mode 100644 index 0000000000..747a7e4a30 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/pom.xml @@ -0,0 +1,290 @@ + + + + + ${groupId} + ${rootArtifactId} + ${version} + + 4.0.0 + ${groupId} + ${artifactId} + ${version} + jar + + UTF-8 + + ${javaVersion} + ${javaVersion} + + + + + + + com.codenameone + codenameone-core + ${cn1.version} + provided + + + + + + + com.codenameone + codenameone-maven-plugin + + + generate-gui-sources + process-sources + + generate-gui-sources + + + + cn1-compliance-check + process-classes + + compliance-check + + + + build-legacy-cn1lib + package + + cn1lib + + + + + + + + + + + + + kotlin + + + + ${basedir}/src/main/kotlin + + + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains + annotations + 13.0 + + + com.codenameone + java-runtime + provided + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + -no-reflect + -no-jdk + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + -no-reflect + -no-jdk + + + + + + + + + + + appended-properties + + + ${basedir}/codenameone_library_appended.properties + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-library-appended-properties + process-resources + + + + + + + + + + + run + + + + + + + + + required-properties + + + ${basedir}/codenameone_library_required.properties + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-library-required-properties + process-resources + + + + + + + + + + + run + + + + + + + + + + copy-css + + + + ${basedir}/src/main/css + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + copy-css + process-resources + + + + + + + + + + + + + + + + run + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + attach-css + package + + attach-artifact + + + + + ${project.build.directory}/${project.build.finalName}-cn1css.zip + zip + cn1css + + + + + + + + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/css/images/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/css/images/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css new file mode 100644 index 0000000000..abd96a1a48 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/css/theme.css @@ -0,0 +1 @@ +/* CSS file for filechooser */ diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/java/MyLibrary.java b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/java/MyLibrary.java new file mode 100644 index 0000000000..5cebf60f7c --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/java/MyLibrary.java @@ -0,0 +1,7 @@ +package ${package}; + +class MyLibrary { + public void helloWorld() { + System.out.println("Hello World"); + } +} \ No newline at end of file diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/resources/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/main/resources/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/test/java/FilechooserTest.java b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/test/java/FilechooserTest.java new file mode 100644 index 0000000000..5b2f43ceea --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/common/src/test/java/FilechooserTest.java @@ -0,0 +1,24 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ${package}; + +import com.codename1.testing.AbstractTest; + +/** + * + * @author shannah + */ +public class FilechooserTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + return true; + } + +} diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/ios/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/ios/pom.xml new file mode 100644 index 0000000000..7ae05ac41c --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/ios/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + + src/main/objectivec + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/ios/src/main/objectivec/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/ios/src/main/objectivec/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/javascript/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javascript/pom.xml new file mode 100644 index 0000000000..b96d228f09 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javascript/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + + src/main/javascript + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/javascript/src/main/javascript/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javascript/src/main/javascript/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/javase/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javase/pom.xml new file mode 100644 index 0000000000..ac684e5ef5 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javase/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + UTF-8 + + ${javaVersion} + ${javaVersion} + + + + + + + com.codenameone + codenameone-javase + provided + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/javase/src/main/java/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/javase/src/main/java/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/lib/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/lib/pom.xml new file mode 100644 index 0000000000..c345662a74 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/lib/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + pom + ${artifactId} + + + UTF-8 + + ${javaVersion} + ${javaVersion} + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + cn1css + zip + + + + + + javase + + + codename1.platform + javase + + + + + ${project.groupId} + ${cn1lib.name}-javase + ${project.version} + + + + + javascript + + + codename1.platform + javascript + + + + + ${project.groupId} + ${cn1lib.name}-javascript + ${project.version} + + + + + ios + + + codename1.platform + ios + + + + + ${project.groupId} + ${cn1lib.name}-ios + ${project.version} + + + + + win + + + codename1.platform + win + + + + + ${project.groupId} + ${cn1lib.name}-win + ${project.version} + + + + + android + + + codename1.platform + android + + + + + ${project.groupId} + ${cn1lib.name}-android + ${project.version} + + + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..554e040817 --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,283 @@ + + + 4.0.0 + + ${groupId} + ${artifactId} + ${version} + pom + + ${artifactId} + Codename One ${artifactId} library + https://www.codenameone.com + + + + GPL v2 With Classpath Exception + https://openjdk.java.net/legal/gplv2+ce.html + repo + A business-friendly OSS license + + + + + + + + + + + ${cn1PluginVersion} + ${cn1Version} + UTF-8 + + 1.8 + 11 + 3.8.0 + + ${javaVersion} + ${javaVersion} + ${artifactId} + ${kotlinVersion} + true + 1.8 + + + common + android + ios + javascript + javase + win + lib + + + + + com.codenameone + java-runtime + ${cn1.version} + + + com.codenameone + codenameone-core + ${cn1.version} + + + com.codenameone + codenameone-javase + ${cn1.version} + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + + + + org.jetbrains + annotations + 13.0 + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + + com.codenameone + codenameone-maven-plugin + ${cn1.plugin.version} + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + build-javadoc + + jar + + post-integration-test + + true + + + + + + + ${javaVersion} + protected + false + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + sign-artifacts + verify + + sign + + + ${gpg.passphrase} + + + + + + + + + + + nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/win/pom.xml b/maven/cn1lib-archetype/src/main/resources/archetype-resources/win/pom.xml new file mode 100644 index 0000000000..43f0cb3c1b --- /dev/null +++ b/maven/cn1lib-archetype/src/main/resources/archetype-resources/win/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + ${groupId} + ${rootArtifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + ${artifactId} + + + + src/main/csharp + + + src/main/resources + + + + + + + ${project.groupId} + ${cn1lib.name}-common + ${project.version} + + + + + diff --git a/maven/cn1lib-archetype/src/main/resources/archetype-resources/win/src/main/csharp/.gitignore b/maven/cn1lib-archetype/src/main/resources/archetype-resources/win/src/main/csharp/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/maven/cn1lib-archetype/src/test/resources/projects/basic/archetype.properties b/maven/cn1lib-archetype/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..59cfb94d48 --- /dev/null +++ b/maven/cn1lib-archetype/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,9 @@ +#Mon Jan 18 08:24:55 PST 2021 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +cn1Version=8.0-SNAPSHOT +cn1PluginVersion=8.0-SNAPSHOT +kotlinVersion=1.4.32 +javaVersion=8 diff --git a/maven/cn1lib-archetype/src/test/resources/projects/basic/goal.txt b/maven/cn1lib-archetype/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..597acc7688 --- /dev/null +++ b/maven/cn1lib-archetype/src/test/resources/projects/basic/goal.txt @@ -0,0 +1 @@ +package \ No newline at end of file diff --git a/maven/pom.xml b/maven/pom.xml index 104f8ecd52..528431424f 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -69,6 +69,8 @@ parparvm designer codenameone-maven-plugin + cn1app-archetype + cn1lib-archetype diff --git a/maven/update-version.sh b/maven/update-version.sh index 0be4e05955..41aac9e66a 100755 --- a/maven/update-version.sh +++ b/maven/update-version.sh @@ -44,6 +44,25 @@ echo "Version: $version" mvn versions:set -DnewVersion=$version mvn versions:commit +# Archetype metadata and IT fixtures: mvn versions:set does not reach inside +# the archetype-resources templates or the IT archetype.properties files, so +# bump the embedded version references by hand. Mirrors what the historical +# cn1-maven-archetypes/update-version.sh did before the archetypes were +# inlined into this repo. +for a in cn1app-archetype cn1lib-archetype; do + f=./$a/src/main/resources/META-INF/maven/archetype-metadata.xml + [ -f "$f" ] && perl -pi -e "s/$oldVersion<\/defaultValue>/$version<\/defaultValue>/g" "$f" + # cn1app-archetype ships basic + netbeans ITs; cn1lib-archetype only ships + # basic. Skip missing fixtures rather than tripping perl with -i. + for proj in basic netbeans; do + f=./$a/src/test/resources/projects/$proj/archetype.properties + if [ -f "$f" ]; then + perl -pi -e "s/^cn1Version=$oldVersion\$/cn1Version=$version/g" "$f" + perl -pi -e "s/^cn1PluginVersion=$oldVersion\$/cn1PluginVersion=$version/g" "$f" + fi + done +done + echo "Committing version change in git" git add -u . # Note: the -u is to prevent adding files that aren't added to git yet. Only changed diff --git a/scripts/setup-workspace.sh b/scripts/setup-workspace.sh index f1405b4094..0e51853980 100755 --- a/scripts/setup-workspace.sh +++ b/scripts/setup-workspace.sh @@ -247,39 +247,11 @@ if [ ! -f "$BUILD_CLIENT" ]; then fi fi -log "Installing cn1-maven-archetypes" -if [ "${SKIP_CN1_ARCHETYPES:-0}" = "1" ]; then - log "Skipping cn1-maven-archetypes install because SKIP_CN1_ARCHETYPES=1" - skip_archetypes=1 -else - set +e # don't let a transient git failure abort the whole build - if [ -d cn1-maven-archetypes/.git ]; then - log "Updating existing cn1-maven-archetypes checkout" - if ! git -C cn1-maven-archetypes fetch --all --tags; then - log "git fetch failed (exit 128?). Leaving existing copy as-is." - else - git -C cn1-maven-archetypes reset --hard origin/master || \ - log "git reset failed; keeping local state." - fi - else - if ! git clone https://github.com/shannah/cn1-maven-archetypes cn1-maven-archetypes; then - log "git clone failed (likely exit 128). Skipping archetype install." - skip_archetypes=1 - fi - fi - set -e -fi - -if [ "${skip_archetypes:-0}" -eq 0 ]; then - ( - cd cn1-maven-archetypes - current_version=$("$MAVEN_HOME/bin/mvn" -q -DforceStdout help:evaluate -Dexpression=project.version | tr -d '\r' | tail -n 1) - if [ -z "$current_version" ]; then - log "Unable to determine cn1-maven-archetypes version; proceeding with defaults" - elif [ "$current_version" != "$CN1_VERSION" ]; then - log "Updating cn1-maven-archetypes version from $current_version to $CN1_VERSION to match local snapshot" - "$MAVEN_HOME/bin/mvn" -q -B versions:set -DnewVersion="$CN1_VERSION" -DgenerateBackupPoms=false - fi - "$MAVEN_HOME/bin/mvn" -T 1C -DskipTests -DskipITs=true -Dinvoker.skip=true install - ) || log "Archetype mvn install failed; continuing." -fi +# The cn1{app,lib}-archetype modules are inlined into the maven/ reactor +# (see maven/cn1app-archetype/ and maven/cn1lib-archetype/), so they're +# already installed into the local repo by the main `mvn install` above. +# Refresh the local archetype catalog so `mvn archetype:generate` can +# resolve them without a network round-trip. +log "Refreshing local archetype catalog" +( cd maven && "$MAVEN_HOME/bin/mvn" -q archetype:update-local-catalog ) || \ + log "archetype:update-local-catalog failed; archetype:generate may need -DarchetypeCatalog=local manually."