Skip to content
Draft
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
81 changes: 81 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,84 @@ jobs:
wget https://github.com/codenameone/CodenameOne/raw/refs/heads/master/maven/CodeNameOneBuildClient.jar -O ~/.codenameone/CodeNameOneBuildClient.jar
- name: Build with Maven
run: mvn install

android-emulator:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'

- name: Install Android SDK
uses: android-actions/setup-android@v3
with:
packages: |-
platform-tools
emulator
system-images;android-33;google_apis;x86_64

- name: Enable KVM
run: |
sudo apt-get update
sudo apt-get install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo usermod -aG kvm $USER
sudo udevadm control --reload-rules && sudo udevadm trigger

- name: Build app with Maven Central artifacts
run: |
# Use local BTDemo directory
APP_DIR=$PWD/BTDemo \
CODENAMEONE_VERSION=7.0.26 \
BUILD_TARGET=android-source \
./scripts/ci/build-thirdparty-app.sh android

- name: Build APK from Source
run: |
# The generated project should be in scripts/ci/.thirdparty-app/app/target
# We search for it

# Find the android project directory (contains build.gradle)
# We look inside the work dir used by the script
ANDROID_PROJECT_DIR=$(find scripts/ci/.thirdparty-app/app/target -name "build.gradle" | grep "android" | xargs dirname)

if [ -z "$ANDROID_PROJECT_DIR" ]; then
echo "Could not find generated Android project"
find scripts/ci/.thirdparty-app/app/target
exit 1
fi

echo "Found Android project at $ANDROID_PROJECT_DIR"
cd "$ANDROID_PROJECT_DIR"

# Ensure gradlew is executable
chmod +x gradlew

# Build APK
./gradlew assembleDebug

- name: Boot emulator and run smoke test
env:
ANDROID_SDK_ROOT: ${{ env.ANDROID_SDK_ROOT }}
run: |
./scripts/ci/start-android-emulator.sh

# Find the generated APK
# It should be in the android project dir/app/build/outputs/apk/debug/
# But we are relative to root now

APK_PATH=$(find scripts/ci/.thirdparty-app/app/target -name "*.apk" | head -n 1)

if [ -z "$APK_PATH" ]; then
echo "Could not find built APK"
find scripts/ci/.thirdparty-app/app/target
exit 1
fi

echo "Installing APK from $APK_PATH"
adb install -r "$APK_PATH"

# Start the app
adb shell monkey -p com.codename1.btle 1
Binary file removed BTDemo/CodeNameOneBuildClient.jar
Binary file not shown.
51 changes: 51 additions & 0 deletions BTDemo/codenameone_settings.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
#Thu Dec 25 09:28:09 UTC 2025
codename1.android.keystore=
codename1.android.keystoreAlias=
codename1.android.keystorePassword=
codename1.arg.android.debug=false
codename1.arg.android.release=true
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.BLUETOOTH"/><uses-permission android\:name\="android.permission.BLUETOOTH_ADMIN"/><uses-permission android\:name\="android.permission.ACCESS_COARSE_LOCATION"/>
codename1.arg.ios.add_libs=;CoreBluetooth.framework;
codename1.arg.ios.application_exits=false
codename1.arg.ios.background_modes=,bluetooth-central,bluetooth-peripheral
codename1.arg.ios.dsym=false
codename1.arg.ios.includePush=false
codename1.arg.ios.interface_orientation=UIInterfaceOrientationPortrait\:UIInterfaceOrientationPortraitUpsideDown\:UIInterfaceOrientationLandscapeLeft\:UIInterfaceOrientationLandscapeRight
codename1.arg.ios.newStorageLocation=true
codename1.arg.ios.plistInject=<key>NSBluetoothPeripheralUsageDescription</key><string>${foobarfoo}</string>
codename1.arg.ios.pods=,Cordova,Cordova ~> 6.1
codename1.arg.ios.pods.platform=,11.0
codename1.arg.ios.prerendered_icon=false
codename1.arg.ios.project_type=ios
codename1.arg.ios.statusbar_hidden=false
codename1.arg.ios.testFlight=false
codename1.arg.j2me.nativeThemeConst=0
codename1.arg.java.version=8
codename1.arg.rim.obfuscation=false
codename1.arg.win.ver=8
codename1.description=
codename1.displayName=BTDemo
codename1.icon=icon.png
codename1.ios.appid=Q5GHSKAL2F.com.codename1.btle
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.languageLevel=5
codename1.mainName=BTDemo
codename1.packageName=com.codename1.btle
codename1.rim.certificatePassword=
codename1.rim.signtoolCsk=
codename1.rim.signtoolDb=
codename1.secondaryTitle=CodenameOne_Template
codename1.vendor=CodenameOne
codename1.version=1.0
foobarfoo=This is a description of what we are going to do
libVersion=111
Binary file removed BTDemo/dist/BTDemo.jar
Binary file not shown.
32 changes: 0 additions & 32 deletions BTDemo/dist/README.TXT

This file was deleted.

