Skip to content

Commit

Permalink
Export JAVA_HOME to xcodegen (#606)
Browse files Browse the repository at this point in the history
* Explicitly pass environmental variables to Xcode build script.

* Integrate COMPOSE_DEMO_APPLE_TEAM_ID variable into xcodegen

* Update prebuild script in project.template.yml

Refactor the prebuild script for better readability and maintainability. Removed unnecessary environment variables and simplified Gradle command.

* Update gradle CLI script in project.template.yml

Refactor prebuildScripts in project.template.yml for better readability and maintainability. Separate relevant commands into distinct lines to improve code structure.

* Add echo JAVA_HOME in build script

---------

Co-authored-by: dima.avdeev <[email protected]>
  • Loading branch information
elijah-semyonov and dima-avdeev-jb authored Jun 21, 2023
1 parent eb888df commit f56a88b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions compose/mpp/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.xcodeproj
plists
project.generated.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: ComposeDemo
# this YML is to be used as a template with %@PLACEHOLDER_VALUES@% replaced with actual ones within regenerate_xcode_project.sh
name: %@PROJECT_NAME@%
options:
bundleIdPrefix: org.jetbrains
settings:
DEVELOPMENT_TEAM: N462MKSJ7M
DEVELOPMENT_TEAM: %@COMPOSE_DEMO_APPLE_TEAM_ID@%
CODE_SIGN_IDENTITY: "iPhone Developer"
CODE_SIGN_STYLE: Automatic
MARKETING_VERSION: "1.0"
Expand All @@ -14,7 +15,13 @@ targets:
platform: iOS
deploymentTarget: "12.0"
prebuildScripts:
- script: cd "$SRCROOT" && OUT_DIR=`pwd`/out JAVA_TOOLS_JAR=/Users/jetbrains/jetpack_compose_ui/compose-jb/compose/scripts/../external/tools.jar ALLOW_PUBLIC_REPOS=1 ANDROIDX_PROJECTS=compose ../../../gradlew -i -Pandroidx.compose.multiplatformEnabled=true --no-daemon -Pkotlin.compiler.execution.strategy="in-process" -p . packForXCode
- script: |
cd "$SRCROOT"
export JAVA_HOME=%@JAVA_HOME@%
export OUT_DIR=`pwd`/../../../out
echo "JAVA_HOME: $JAVA_HOME"
echo "OUT_DIR: $OUT_DIR"
../../../gradlew -i --no-daemon -p . packForXCode
name: GradleCompile
info:
path: plists/Ios/Info.plist
Expand Down
27 changes: 22 additions & 5 deletions compose/mpp/demo/regenerate_xcode_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@ cd "$(dirname "$0")" || exit

if command -v xcodegen >/dev/null 2>&1; then
# xcodegen exists
PROJECT_NAME=ComposeDemo

projPath="ComposeDemo.xcodeproj"
if [[ -z "$COMPOSE_DEMO_APPLE_TEAM_ID" ]]; then
echo "COMPOSE_DEMO_APPLE_TEAM_ID is not set"
COMPOSE_DEMO_APPLE_TEAM_ID="N462MKSJ7M"
fi

if [[ -z "$JAVA_HOME" ]]; then
echo "JAVA_HOME is not set"
exit 1
fi

if [ -d "$projPath" ]; then
PROJECT_FILE_PATH="$PROJECT_NAME.xcodeproj"

if [ -d "$PROJECT_FILE_PATH" ]; then
echo "Removing existing project"
rm -rf "$projPath"
rm -rf "$PROJECT_FILE_PATH"
fi

xcodegen
open $projPath
INPUT_FILE="project.template.yml"
OUTPUT_FILE="project.generated.yml"

# replace template placeholders with actual values
sed -e "s|%@JAVA_HOME@%|$JAVA_HOME|g" -e "s|%@PROJECT_NAME@%|$PROJECT_NAME|g" -e "s|%@COMPOSE_DEMO_APPLE_TEAM_ID@%|$COMPOSE_DEMO_APPLE_TEAM_ID|g" $INPUT_FILE > $OUTPUT_FILE

xcodegen --spec $OUTPUT_FILE
open $PROJECT_FILE_PATH
else
# xcodegen does not exist
echo "Error: xcodegen not found. Please install it using 'brew install xcodegen'."
Expand Down

0 comments on commit f56a88b

Please sign in to comment.