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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<servers>
<server>
<id>nexusExt</id>
<username>${env.NEXUS_EXT_USERNAME}</username>
<password>${env.NEXUS_EXT_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>nexusExt</id>
<repositories>
<repository>
<id>nexusExt</id>
<name>External Dalet Nexus</name>
<url>https://nexus-ext.services.ooflex.net/repository/maven</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexusExt</activeProfile>
</activeProfiles>
</settings>
32 changes: 28 additions & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ concurrency:
cancel-in-progress: false

jobs:
compile-and-test:
external-scripts:
strategy:
matrix:
java-version: [ 17 ]
os: [ubuntu-latest, macos-latest]
module: [ExternalScripts, UsingAnIdeToWriteScripts]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -36,13 +35,38 @@ jobs:
uses: gradle/gradle-build-action@v2

- name: Assemble
run: cd ${{ matrix.module }}; ./gradlew assemble -PnexusExtUsername=${NEXUS_EXT_USERNAME} -PnexusExtPassword=${NEXUS_EXT_PASSWORD}
working-directory: ExternalScripts
run: ./gradlew assemble -PnexusExtUsername=${NEXUS_EXT_USERNAME} -PnexusExtPassword=${NEXUS_EXT_PASSWORD}
env:
NEXUS_EXT_USERNAME: ${{ vars.NEXUS_EXT_USERNAME }}
NEXUS_EXT_PASSWORD: ${{ secrets.NEXUS_EXT_PASSWORD }}

- name: Check
run: cd ${{ matrix.module }}; ./gradlew check -PnexusExtUsername=${NEXUS_EXT_USERNAME} -PnexusExtPassword=${NEXUS_EXT_PASSWORD}
working-directory: ExternalScripts
run: ./gradlew check -PnexusExtUsername=${NEXUS_EXT_USERNAME} -PnexusExtPassword=${NEXUS_EXT_PASSWORD}
env:
NEXUS_EXT_USERNAME: ${{ vars.NEXUS_EXT_USERNAME }}
NEXUS_EXT_PASSWORD: ${{ secrets.NEXUS_EXT_PASSWORD }}

using-an-ide-to-write-scripts:
strategy:
matrix:
java-version: [ 21 ]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java and Maven
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}

