Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/archetype-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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: |
Expand Down
109 changes: 29 additions & 80 deletions .github/workflows/release-on-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <build> block (top-level,
# not the sign-artifacts profile build) before the deploy.
sed -i '1,/<build>/s|<build>|<build><pluginManagement><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>3.3.1</version></plugin></plugins></pluginManagement>|' pom.xml
if ! grep -q 'maven-resources-plugin</artifactId><version>3.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

12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
32 changes: 5 additions & 27 deletions maven/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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".

Expand Down
101 changes: 101 additions & 0 deletions maven/cn1app-archetype/README.adoc
Original file line number Diff line number Diff line change
@@ -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.
====





Loading
Loading