Skip to content

Commit 6f429a2

Browse files
authored
Overhaul heroku-deploy-standalone (#232)
1 parent f6ca911 commit 6f429a2

File tree

33 files changed

+2868
-238
lines changed

33 files changed

+2868
-238
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,38 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
integration-linux:
14+
name: "Integration Tests"
15+
runs-on: ubuntu-22.04
16+
env:
17+
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
18+
HEROKU_API_USER: ${{ secrets.HEROKU_API_USER }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-java@v3
22+
with:
23+
distribution: zulu
24+
java-version: "21"
25+
- name: Setup Git
26+
run: |
27+
git config --global user.email "[email protected]"
28+
git config --global user.name "Example"
29+
- name: Update Rust toolchain
30+
run: rustup update
31+
- name: Install Heroku CLI
32+
run: curl https://cli-assets.heroku.com/install.sh | sh
33+
- name: Package heroku-deploy-standalone
34+
run: "./mvnw --batch-mode package"
35+
- name: Package integration test fixtures
36+
working-directory: "integration-test/fixtures/war-app"
37+
run: "./mvnw --batch-mode package"
38+
- name: Package integration test fixtures
39+
working-directory: "integration-test/fixtures/jar-app"
40+
run: "./mvnw --batch-mode package"
41+
- name: Run integration tests
42+
working-directory: "integration-test"
43+
run: "cargo test"
44+
1345
maven:
1446
name: "Execute build, run tests (Java ${{ matrix.java-version }})"
1547
runs-on: ubuntu-22.04

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## main
4+
5+
### heroku-deploy-standalone
6+
7+
* Add proper CLI to configure all aspects of app deployment. Previously used Java properties are no longer supported. See `--help` for usage. ([#232](https://github.com/heroku/heroku-maven-plugin/pull/232))
8+
* Unify usage between WAR and JAR files. heroku-deploy-standalone will now automatically use the correct mode based on file extension. ([#232](https://github.com/heroku/heroku-maven-plugin/pull/232))
9+
* Default `webapp-runner` version is now always the most recently released version. ([#232](https://github.com/heroku/heroku-maven-plugin/pull/232))
10+
311
## 3.0.5
412

513
* Update dependencies. ([#142](https://github.com/heroku/heroku-maven-plugin/pull/142))

heroku-deploy-standalone/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Heroku JVM App Deploy   ![License](https://img.shields.io/github/license/heroku/heroku-maven-plugin) ![Maven Central](https://img.shields.io/maven-central/v/com.heroku.sdk/heroku-sdk-parent) [![CI](https://github.com/heroku/heroku-maven-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/heroku/heroku-maven-plugin/actions/workflows/ci.yml)
2+
3+
This command line tool is used to deploy JVM applications directly to Heroku without pushing to a Git repository.
4+
It uses [Heroku's Platform API](https://devcenter.heroku.com/articles/platform-api-quickstart).
5+
This can be useful when deploying from a CI server, deploying pre-built JAR or WAR files.
6+
7+
It will automatically include and configure a Tomcat server via [webapp-runner](https://github.com/heroku/webapp-runner) if a WAR file is deployed.
8+
9+
## Table of Contents
10+
* [Installation](#installation)
11+
* [Usage](#usage)
12+
* [Requirements](#requirements)
13+
* [Configuration](#configuration)
14+
+ [Heroku API Key](#heroku-api-key)
15+
16+
## Installation
17+
18+
Download the latest release from [Maven Central](https://repo1.maven.org/maven2/com/heroku/sdk/heroku-deploy-standalone/).
19+
The JAR file contains all required dependencies.
20+
21+
## Usage
22+
23+
```shell
24+
java -jar heroku-deploy-standalone-0.0.0.jar --help
25+
```
26+
27+
```
28+
Usage: heroku-deploy-standalone [-hV] [--disable-auto-includes] [-a=<appName>]
29+
[-j=<jdkString>] [--jar-opts=<jarFileOpts>]
30+
[--webapp-runner-version=<webappRunnerVersion>]
31+
[-b[=<buildpacks>...]]... [-i
32+
[=<includedPaths>...]]... <mainFile>
33+
Application for deploying Java applications to Heroku.
34+
<mainFile> The JAR or WAR file to deploy.
35+
-a, --app=<appName> The name of the Heroku app to deploy to.
36+
-b, --buildpack[=<buildpacks>...]
37+
38+
--disable-auto-includes
39+
40+
-h, --help Show this help message and exit.
41+
-i, --include[=<includedPaths>...]
42+
Additional files or directories to include.
43+
-j, --jdk=<jdkString>
44+
--jar-opts=<jarFileOpts>
45+
46+
-V, --version Print version information and exit.
47+
--webapp-runner-version=<webappRunnerVersion>
48+
The version of webapp-runner to use. Defaults to the
49+
most recent version (9.0.80.0).
50+
```
51+
52+
53+
## Requirements
54+
55+
- Java 8u101 or higher (versions < u101 might experience difficulties displaying build log output)
56+
57+
## Configuration
58+
59+
### Heroku API Key
60+
This plugin uses Heroku's Platform API and thus requires an API key to function. If you have the
61+
[Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) installed and logged in with `heroku login`, the plugin will automatically
62+
pick up your API key. Alternatively, you can use the `HEROKU_API_KEY` environment variable to set your API key:
63+
64+
```shell
65+
$ HEROKU_API_KEY="xxx-xxx-xxxx" java -jar heroku-deploy-standalone-0.0.0.jar ...
66+
```

heroku-deploy-standalone/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
<artifactId>slf4j-nop</artifactId>
2626
<version>2.0.9</version>
2727
</dependency>
28+
<dependency>
29+
<groupId>info.picocli</groupId>
30+
<artifactId>picocli</artifactId>
31+
<version>4.7.4</version>
32+
</dependency>
2833
</dependencies>
2934

3035
<build>
@@ -40,7 +45,7 @@
4045
<appendAssemblyId>false</appendAssemblyId>
4146
<archive>
4247
<manifest>
43-
<mainClass>com.heroku.sdk.deploy.DeployWar</mainClass>
48+
<mainClass>com.heroku.sdk.deploy.standalone.Main</mainClass>
4449
</manifest>
4550
</archive>
4651
</configuration>

heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/DeployJar.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/DeployWar.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

heroku-deploy-standalone/src/main/java/com/heroku/sdk/deploy/RunWar.java

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.heroku.sdk.deploy.standalone;
2+
3+
import com.heroku.sdk.deploy.lib.resolver.AppNameResolver;
4+
import com.heroku.sdk.deploy.lib.resolver.WebappRunnerResolver;
5+
import picocli.CommandLine;
6+
import java.nio.file.Paths;
7+
import java.util.Optional;
8+
9+
public class DefaultValueProvider implements CommandLine.IDefaultValueProvider {
10+
@Override
11+
public String defaultValue(CommandLine.Model.ArgSpec argSpec) throws Exception {
12+
13+
if (argSpec instanceof CommandLine.Model.OptionSpec) {
14+
CommandLine.Model.OptionSpec optionSpec = (CommandLine.Model.OptionSpec) argSpec;
15+
16+
if (optionSpec.shortestName().equalsIgnoreCase("-a")) {
17+
Optional<String> appName = AppNameResolver.resolveViaHerokuGitRemote(Paths.get(System.getProperty("user.dir")));
18+
if (appName.isPresent()) {
19+
return appName.get();
20+
}
21+
}
22+
23+
if (optionSpec.shortestName().equalsIgnoreCase("--webapp-runner-version")) {
24+
return WebappRunnerResolver.getLatestVersion();
25+
}
26+
}
27+
28+
return null;
29+
}
30+
}

0 commit comments

Comments
 (0)