- name: Compile and test
working-directory: UsingAnIdeToWriteScripts
run: mvn --batch-mode --settings ../.github/maven-settings.xml test
env:
NEXUS_EXT_USERNAME: ${{ vars.NEXUS_EXT_USERNAME }}
NEXUS_EXT_PASSWORD: ${{ secrets.NEXUS_EXT_PASSWORD }}
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[![CI Build](https://github.com/dalet-oss/flex-scripting-examples/actions/workflows/ci-build.yml/badge.svg)](https://github.com/dalet-oss/flex-scripting-examples/actions/workflows/ci-build.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.dalet-oss/flex-scripting-examples/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.dalet-oss/flex-scripting-examples) [![Licence](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/dalet-oss/flex-scripting-examples/blob/master/LICENSE)
---

This repository contains 2 projects that can help springboard your development of Flex scripts:
This repository contains two projects that can help springboard your development of Flex scripts:

* [External Scripts](ExternalScripts/README.md) - An example project on how to write scripts that are assembled into
JARs and referenced from Flex scripting actions via the `JAR File URLs` configuration field.
* [UsingAnIdeToWriteScripts](UsingAnIdeToWriteScripts/README.md) - A project that demonstrates how to write Flex
scripts using an IDE in order to leverage code completion, unit testing and source control, before being copy and
pasted into Flex.
* [External Scripts](ExternalScripts/README.md) — A Gradle project demonstrating how to write scripts that are
assembled into JARs and referenced from Flex scripting actions through the `JAR File URLs` configuration field.
* [Using an IDE to Write Scripts](UsingAnIdeToWriteScripts/README.md) — A Maven project demonstrating how to use an IDE
for code completion, unit testing and source control before copying a script into Flex.
88 changes: 71 additions & 17 deletions UsingAnIdeToWriteScripts/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,73 @@
This repository demonstrates how Flex scripts can be written within an IDE, in order to provide code completion and
unit testing capabilities. Code written in this manner can also be managed by source control, although care needs to be
taken to keep the code in source control in sync with the scripts in Flex.

The folder `src/main/groovy` contains an example script class CreateNewAssetScript, which creates a simple placeholder
asset. The code can be copy and pasted from the class into a Flex scripting action `script` configuration field. There
is a correspondingunit test for this script in `test/main/groovy`.

N.B.:
- If you are within Dalet, you will have to update the `repositories` section of `build.gradle` to target the internal
Nexus instance.
- If you are outside Dalet, then as noted in `build.gradle` you will have to provide Nexus username & password
properties to Gradle invocations, such as:
`./gradlew test -PnexusExtUsername=${NEXUS_EXT_USERNAME} -PnexusExtPassword=${NEXUS_EXT_PASSWORD}`

To compile and run the unit tests from the command line, run:
# Using an IDE to Write Flex Scripts

This Maven project demonstrates how to write Flex scripts in an IDE with code completion, unit tests and source
control. Scripts managed in this repository must be kept in sync with the corresponding scripting action
configuration in Flex.

The example uses Java 21, matching the Flex service that executes Groovy scripts.

## IntelliJ IDEA setup

1. Open `pom.xml` as a project, or add it as a Maven module to an existing project.
2. Select a Java 21 JDK for the project and Maven runner.
3. Reload the Maven project when prompted.

Maven registers `src/main/groovy` and `src/test/groovy` as source roots. IntelliJ should therefore provide Groovy and
Flex SDK code completion without a separately downloaded Groovy SDK.

## Accessing the Flex SDK

The Flex SDK is hosted in the Dalet Nexus repository. Users with access to Dalet Nexus can add it directly as a Maven
repository in IntelliJ IDEA under **Settings | Build, Execution, Deployment | Build Tools | Maven | Repositories**.

The preferred option for users with access is to configure Nexus as a mirror in `~/.m2/settings.xml`. This applies
consistently to Maven on the command line and to IntelliJ IDEA without adding machine-specific configuration to this
repository:

```xml
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Dalet Nexus</name>
<url>https://nexus-internal.ooflex.net/repository/maven</url>
</mirror>
</mirrors>
</settings>
```

### External users without access to Dalet Nexus

Contact your Dalet representative to request access to the Flex SDK dependency. If Nexus access is not available,
Dalet will provide both files for the appropriate SDK version:

* `flex-sdk-external-<version>.jar`
* `flex-sdk-external-<version>.pom`, the flattened POM containing the resolved dependency versions

Install the JAR and its flattened POM into your local Maven repository:

```shell
mvn install:install-file \
-Dfile=flex-sdk-external-<version>.jar \
-DpomFile=flex-sdk-external-<version>.pom
```
./gradlew test

Keep the standard `flex-sdk-external` dependency in `pom.xml` and set `flex-sdk.version` to the version supplied by
Dalet. Maven will then use the locally installed SDK and its flattened dependency metadata.

## Example script

`src/main/groovy/CreateNewAssetScript.groovy` creates a placeholder asset. Its `context` and `flexSdkClient` fields
exist only to give the IDE type information; Flex supplies those objects when it executes the script.

Copy the `execute` method into the Flex scripting action's `script` configuration field. The corresponding Mockito test
is in `src/test/groovy/CreateNewAssetScriptTest.groovy`.

## Test

Compile the script and run its unit test with:

```shell
mvn test
```
45 changes: 0 additions & 45 deletions UsingAnIdeToWriteScripts/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion UsingAnIdeToWriteScripts/gradle.properties

This file was deleted.

Binary file not shown.

This file was deleted.

Loading
Loading