Binary file removed BTDemo/dist/lib/CLDC11.jar
Binary file not shown.
Binary file removed BTDemo/dist/lib/CodenameOne.jar
Binary file not shown.
Binary file removed BTDemo/dist/lib/CodenameOne_SRC.zip
Binary file not shown.
Binary file removed BTDemo/dist/lib/JavaSE.jar
Binary file not shown.
147 changes: 147 additions & 0 deletions scripts/ci/build-thirdparty-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/usr/bin/env bash
# Simple helper to build a Codename One Maven app using published artifacts
# from Maven Central. Useful for CI jobs that want to validate the toolchain
# without building Codename One from source.
set -euo pipefail

function usage() {
cat <<'USAGE'
Usage: build-thirdparty-app.sh <android|ios>

Options are provided via environment variables:
APP_DIR Path to an existing Codename One Maven project. If set,
the script builds this directory directly.
APP_REPO Git URL for a Codename One Maven project to clone.
Ignored when APP_DIR is set.
APP_REF Optional git ref (branch, tag, or commit) to check out
after cloning APP_REPO.
WORK_DIR Temporary workspace for cloned/copied sources. Default:
<repo>/scripts/ci/.thirdparty-app
CODENAMEONE_VERSION Codename One runtime version to request from Maven
Central. Defaults to LATEST.
CODENAMEONE_PLUGIN_VERSION
Codename One Maven plugin version. Defaults to
CODENAMEONE_VERSION.
BUILD_TARGET Overrides the codename1.buildTarget value passed to Maven.
Defaults to android-device for android or ios-source for
ios.

Examples:
# Build a local Maven app for Android
APP_DIR=/path/to/app ./scripts/ci/build-thirdparty-app.sh android

# Build a remote project for iOS from a specific tag
APP_REPO=https://github.com/example/my-cn1-app \
APP_REF=v1.2.3 \
CODENAMEONE_VERSION=8.0.0 \
./scripts/ci/build-thirdparty-app.sh ios

# Use the bundled hello-codenameone sample as a fallback
./scripts/ci/build-thirdparty-app.sh android
USAGE
}

if [[ ${1:-} == "--help" || ${1:-} == "-h" ]]; then
usage
exit 0
fi

TARGET=${1:-android}
if [[ "$TARGET" != "android" && "$TARGET" != "ios" ]]; then
echo "Unsupported target '$TARGET'. Expected 'android' or 'ios'." >&2
usage
exit 1
fi

CODENAMEONE_VERSION=${CODENAMEONE_VERSION:-LATEST}
CODENAMEONE_PLUGIN_VERSION=${CODENAMEONE_PLUGIN_VERSION:-$CODENAMEONE_VERSION}
WORK_DIR=${WORK_DIR:-"$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)/ci/.thirdparty-app"}
APP_WORK_DIR="$WORK_DIR/app"

function info() {
echo "[build-thirdparty] $*"
}

function prepare_workspace() {
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
}

function copy_local_app() {
local source_dir=$1
info "Using local app at $source_dir"
cp -R "$source_dir" "$APP_WORK_DIR"
}

function clone_app() {
local repo_url=$1
info "Cloning $repo_url"
git clone --depth 1 "$repo_url" "$APP_WORK_DIR"
if [[ -n ${APP_REF:-} ]]; then
pushd "$APP_WORK_DIR" >/dev/null
git fetch origin "$APP_REF" --depth 1
git checkout "$APP_REF"
popd >/dev/null
fi
}

function use_bundled_sample() {
local root_dir
root_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)
local sample_dir="$root_dir/scripts/hellocodenameone"
info "Falling back to bundled sample at $sample_dir"
cp -R "$sample_dir" "$APP_WORK_DIR"
}

function prepare_app() {
prepare_workspace
if [[ -n ${APP_DIR:-} ]]; then
copy_local_app "$APP_DIR"
return
fi
if [[ -n ${APP_REPO:-} ]]; then
clone_app "$APP_REPO"
return
fi
use_bundled_sample
}

function resolve_maven() {
local mvnw="$APP_WORK_DIR/mvnw"
if [[ -x "$mvnw" ]]; then
echo "$mvnw"
else
echo "mvn"
fi
}

function build_target() {
local mvn_cmd
mvn_cmd=$(resolve_maven)
local build_target
case "$TARGET" in
android)
build_target=${BUILD_TARGET:-android-device}
;;
ios)
build_target=${BUILD_TARGET:-ios-source}
;;
esac

pushd "$APP_WORK_DIR" >/dev/null
info "Building $TARGET with Codename One $CODENAMEONE_VERSION"
"$mvn_cmd" \
-B \
-U \
-DskipTests \
-Dcn1.version="$CODENAMEONE_VERSION" \
-Dcn1.plugin.version="$CODENAMEONE_PLUGIN_VERSION" \
-Dcodename1.platform="$TARGET" \
-Dcodename1.buildTarget="$build_target" \
package
popd >/dev/null
}

prepare_app
build_target
info "Build complete. Output available under $APP_WORK_DIR"
Loading