This script is a utility designed for CI/CD environments (primarily GitHub Actions) to globally configure sbt, Maven, and Gradle to use the Akka repository. This ensures that dependencies hosted by Akka can be resolved without modifying individual project source files. It automates the setup of repository resolvers and deployment credentials across multiple build systems with primary goals of:
- Global Dependency Resolution: Injects Akka Release and Snapshot URLs into global config files.
- Credential Injection: Dynamically sets up Sonatype Maven Central deployment credentials if environment variables are present.
- Security: Configures a Maven HTTP blocker to prevent insecure repository connections.
- Test Isolation: Specifically configures sbt "scripted" tests for plugin development.
The script accepts two positional arguments. It includes logic to handle cases where only one argument is provided.
| Parameter | Position | Required | Description |
|---|---|---|---|
| SBT Project Name | $1 |
No | The name of the sbt plugin project directory. Used to locate src/sbt-test for scripted test setup. |
| Mirror Control | $2 |
No | Set to NO_MIRROR to prevent the script from injecting <mirrors> into the Maven settings.xml. |
- If 2 arguments are provided:
$1is the project name,$2is the mirror control. - If 1 argument is provided and it contains "MIRROR": The script treats it as the mirror control flag and leaves the project name empty.
- If 1 argument is provided and it does NOT contain "MIRROR": It is treated as the sbt project name.
The script utilizes the following environment variables for advanced configuration:
SONATYPE_USERNAME: The username for Sonatype/Maven Central.SONATYPE_PASSWORD: The password/token for Sonatype/Maven Central.PGP_PASSPHRASE: The passphrase used for GPG signing of artifacts.
The general format for use in Github Actions is:
- name: Checkout Global Scripts
uses: actions/checkout@v4
with:
repository: akka/github-actions-scripts
path: scripts
fetch-depth: 0
- name: Setup global resolver
run: |
chmod +x ./scripts/setup_global_resolver.sh
./scripts/setup_global_resolver.sh
Then the specific use of the shell would look like the followin
Standard usage for a library (No scripted tests):
./scripts/setup_global_resolver.shUsage for an sbt plugin (Enables scripted test setup):
./scripts/setup_global_resolver.sh sbt-pluginUsage where Maven mirrors must be disabled:
./scripts/setup_global_resolver.sh NO_MIRRORCreates or appends to ~/.sbt/1.0/resolvers.sbt. It adds the Akka release and snapshot URLs as global resolvers for all sbt builds on the machine.
If a project name is provided, the script searches for build.sbt files within the sbt-test directory. It then creates a global/resolvers.sbt file for every individual test case found. This is critical for sbt plugin testing where each test case runs in an isolated environment.
Generates a Gradle Init Script at ~/.gradle/init.d/akka-resolvers.init.gradle. This uses the allprojects block to inject the Akka Maven repositories into both the buildscript (for plugins) and the standard repositories (for dependencies).
Generates a ~/.m2/settings.xml file with:
- Mirrors: Blocks all plain
httptraffic for security and redirects Akka requests. - Profiles: Creates an
akka-repoprofile and sets it to<activeByDefault>. - Credentials: If Sonatype variables are found, it injects
<servers>and GPG properties into the settings file.