Skip to content

Commit

Permalink
Maven plugin support for configurable SNAPSHOT branch
Browse files Browse the repository at this point in the history
Currently, the Maven has an undocumented requirement for a "dev-snapshot" branch for committing the next SNAPSHOT version after release. These changes:
1. Add a new environment variable `MAVEN_SNAPSHOT_BRANCH` that can be used to configure the SNAPSHOT branch.
2. Document all environment variables used by this plugin directly. *NOTE: environment variables used in a `pom.xml` or `settings.xml` or other Maven configuration files are NOT documented here.*
  • Loading branch information
G. Richard Bellamy committed May 21, 2020
1 parent 62c4482 commit 6a0c98d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
59 changes: 34 additions & 25 deletions plugins/maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Release a Java project to a [maven](https://maven.apache.org/) instance.

This plugin is not included with the `auto` CLI installed via NPM. To install:

```sh
```shell script
npm i --save-dev @auto-it/maven
# or
yarn add -D @auto-it/maven
Expand All @@ -20,6 +20,15 @@ yarn add -D @auto-it/maven
}
```

## Environment Variables

| Name | Description | Default value |
| ----------------------- | ------------------------------------------------------------------------------------------------ | -------------- |
| `MAVEN_USERNAME` | The deploy username used to login to the repository. | `null` |
| `MAVEN_PASSWORD` | The deploy password used to login to the repository. | `null` |
| `MAVEN_SETTINGS` | The maven `settings.xml` file used by maven. | `null` |
| `MAVEN_SNAPSHOT_BRANCH` | The branch on which the `SNAPSHOT` version lives. Must be different than the Auto "base branch." | `dev-snapshot` |

## Maven Project Configuration

Your project must be using the maven release plugin. Make sure the the latest `maven-release-plugin` is in your `pom.xml`.
Expand All @@ -33,39 +42,39 @@ Your project must be using the maven release plugin. Make sure the the latest `m
<preparationGoals>initialize</preparationGoals>
<goals>deploy</goals>
</configuration>
</plugin
</plugin>
```

You will also need all of the following configuration blocks for all parts of `auto` to function:
You will also need all the following configuration blocks for all parts of `auto` to function:

1. Author

```xml
<developers>
<developer>
<name>Andrew Lisowski</name>
<email>[email protected]</email>
</developer>
</developers>
```
```xml
<developers>
<developer>
<name>Andrew Lisowski</name>
<email>[email protected]</email>
</developer>
</developers>
```

2. SCM

```xml
<scm>
<connection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</connection>
<developerConnection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</developerConnection>
<url>https://github.com/Fuego-Tools/java-test-project</url>
<tag>HEAD</tag>
</scm>
```
```xml
<scm>
<connection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</connection>
<developerConnection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</developerConnection>
<url>https://github.com/Fuego-Tools/java-test-project</url>
<tag>HEAD</tag>
</scm>
```

::: message is-info
Don't forget to set enviornment variables `GH_USER`, `GH_TOKEN`
:::
::: message is-info
Don't forget to set enviornment variables `GH_USER`, `GH_TOKEN`
:::

3. Version

```xml
<version>1.0.0-SNAPSHOT</version>
```
```xml
<version>1.0.0-SNAPSHOT</version>
```
6 changes: 4 additions & 2 deletions plugins/maven/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ export default class MavenPlugin implements IPlugin {
});

auto.hooks.afterShipIt.tapPromise(this.name, async () => {
const { MAVEN_SNAPSHOT_BRANCH } = process.env;
const mavenSnapshotBranch = MAVEN_SNAPSHOT_BRANCH || "dev-snapshot";
// prepare for next development iteration
await execPromise("git", ["reset", "--hard", "dev-snapshot"]);
await execPromise("git", ["branch", "-d", "dev-snapshot"]);
await execPromise("git", ["reset", "--hard", mavenSnapshotBranch]);
await execPromise("git", ["branch", "-d", mavenSnapshotBranch]);
await execPromise("git", ["push", auto.remote, auto.baseBranch]);
});
}
Expand Down

0 comments on commit 6a0c98d

Please sign in to comment.