diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0eab0991e4..a46ff9b860 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -300,20 +300,6 @@ jobs: - name: Build Android Port run: ant -noinput -buildfile Ports/Android/build.xml jar - - name: Run Java SE device-runner tests - env: - ARTIFACTS_DIR: ${{ github.workspace }}/artifacts/desktop-device-runner - run: ./scripts/run-javase-device-tests.sh - - - name: Upload Java SE device-runner artifacts - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: javase-device-runner - path: artifacts/desktop-device-runner - if-no-files-found: warn - retention-days: 14 - - name: Packaging Everything run: zip -j result.zip CodenameOne/javadocs.zip CodenameOne/dist/CodenameOne.jar CodenameOne/updatedLibs.zip Ports/JavaSE/dist/JavaSE.jar build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip diff --git a/.github/workflows/scripts-ios.yml b/.github/workflows/scripts-ios.yml index b8cc8c2143..642379b45a 100644 --- a/.github/workflows/scripts-ios.yml +++ b/.github/workflows/scripts-ios.yml @@ -75,14 +75,29 @@ jobs: gem install cocoapods xcodeproj --no-document --user-install pod --version + - name: Compute setup-workspace hash + id: setup_hash + run: | + set -euo pipefail + echo "hash=$(shasum -a 256 scripts/setup-workspace.sh | awk '{print $1}')" >> "$GITHUB_OUTPUT" + - name: Restore cn1-binaries cache uses: actions/cache@v4 with: path: ../cn1-binaries - key: cn1-binaries-${{ runner.os }}-${{ hashFiles('scripts/setup-workspace.sh') }} + key: cn1-binaries-${{ runner.os }}-${{ steps.setup_hash.outputs.hash }} restore-keys: | cn1-binaries-${{ runner.os }}- +# Temporary disabled due to github issue: https://github.com/actions/runner/issues/4134 +# - name: Restore cn1-binaries cache +# uses: actions/cache@v4 +# with: +# path: ../cn1-binaries +# key: cn1-binaries-${{ runner.os }}-${{ hashFiles('scripts/setup-workspace.sh') }} +# restore-keys: | +# cn1-binaries-${{ runner.os }}- + - name: Setup workspace run: ./scripts/setup-workspace.sh -q -DskipTests # per-step timeout diff --git a/maven/core-unittests/src/test/java/com/codename1/ui/AutoCompleteTextComponentTest.java b/maven/core-unittests/src/test/java/com/codename1/ui/AutoCompleteTextComponentTest.java index b9aab6a69d..62f36b261e 100644 --- a/maven/core-unittests/src/test/java/com/codename1/ui/AutoCompleteTextComponentTest.java +++ b/maven/core-unittests/src/test/java/com/codename1/ui/AutoCompleteTextComponentTest.java @@ -1,5 +1,6 @@ package com.codename1.ui; +import com.codename1.junit.FormTest; import com.codename1.junit.UITestBase; import com.codename1.ui.list.DefaultListModel; import com.codename1.ui.list.ListModel; @@ -23,7 +24,7 @@ void initModel() { suggestionModel = new DefaultListModel(new String[]{"alpha", "beta", "gamma"}); } - @Test + @FormTest void constructorAppliesCustomFilterAndProvidesEditorAccess() throws Exception { final List filtered = new ArrayList(); AutoCompleteTextComponent.AutoCompleteFilter filter = new AutoCompleteTextComponent.AutoCompleteFilter() { @@ -44,7 +45,7 @@ public boolean filter(String text) { assertSame(field, component.getEditor(), "getEditor should return the AutoCompleteTextField instance"); } - @Test + @FormTest void focusAnimationFollowsThemeAndManualOverrides() { Hashtable theme = new Hashtable(); theme.put("@textComponentAnimBool", "true"); @@ -60,7 +61,7 @@ void focusAnimationFollowsThemeAndManualOverrides() { assertTrue(component.isFocusAnimation(), "Explicit true should override theme"); } - @Test + @FormTest void fluentSettersUpdateUnderlyingField() { AutoCompleteTextComponent component = new AutoCompleteTextComponent(suggestionModel, AcceptAllFilter.INSTANCE); Image hintIcon = Image.createImage(2, 2); @@ -84,7 +85,7 @@ void fluentSettersUpdateUnderlyingField() { assertSame(hintIcon, field.getHintIcon()); } - @Test + @FormTest void propertyMetadataAndValuesReflectFieldState() { AutoCompleteTextComponent component = new AutoCompleteTextComponent(suggestionModel, AcceptAllFilter.INSTANCE); component diff --git a/scripts/build-android-app.sh b/scripts/build-android-app.sh index 57e4009e44..4fb840aa9b 100755 --- a/scripts/build-android-app.sh +++ b/scripts/build-android-app.sh @@ -4,14 +4,13 @@ set -euo pipefail ba_log() { echo "[build-android-app] $1"; } +REPO_ROOT="$(pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$REPO_ROOT" TMPDIR="${TMPDIR:-/tmp}"; TMPDIR="${TMPDIR%/}" DOWNLOAD_DIR="${TMPDIR%/}/codenameone-tools" ENV_DIR="$DOWNLOAD_DIR/tools" -EXTRA_MVN_ARGS=("$@") ENV_FILE="$ENV_DIR/env.sh" ba_log "Loading workspace environment from $ENV_FILE" @@ -74,191 +73,21 @@ fi export ANDROID_SDK_ROOT ANDROID_HOME="$ANDROID_SDK_ROOT" ba_log "Using Android SDK at $ANDROID_SDK_ROOT" -CN1_VERSION=$(awk -F'[<>]' '//{print $3; exit}' maven/pom.xml) -ba_log "Detected Codename One version $CN1_VERSION" - -WORK_DIR="$TMPDIR/cn1-hello-android" -rm -rf "$WORK_DIR"; mkdir -p "$WORK_DIR" - -GROUP_ID="com.codenameone.examples" -ARTIFACT_ID="hello-codenameone" -PACKAGE_NAME="com.codenameone.examples.hellocodenameone" -MAIN_NAME="HelloCodenameOne" - -SOURCE_PROJECT="$REPO_ROOT/Samples/SampleProjectTemplate" -if [ ! -d "$SOURCE_PROJECT" ]; then - ba_log "Source project template not found at $SOURCE_PROJECT" >&2 - exit 1 -fi -ba_log "Using source project template at $SOURCE_PROJECT" - -LOCAL_MAVEN_REPO="${LOCAL_MAVEN_REPO:-$HOME/.m2/repository}" -ba_log "Using local Maven repository at $LOCAL_MAVEN_REPO" -mkdir -p "$LOCAL_MAVEN_REPO" -MAVEN_CMD=( - "$MAVEN_HOME/bin/mvn" -B -ntp - -Dmaven.repo.local="$LOCAL_MAVEN_REPO" - -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -) - -# --- Generate app skeleton --- -ba_log "Generating Codename One application skeleton via codenameone-maven-plugin" -( - cd "$WORK_DIR" - xvfb-run -a "${MAVEN_CMD[@]}" -q \ - com.codenameone:codenameone-maven-plugin:7.0.204:generate-app-project \ - -DgroupId="$GROUP_ID" \ - -DartifactId="$ARTIFACT_ID" \ - -Dversion=1.0-SNAPSHOT \ - -DsourceProject="$SOURCE_PROJECT" \ - -Dcn1Version="7.0.204" \ - "${EXTRA_MVN_ARGS[@]}" -) - -APP_DIR="$WORK_DIR/$ARTIFACT_ID" - -# --- Namespace-aware CN1 normalization (xmlstarlet) --- -ROOT_POM="$APP_DIR/pom.xml" -NS="mvn=http://maven.apache.org/POM/4.0.0" - -if ! command -v xmlstarlet >/dev/null 2>&1; then - sudo apt-get update -y && sudo apt-get install -y xmlstarlet -fi - -# Helper to run xmlstarlet with Maven namespace -x() { xmlstarlet ed -L -N "$NS" "$@"; } -q() { xmlstarlet sel -N "$NS" "$@"; } - -# 1) Ensure exists/updated (root pom) -if [ "$(q -t -v 'count(/mvn:project/mvn:properties)' "$ROOT_POM" 2>/dev/null || echo 0)" = "0" ]; then - x -s "/mvn:project" -t elem -n properties -v "" "$ROOT_POM" -fi -if [ "$(q -t -v 'count(/mvn:project/mvn:properties/mvn:codenameone.version)' "$ROOT_POM" 2>/dev/null || echo 0)" = "0" ]; then - x -s "/mvn:project/mvn:properties" -t elem -n codenameone.version -v "$CN1_VERSION" "$ROOT_POM" -else - x -u "/mvn:project/mvn:properties/mvn:codenameone.version" -v "$CN1_VERSION" "$ROOT_POM" -fi - -# 2) Parent must be a LITERAL version (no property allowed) -while IFS= read -r -d '' P; do - x -u "/mvn:project[mvn:parent/mvn:groupId='com.codenameone' and mvn:parent/mvn:artifactId='codenameone-maven-parent']/mvn:parent/mvn:version" -v "$CN1_VERSION" "$P" || true -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 3) Point com.codenameone deps/plugins to ${codenameone.version} -while IFS= read -r -d '' P; do - # Dependencies - x -u "/mvn:project//mvn:dependencies/mvn:dependency[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true - # Plugins (regular) - x -u "/mvn:project//mvn:build/mvn:plugins/mvn:plugin[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true - # Plugins (pluginManagement) - x -u "/mvn:project//mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 4) Ensure common Maven plugins have a version (Maven requires it even if parent not yet resolved) -declare -A PIN=( - [org.apache.maven.plugins:maven-compiler-plugin]=3.11.0 - [org.apache.maven.plugins:maven-resources-plugin]=3.3.1 - [org.apache.maven.plugins:maven-surefire-plugin]=3.2.5 - [org.apache.maven.plugins:maven-failsafe-plugin]=3.2.5 - [org.apache.maven.plugins:maven-jar-plugin]=3.3.0 - [org.apache.maven.plugins:maven-clean-plugin]=3.3.2 - [org.apache.maven.plugins:maven-deploy-plugin]=3.1.2 - [org.apache.maven.plugins:maven-install-plugin]=3.1.2 - [org.apache.maven.plugins:maven-assembly-plugin]=3.6.0 - [org.apache.maven.plugins:maven-site-plugin]=4.0.0-M15 - [com.codenameone:codenameone-maven-plugin]='${codenameone.version}' -) - -add_version_if_missing() { - local pom="$1" g="$2" a="$3" v="$4" - # build/plugins - if [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']/mvn:version)" "$pom" 2>/dev/null || echo 0)" = "0" ] && - [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a'])" "$pom" 2>/dev/null || echo 0)" != "0" ]; then - x -s "/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']" -t elem -n version -v "$v" "$pom" || true - fi - # pluginManagement/plugins - if [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']/mvn:version)" "$pom" 2>/dev/null || echo 0)" = "0" ] && - [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a'])" "$pom" 2>/dev/null || echo 0)" != "0" ]; then - x -s "/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']" -t elem -n version -v "$v" "$pom" || true - fi -} - -while IFS= read -r -d '' P; do - for ga in "${!PIN[@]}"; do - add_version_if_missing "$P" "${ga%%:*}" "${ga##*:}" "${PIN[$ga]}" - done -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 5) Build with the property set so any lingering refs resolve to the local snapshot -EXTRA_MVN_ARGS+=("-Dcodenameone.version=${CN1_VERSION}") - -# (Optional) quick non-fatal checks -xmlstarlet sel -N "$NS" -t -v "/mvn:project/mvn:properties/mvn:codenameone.version" -n "$ROOT_POM" || true -xmlstarlet sel -N "$NS" -t -c "/mvn:project/mvn:build/mvn:plugins" -n "$ROOT_POM" | head -n 60 || true - - +APP_DIR="scripts/hellocodenameone" [ -d "$APP_DIR" ] || { ba_log "Failed to create Codename One application project" >&2; exit 1; } [ -f "$APP_DIR/build.sh" ] && chmod +x "$APP_DIR/build.sh" -SETTINGS_FILE="$APP_DIR/common/codenameone_settings.properties" -echo "codename1.arg.android.useAndroidX=true" >> "$SETTINGS_FILE" -[ -f "$SETTINGS_FILE" ] || { ba_log "codenameone_settings.properties not found at $SETTINGS_FILE" >&2; exit 1; } - -set_prop() { - local key="$1" value="$2" - if grep -q "^${key}=" "$SETTINGS_FILE"; then - if sed --version >/dev/null 2>&1; then - sed -i -E "s|^${key}=.*$|${key}=${value}|" "$SETTINGS_FILE" - else - sed -i '' -E "s|^${key}=.*$|${key}=${value}|" "$SETTINGS_FILE" - fi - else - printf '\n%s=%s\n' "$key" "$value" >> "$SETTINGS_FILE" - fi -} - -# --- Install Codename One application sources --- -PACKAGE_PATH="${PACKAGE_NAME//.//}" -JAVA_DIR="$APP_DIR/common/src/main/java/${PACKAGE_PATH}" -mkdir -p "$JAVA_DIR" -MAIN_FILE_SOURCE="$SCRIPT_DIR/device-runner-app/main/${MAIN_NAME}.java" -if [ ! -f "$MAIN_FILE_SOURCE" ]; then - ba_log "Sample application source not found: $MAIN_FILE_SOURCE" >&2 - exit 1 -fi -cp "$MAIN_FILE_SOURCE" "$JAVA_DIR/${MAIN_NAME}.java" - -ba_log "Setting Codename One application metadata" -set_prop "codename1.packageName" "$PACKAGE_NAME" -set_prop "codename1.mainName" "$MAIN_NAME" -# DeviceRunner integration is handled inside the copied sources, so unit test -# build mode is not required (and is unsupported for local Android builds). -# Ensure trailing newline -tail -c1 "$SETTINGS_FILE" | read -r _ || echo >> "$SETTINGS_FILE" - -# --- Install DeviceRunner UI tests --- -TEST_SOURCE_DIR="$SCRIPT_DIR/device-runner-app/tests" -TEST_JAVA_DIR="$APP_DIR/common/src/main/java/${PACKAGE_PATH}/tests" -mkdir -p "$TEST_JAVA_DIR" -if [ ! -d "$TEST_SOURCE_DIR" ]; then - ba_log "DeviceRunner test sources not found: $TEST_SOURCE_DIR" >&2 - exit 1 -fi -cp "$TEST_SOURCE_DIR"/*.java "$TEST_JAVA_DIR"/ -ba_log "Installed DeviceRunner UI tests in $TEST_JAVA_DIR" - -# --- Normalize Codename One versions (use Maven Versions Plugin) --- -ba_log "Normalizing Codename One Maven coordinates to $CN1_VERSION" - # --- Build Android gradle project --- ba_log "Building Android gradle project using Codename One port" -xvfb-run -a "${MAVEN_CMD[@]}" -q -f "$APP_DIR/pom.xml" package \ +cd $APP_DIR +xvfb-run -a ./mvnw package \ -DskipTests \ -Dcodename1.platform=android \ -Dcodename1.buildTarget=android-source \ -Dopen=false \ - "${EXTRA_MVN_ARGS[@]}" + -U -e +cd ../.. GRADLE_PROJECT_DIR=$(find "$APP_DIR/android/target" -maxdepth 2 -type d -name "*-android-source" | head -n 1 || true) if [ -z "$GRADLE_PROJECT_DIR" ]; then @@ -273,7 +102,7 @@ ba_log "Normalizing Android Gradle project in $GRADLE_PROJECT_DIR" # --- Install Android instrumentation harness for coverage --- ANDROID_TEST_SOURCE_DIR="$SCRIPT_DIR/device-runner-app/androidTest" ANDROID_TEST_ROOT="$GRADLE_PROJECT_DIR/app/src/androidTest" -ANDROID_TEST_JAVA_DIR="$ANDROID_TEST_ROOT/java/${PACKAGE_PATH}" +ANDROID_TEST_JAVA_DIR="$ANDROID_TEST_ROOT/java/com/codenameone/examples/hellocodenameone" if [ -d "$ANDROID_TEST_ROOT" ]; then ba_log "Removing template Android instrumentation tests from $ANDROID_TEST_ROOT" rm -rf "$ANDROID_TEST_ROOT" @@ -342,7 +171,6 @@ if [ -n "${GITHUB_OUTPUT:-}" ]; then { echo "gradle_project_dir=$GRADLE_PROJECT_DIR" echo "apk_path=$APK_PATH" - echo "package_name=$PACKAGE_NAME" } >> "$GITHUB_OUTPUT" ba_log "Published GitHub Actions outputs for downstream steps" fi diff --git a/scripts/build-ios-app.sh b/scripts/build-ios-app.sh index 833f5d3b52..a37a5a9bad 100755 --- a/scripts/build-ios-app.sh +++ b/scripts/build-ios-app.sh @@ -15,7 +15,6 @@ cd "$REPO_ROOT" TMPDIR="${TMPDIR:-/tmp}"; TMPDIR="${TMPDIR%/}" DOWNLOAD_DIR="${TMPDIR}/codenameone-tools" ENV_DIR="$DOWNLOAD_DIR/tools" -EXTRA_MVN_ARGS=("$@") ENV_FILE="$ENV_DIR/env.sh" bia_log "Loading workspace environment from $ENV_FILE" @@ -57,186 +56,19 @@ bia_log "Using JAVA17_HOME at $JAVA17_HOME" bia_log "Using Maven installation at $MAVEN_HOME" bia_log "Using CocoaPods version $(pod --version 2>/dev/null || echo '')" -CN1_VERSION=$(awk -F'[<>]' '//{print $3; exit}' maven/pom.xml) -bia_log "Detected Codename One version $CN1_VERSION" - -WORK_DIR="$TMPDIR/cn1-hello-ios" -rm -rf "$WORK_DIR"; mkdir -p "$WORK_DIR" - -GROUP_ID="com.codenameone.examples" -ARTIFACT_ID="hello-codenameone-ios" -MAIN_NAME="HelloCodenameOne" -PACKAGE_NAME="com.codenameone.examples.hellocodenameone" - -SOURCE_PROJECT="$REPO_ROOT/Samples/SampleProjectTemplate" -if [ ! -d "$SOURCE_PROJECT" ]; then - bia_log "Source project template not found at $SOURCE_PROJECT" >&2 - exit 1 -fi -bia_log "Using source project template at $SOURCE_PROJECT" - -# Local Maven repo + command wrapper (define BEFORE using it) -LOCAL_MAVEN_REPO="${LOCAL_MAVEN_REPO:-$HOME/.m2/repository}" -bia_log "Using local Maven repository at $LOCAL_MAVEN_REPO" -mkdir -p "$LOCAL_MAVEN_REPO" - -MAVEN_CMD=( - "$MAVEN_HOME/bin/mvn" -B -ntp - -Dmaven.repo.local="$LOCAL_MAVEN_REPO" - -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -) - -# --- Generate app skeleton --- -bia_log "Generating Codename One application skeleton via codenameone-maven-plugin" -( - cd "$WORK_DIR" - "${MAVEN_CMD[@]}" -q \ - com.codenameone:codenameone-maven-plugin:7.0.204:generate-app-project \ - -DgroupId="$GROUP_ID" \ - -DartifactId="$ARTIFACT_ID" \ - -Dversion=1.0-SNAPSHOT \ - -DsourceProject="$SOURCE_PROJECT" \ - -Dcn1Version="$CN1_VERSION" \ - "${EXTRA_MVN_ARGS[@]}" -) - -APP_DIR="$WORK_DIR/$ARTIFACT_ID" -[ -d "$APP_DIR" ] || { bia_log "Failed to create Codename One application project" >&2; exit 1; } -[ -f "$APP_DIR/build.sh" ] && chmod +x "$APP_DIR/build.sh" - -# --- Normalize Codename One versions in generated iOS project POMs --- -ROOT_POM="$APP_DIR/pom.xml" -NS="mvn=http://maven.apache.org/POM/4.0.0" - -# Ensure xmlstarlet is available (macOS runners use Homebrew) -if ! command -v xmlstarlet >/dev/null 2>&1; then - if command -v brew >/dev/null 2>&1; then - brew install xmlstarlet - elif command -v apt-get >/dev/null 2>&1; then - sudo apt-get update -y && sudo apt-get install -y xmlstarlet - else - bia_log "xmlstarlet not found and no installer available"; exit 1 - fi -fi - -# Helpers -x() { xmlstarlet ed -L -N "$NS" "$@"; } -q() { xmlstarlet sel -N "$NS" "$@"; } - -# 1) Ensure ${CN1_VERSION} -if [ "$(q -t -v 'count(/mvn:project/mvn:properties)' "$ROOT_POM" 2>/dev/null || echo 0)" = "0" ]; then - x -s "/mvn:project" -t elem -n properties -v "" "$ROOT_POM" -fi -if [ "$(q -t -v 'count(/mvn:project/mvn:properties/mvn:codenameone.version)' "$ROOT_POM" 2>/dev/null || echo 0)" = "0" ]; then - x -s "/mvn:project/mvn:properties" -t elem -n codenameone.version -v "$CN1_VERSION" "$ROOT_POM" -else - x -u "/mvn:project/mvn:properties/mvn:codenameone.version" -v "$CN1_VERSION" "$ROOT_POM" -fi - -# 2) Force the com.codenameone parent to a literal version (no property) -while IFS= read -r -d '' P; do - x -u "/mvn:project[mvn:parent/mvn:groupId='com.codenameone' and mvn:parent/mvn:artifactId='codenameone-maven-parent']/mvn:parent/mvn:version" -v "$CN1_VERSION" "$P" || true -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 3) Point all com.codenameone deps/plugins to ${codenameone.version} -while IFS= read -r -d '' P; do - x -u "/mvn:project//mvn:dependencies/mvn:dependency[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true - x -u "/mvn:project//mvn:build/mvn:plugins/mvn:plugin[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true - x -u "/mvn:project//mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[starts-with(mvn:groupId,'com.codenameone')]/mvn:version" -v '${codenameone.version}' "$P" 2>/dev/null || true -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 4) Ensure common Maven plugins have versions (helps before parent resolves) -declare -A PIN=( - [org.apache.maven.plugins:maven-compiler-plugin]=3.11.0 - [org.apache.maven.plugins:maven-resources-plugin]=3.3.1 - [org.apache.maven.plugins:maven-surefire-plugin]=3.2.5 - [org.apache.maven.plugins:maven-failsafe-plugin]=3.2.5 - [org.apache.maven.plugins:maven-jar-plugin]=3.3.0 - [org.apache.maven.plugins:maven-clean-plugin]=3.3.2 - [org.apache.maven.plugins:maven-deploy-plugin]=3.1.2 - [org.apache.maven.plugins:maven-install-plugin]=3.1.2 - [org.apache.maven.plugins:maven-assembly-plugin]=3.6.0 - [org.apache.maven.plugins:maven-site-plugin]=4.0.0-M15 - [com.codenameone:codenameone-maven-plugin]='${codenameone.version}' -) -add_version_if_missing() { - local pom="$1" g="$2" a="$3" v="$4" - if [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']/mvn:version)" "$pom" 2>/dev/null || echo 0)" = "0" ] && - [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a'])" "$pom" 2>/dev/null || echo 0)" != "0" ]; then - x -s "/mvn:project/mvn:build/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']" -t elem -n version -v "$v" "$pom" || true - fi - if [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']/mvn:version)" "$pom" 2>/dev/null || echo 0)" = "0" ] && - [ "$(q -t -v "count(/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a'])" "$pom" 2>/dev/null || echo 0)" != "0" ]; then - x -s "/mvn:project/mvn:build/mvn:pluginManagement/mvn:plugins/mvn:plugin[mvn:groupId='$g' and mvn:artifactId='$a']" -t elem -n version -v "$v" "$pom" || true - fi -} -while IFS= read -r -d '' P; do - for ga in "${!PIN[@]}"; do add_version_if_missing "$P" "${ga%%:*}" "${ga##*:}" "${PIN[$ga]}"; done -done < <(find "$APP_DIR" -type f -name pom.xml -print0) - -# 5) Also pass the property when building (already present below) -EXTRA_MVN_ARGS+=("-Dcodenameone.version=${CN1_VERSION}") - -SETTINGS_FILE="$APP_DIR/common/codenameone_settings.properties" -if [ ! -f "$SETTINGS_FILE" ]; then - bia_log "codenameone_settings.properties not found at $SETTINGS_FILE" >&2 - exit 1 -fi - -set_property() { - local key="$1" value="$2" - if grep -q "^${key}=" "$SETTINGS_FILE"; then - if sed --version >/dev/null 2>&1; then - sed -i -E "s|^${key}=.*$|${key}=${value}|" "$SETTINGS_FILE" - else - sed -i '' -E "s|^${key}=.*$|${key}=${value}|" "$SETTINGS_FILE" - fi - else - printf '\n%s=%s\n' "$key" "$value" >> "$SETTINGS_FILE" - fi -} - -set_property "codename1.packageName" "$PACKAGE_NAME" -set_property "codename1.mainName" "$MAIN_NAME" - -# Ensure trailing newline -tail -c1 "$SETTINGS_FILE" | read -r _ || echo >> "$SETTINGS_FILE" - -PACKAGE_PATH="${PACKAGE_NAME//.//}" -JAVA_DIR="$APP_DIR/common/src/main/java/${PACKAGE_PATH}" -mkdir -p "$JAVA_DIR" -MAIN_FILE_SOURCE="$SCRIPT_DIR/device-runner-app/main/${MAIN_NAME}.java" -if [ ! -f "$MAIN_FILE_SOURCE" ]; then - bia_log "Sample application source not found: $MAIN_FILE_SOURCE" >&2 - exit 1 -fi -cp "$MAIN_FILE_SOURCE" "$JAVA_DIR/${MAIN_NAME}.java" -bia_log "Wrote main application class to $JAVA_DIR/${MAIN_NAME}.java" - -TEST_SOURCE_DIR="$SCRIPT_DIR/device-runner-app/tests" -TEST_JAVA_DIR="$APP_DIR/common/src/main/java/${PACKAGE_PATH}/tests" -mkdir -p "$TEST_JAVA_DIR" -if [ ! -d "$TEST_SOURCE_DIR" ]; then - bia_log "DeviceRunner test sources not found: $TEST_SOURCE_DIR" >&2 - exit 1 -fi -cp "$TEST_SOURCE_DIR"/*.java "$TEST_JAVA_DIR"/ -bia_log "Installed DeviceRunner UI tests in $TEST_JAVA_DIR" - -# --- Build iOS project (ios-source) --- -DERIVED_DATA_DIR="${TMPDIR}/codenameone-ios-derived" -rm -rf "$DERIVED_DATA_DIR"; mkdir -p "$DERIVED_DATA_DIR" +APP_DIR="scripts/hellocodenameone" xcodebuild -version bia_log "Building iOS Xcode project using Codename One port" -"${MAVEN_CMD[@]}" -q -f "$APP_DIR/pom.xml" package \ +cd $APP_DIR +./mvnw package \ -DskipTests \ -Dcodename1.platform=ios \ -Dcodename1.buildTarget=ios-source \ -Dopen=false \ - -Dcodenameone.version="$CN1_VERSION" \ - "${EXTRA_MVN_ARGS[@]}" + -U -e +cd ../.. IOS_TARGET_DIR="$APP_DIR/ios/target" if [ ! -d "$IOS_TARGET_DIR" ]; then @@ -287,17 +119,16 @@ if [ -z "$WORKSPACE" ]; then fi bia_log "Found xcworkspace: $WORKSPACE" -SCHEME="$MAIN_NAME" # Make these visible to the next GH Actions step if [ -n "${GITHUB_OUTPUT:-}" ]; then { echo "workspace=$WORKSPACE" - echo "scheme=$SCHEME" + echo "scheme=HelloCodenameOne" } >> "$GITHUB_OUTPUT" fi -bia_log "Emitted outputs -> workspace=$WORKSPACE, scheme=$SCHEME" +bia_log "Emitted outputs -> workspace=$WORKSPACE, scheme=HelloCodenameOne" # (Optional) dump xcodebuild -list for debugging ARTIFACTS_DIR="${ARTIFACTS_DIR:-$REPO_ROOT/artifacts}" diff --git a/scripts/hellocodenameone/.mvn/jvm.config b/scripts/hellocodenameone/.mvn/jvm.config new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/hellocodenameone/.mvn/wrapper/MavenWrapperDownloader.java b/scripts/hellocodenameone/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000..b901097f2d --- /dev/null +++ b/scripts/hellocodenameone/.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/scripts/hellocodenameone/.mvn/wrapper/maven-wrapper.properties b/scripts/hellocodenameone/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..642d572ce9 --- /dev/null +++ b/scripts/hellocodenameone/.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/scripts/hellocodenameone/.vscode/extensions.json b/scripts/hellocodenameone/.vscode/extensions.json new file mode 100644 index 0000000000..24d1c3c854 --- /dev/null +++ b/scripts/hellocodenameone/.vscode/extensions.json @@ -0,0 +1 @@ +{"recommendations": ["vscjava.vscode-java-pack"]} \ No newline at end of file diff --git a/scripts/hellocodenameone/.vscode/settings.json b/scripts/hellocodenameone/.vscode/settings.json new file mode 100644 index 0000000000..a079bcd2cc --- /dev/null +++ b/scripts/hellocodenameone/.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/scripts/hellocodenameone/README.adoc b/scripts/hellocodenameone/README.adoc new file mode 100644 index 0000000000..3c48268908 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/android/pom.xml b/scripts/hellocodenameone/android/pom.xml new file mode 100644 index 0000000000..b72d6f7ffd --- /dev/null +++ b/scripts/hellocodenameone/android/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-android + 1.0-SNAPSHOT + + hellocodenameone-android + + + UTF-8 + 1.8 + 1.8 + android + android + android-device + + + src/main/empty + + + + src/main/java + + + src/main/resources + + + + + 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/scripts/hellocodenameone/build.bat b/scripts/hellocodenameone/build.bat new file mode 100644 index 0000000000..b7ccc0e212 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/build.sh b/scripts/hellocodenameone/build.sh new file mode 100755 index 0000000000..8a99f56684 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/common/codenameone_settings.properties b/scripts/hellocodenameone/common/codenameone_settings.properties new file mode 100644 index 0000000000..b388059468 --- /dev/null +++ b/scripts/hellocodenameone/common/codenameone_settings.properties @@ -0,0 +1,30 @@ +codename1.android.keystore= +codename1.android.keystoreAlias= +codename1.android.keystorePassword= +codename1.arg.ios.newStorageLocation=true +codename1.arg.java.version=8 +codename1.displayName=HelloCodenameOne +codename1.icon=icon.png +codename1.arg.android.useAndroidX=true +codename1.ios.appid=Q5GHSKAL2F.com.codenameone.examples.hellocodenameone +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=HelloCodenameOne +codename1.packageName=com.codenameone.examples.hellocodenameone +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/scripts/hellocodenameone/common/icon.png b/scripts/hellocodenameone/common/icon.png new file mode 100644 index 0000000000..1f4fa5dd25 Binary files /dev/null and b/scripts/hellocodenameone/common/icon.png differ diff --git a/scripts/hellocodenameone/common/pom.xml b/scripts/hellocodenameone/common/pom.xml new file mode 100644 index 0000000000..f617a6a0b0 --- /dev/null +++ b/scripts/hellocodenameone/common/pom.xml @@ -0,0 +1,376 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-common + 1.0-SNAPSHOT + 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 + + + + 1.3.72 + 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 + + 1.8 + 1.8 + + + + 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/scripts/hellocodenameone/common/src/main/css/theme.css b/scripts/hellocodenameone/common/src/main/css/theme.css new file mode 100644 index 0000000000..1b645201b0 --- /dev/null +++ b/scripts/hellocodenameone/common/src/main/css/theme.css @@ -0,0 +1,54 @@ +/** 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; +} diff --git a/scripts/device-runner-app/main/HelloCodenameOne.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java similarity index 100% rename from scripts/device-runner-app/main/HelloCodenameOne.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/HelloCodenameOne.java diff --git a/scripts/device-runner-app/tests/AbstractGraphicsScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/AbstractGraphicsScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/AbstractGraphicsScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/AbstractGraphicsScreenshotTest.java diff --git a/scripts/device-runner-app/tests/BaseTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/BaseTest.java similarity index 100% rename from scripts/device-runner-app/tests/BaseTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/BaseTest.java diff --git a/scripts/device-runner-app/tests/BrowserComponentScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/BrowserComponentScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/BrowserComponentScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/BrowserComponentScreenshotTest.java diff --git a/scripts/device-runner-app/tests/Cn1ssDeviceRunner.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java similarity index 100% rename from scripts/device-runner-app/tests/Cn1ssDeviceRunner.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunner.java diff --git a/scripts/device-runner-app/tests/Cn1ssDeviceRunnerHelper.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunnerHelper.java similarity index 100% rename from scripts/device-runner-app/tests/Cn1ssDeviceRunnerHelper.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunnerHelper.java diff --git a/scripts/device-runner-app/tests/Cn1ssDeviceRunnerReporter.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunnerReporter.java similarity index 100% rename from scripts/device-runner-app/tests/Cn1ssDeviceRunnerReporter.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/Cn1ssDeviceRunnerReporter.java diff --git a/scripts/device-runner-app/tests/GraphicsPipelineScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsPipelineScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/GraphicsPipelineScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsPipelineScreenshotTest.java diff --git a/scripts/device-runner-app/tests/GraphicsShapesAndGradientsScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsShapesAndGradientsScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/GraphicsShapesAndGradientsScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsShapesAndGradientsScreenshotTest.java diff --git a/scripts/device-runner-app/tests/GraphicsStateAndTextScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsStateAndTextScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/GraphicsStateAndTextScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsStateAndTextScreenshotTest.java diff --git a/scripts/device-runner-app/tests/GraphicsTransformationsScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsTransformationsScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/GraphicsTransformationsScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/GraphicsTransformationsScreenshotTest.java diff --git a/scripts/device-runner-app/tests/MainScreenScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/MainScreenScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/MainScreenScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/MainScreenScreenshotTest.java diff --git a/scripts/device-runner-app/tests/MediaPlaybackScreenshotTest.java b/scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/MediaPlaybackScreenshotTest.java similarity index 100% rename from scripts/device-runner-app/tests/MediaPlaybackScreenshotTest.java rename to scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/MediaPlaybackScreenshotTest.java diff --git a/scripts/hellocodenameone/common/src/test/java/com/codenameone/examples/hellocodenameone/MyFirstTest.java b/scripts/hellocodenameone/common/src/test/java/com/codenameone/examples/hellocodenameone/MyFirstTest.java new file mode 100644 index 0000000000..45c61c30ec --- /dev/null +++ b/scripts/hellocodenameone/common/src/test/java/com/codenameone/examples/hellocodenameone/MyFirstTest.java @@ -0,0 +1,23 @@ + +/* + * 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 com.codenameone.examples.hellocodenameone; + +import com.codename1.testing.AbstractTest; + +/** + * + * @author shannah + */ +public class MyFirstTest extends AbstractTest { + + @Override + public boolean runTest() throws Exception { + return true; + } + + +} diff --git a/scripts/hellocodenameone/ios/pom.xml b/scripts/hellocodenameone/ios/pom.xml new file mode 100644 index 0000000000..ccbad41f9f --- /dev/null +++ b/scripts/hellocodenameone/ios/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-ios + 1.0-SNAPSHOT + + hellocodenameone-ios + + + UTF-8 + 1.8 + 1.8 + ios + ios + ios-device + + + + + src/main/objectivec + + + src/main/resources + + + + + 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/scripts/hellocodenameone/javascript/pom.xml b/scripts/hellocodenameone/javascript/pom.xml new file mode 100644 index 0000000000..b9bfdcee29 --- /dev/null +++ b/scripts/hellocodenameone/javascript/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-javascript + 1.0-SNAPSHOT + + hellocodenameone-javascript + + + UTF-8 + 1.8 + 1.8 + javascript + javascript + javascript + + + + + src/main/javascript + + + src/main/resources + + + + + 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/scripts/hellocodenameone/javase/pom.xml b/scripts/hellocodenameone/javase/pom.xml new file mode 100644 index 0000000000..82ff468af0 --- /dev/null +++ b/scripts/hellocodenameone/javase/pom.xml @@ -0,0 +1,788 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-javase + 1.0-SNAPSHOT + + hellocodenameone-javase + + + 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 + com.codenameone.examples.hellocodenameone.HelloCodenameOneStub + + + + 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 + com.codenameone.examples.hellocodenameone.HelloCodenameOneStub + + + + 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/scripts/hellocodenameone/javase/src/desktop/java/com/codenameone/examples/hellocodenameone/HelloCodenameOneStub.java b/scripts/hellocodenameone/javase/src/desktop/java/com/codenameone/examples/hellocodenameone/HelloCodenameOneStub.java new file mode 100644 index 0000000000..530bc54e3c --- /dev/null +++ b/scripts/hellocodenameone/javase/src/desktop/java/com/codenameone/examples/hellocodenameone/HelloCodenameOneStub.java @@ -0,0 +1,213 @@ +/* + * 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. + */ + +package com.codenameone.examples.hellocodenameone; + +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 HelloCodenameOneStub implements Runnable, WindowListener { + private static final String APP_TITLE = "Hi World"; + private static final String APP_NAME = "HelloCodenameOne"; + 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 HelloCodenameOne 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 HelloCodenameOneStub()); + } + + 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 HelloCodenameOne(); + 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/scripts/hellocodenameone/javase/src/desktop/resources/NativeTheme.res b/scripts/hellocodenameone/javase/src/desktop/resources/NativeTheme.res new file mode 100644 index 0000000000..83e067b696 Binary files /dev/null and b/scripts/hellocodenameone/javase/src/desktop/resources/NativeTheme.res differ diff --git a/scripts/hellocodenameone/mvnw b/scripts/hellocodenameone/mvnw new file mode 100755 index 0000000000..41c0f0c23d --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/mvnw.cmd b/scripts/hellocodenameone/mvnw.cmd new file mode 100644 index 0000000000..86115719e5 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/pom.xml b/scripts/hellocodenameone/pom.xml new file mode 100644 index 0000000000..2c9bc5d48a --- /dev/null +++ b/scripts/hellocodenameone/pom.xml @@ -0,0 +1,185 @@ + + 4.0.0 + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + pom + hellocodenameone + hellocodenameone + https://www.codenameone.com + + + GPL v2 With Classpath Exception + https://openjdk.java.net/legal/gplv2+ce.html + repo + A business-friendly OSS license + + + +common + + + 7.0.212 + 8.0-SNAPSHOT + UTF-8 + 1.8 + 11 + 1.7.11 + 3.8.0 + 1.8 + 1.8 + 1.8 + hellocodenameone + + + + + 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/scripts/hellocodenameone/run.bat b/scripts/hellocodenameone/run.bat new file mode 100644 index 0000000000..f8b979c32a --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/run.sh b/scripts/hellocodenameone/run.sh new file mode 100755 index 0000000000..ef0a12cbe5 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build Android Studio Project.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build Android Studio Project.launch new file mode 100644 index 0000000000..ef99b4237b --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build Android Studio Project.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build JavaSE Desktop App.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build JavaSE Desktop App.launch new file mode 100644 index 0000000000..c278271267 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build JavaSE Desktop App.launch @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build iOS Xcode Project.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build iOS Xcode Project.launch new file mode 100644 index 0000000000..e18e14377a --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Build iOS Xcode Project.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug Simulator.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug Simulator.launch new file mode 100644 index 0000000000..8f2fbaae2f --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug Simulator.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug in Simulator.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug in Simulator.launch new file mode 100644 index 0000000000..6476652c88 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Debug in Simulator.launch @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Remote Debug Simulator.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Remote Debug Simulator.launch new file mode 100644 index 0000000000..629afc28e8 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Remote Debug Simulator.launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Desktop.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Desktop.launch new file mode 100644 index 0000000000..2cce230ccb --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Desktop.launch @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Simulator.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Simulator.launch new file mode 100644 index 0000000000..8a33375419 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Run Simulator.launch @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Android Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Android Build.launch new file mode 100644 index 0000000000..7c4224eef5 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Android Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Javascript Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Javascript Build.launch new file mode 100644 index 0000000000..de56113e40 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Javascript Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Mac Desktop Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Mac Desktop Build.launch new file mode 100644 index 0000000000..c403a2e9ef --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Mac Desktop Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows Desktop Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows Desktop Build.launch new file mode 100644 index 0000000000..7a96fc4c74 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows Desktop Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows UWP Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows UWP Build.launch new file mode 100644 index 0000000000..d7d0326ec7 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send Windows UWP Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Debug Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Debug Build.launch new file mode 100644 index 0000000000..79e66bdc4a --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Debug Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Release Build.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Release Build.launch new file mode 100644 index 0000000000..37b22344f1 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Send iOS Release Build.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Update Codename One.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Update Codename One.launch new file mode 100644 index 0000000000..4c998eb7a4 --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne - Update Codename One.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne Settings.launch b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne Settings.launch new file mode 100644 index 0000000000..605be6d01a --- /dev/null +++ b/scripts/hellocodenameone/tools/eclipse/HelloCodenameOne Settings.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/hellocodenameone/tools/netbeans/nb-configuration.xml b/scripts/hellocodenameone/tools/netbeans/nb-configuration.xml new file mode 100644 index 0000000000..cddcc7d75f --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/tools/netbeans/nbactions-Desktop App.xml b/scripts/hellocodenameone/tools/netbeans/nbactions-Desktop App.xml new file mode 100644 index 0000000000..53068a1728 --- /dev/null +++ b/scripts/hellocodenameone/tools/netbeans/nbactions-Desktop App.xml @@ -0,0 +1,12 @@ + + + + run + + verify + + + true + + + diff --git a/scripts/hellocodenameone/tools/netbeans/nbactions-JavaSE Desktop App.xml b/scripts/hellocodenameone/tools/netbeans/nbactions-JavaSE Desktop App.xml new file mode 100644 index 0000000000..f1c86c5acb --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/tools/netbeans/nbactions-Simulator.xml b/scripts/hellocodenameone/tools/netbeans/nbactions-Simulator.xml new file mode 100644 index 0000000000..b9707637fc --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/tools/netbeans/nbactions.xml b/scripts/hellocodenameone/tools/netbeans/nbactions.xml new file mode 100644 index 0000000000..eab8d61a95 --- /dev/null +++ b/scripts/hellocodenameone/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/scripts/hellocodenameone/win/pom.xml b/scripts/hellocodenameone/win/pom.xml new file mode 100644 index 0000000000..81831387c2 --- /dev/null +++ b/scripts/hellocodenameone/win/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + com.codenameone.examples.hellocodenameone + hellocodenameone + 1.0-SNAPSHOT + + com.codenameone.examples.hellocodenameone + hellocodenameone-win + 1.0-SNAPSHOT + + hellocodenameone-win + + + 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/scripts/run-android-instrumentation-tests.sh b/scripts/run-android-instrumentation-tests.sh index c953109bda..800d896ed5 100755 --- a/scripts/run-android-instrumentation-tests.sh +++ b/scripts/run-android-instrumentation-tests.sh @@ -112,13 +112,12 @@ ra_log "Capturing device logcat to $TEST_LOG" LOGCAT_PID=$! sleep 2 -GRADLEW="$GRADLE_PROJECT_DIR/gradlew" -[ -x "$GRADLEW" ] || chmod +x "$GRADLEW" +GRADLEW="./gradlew" GRADLE_CMD=("$GRADLEW" --no-daemon connectedDebugAndroidTest) ra_log "Executing connectedDebugAndroidTest via Gradle" if ! ( - cd "$GRADLE_PROJECT_DIR" + cd "scripts/hellocodenameone/android/target/hellocodenameone-android-1.0-SNAPSHOT-android-source" JAVA_HOME="$JAVA17_HOME" "${GRADLE_CMD[@]}" ); then ra_log "FATAL: connectedDebugAndroidTest failed"