Skip to content

Commit

Permalink
Support both "versions-maven-plugin" and auto-native DOM/XML
Browse files Browse the repository at this point in the history
`auto` will detect if the parent `pom.xml` file has the `versions-maven-plugin` configured, and if so, use it to set the version on the parent and all child pom.xml files. If not, then auto will modify the parent and all child `pom.xml` files using a DOM parser and XML serializer. This has the effect of losing formatting. Therefore it then runs the serialized XML through the `prettier` "html" pretty-printer.

This means that if the versions-maven-plugin isn't available, the pom.xml files will be pretty-printed using prettier formatter with the following default settings:

* `printWidth: 120` (configurable - see below)
* `tabWidth: 4` (configurable - see below)
* `parser: "html"`
  • Loading branch information
hipstersmoothie committed Jun 18, 2020
1 parent 1fbede9 commit eda05a6
Show file tree
Hide file tree
Showing 7 changed files with 1,202 additions and 212 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.27",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/react-fontawesome": "^0.1.9",
"@types/jest": "^26.0.0",
"@types/parse-github-url": "1.0.0",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
Expand All @@ -61,6 +62,7 @@
"husky": "^4.0.7",
"ignite": "1.11.2",
"jest": "~25.5.4",
"jest-circus": "^26.0.1",
"jest-serializer-path": "^0.1.15",
"jest-snapshot-serializer-ansi": "^1.0.0",
"lerna": "^3.13.4",
Expand Down Expand Up @@ -102,6 +104,7 @@
"!**/dist/**/*",
"!**/scripts/template-plugin/**/*"
],
"testRunner": "jest-circus/runner",
"snapshotSerializers": [
"jest-serializer-path",
"jest-snapshot-serializer-ansi"
Expand Down
55 changes: 45 additions & 10 deletions plugins/maven/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maven Plugin

Release a Java project to a [maven](https://maven.apache.org/) repository.
Release a Java project to a [maven][maven] repository.

## Installation

Expand All @@ -14,6 +14,18 @@ yarn add -D @auto-it/maven

## Usage

`auto` will detect if the parent `pom.xml` file has the [`versions-maven-plugin`][versions-maven-plugin] configured, and
if so, use it to set the version on the parent and all child `pom.xml` files. If not, then `auto` will modify the parent
and all child `pom.xml` files using a DOM parser and XML serializer. This has the effect of losing formatting. Therefore
it then runs the serialized XML through the `prettier` "html" pretty-printer.

This means that if the `versions-maven-plugin` isn't available, the `pom.xml` files will be pretty-printed using `prettier`
formatter with the following default settings:

- `printWidth: 120` (configurable - see below)
- `tabWidth: 4` (configurable - see below)
- `parser: "html"`

```jsonc
{
"plugins": [
Expand All @@ -35,7 +47,15 @@ yarn add -D @auto-it/maven

// An optional path to a maven settings.xml file
// @default ""
"mavenSettings": "./.github/maven/settings.xml"
"mavenSettings": "./.github/maven/settings.xml",

// An optional printWidth for the prettier pretty-printer
// @default 120
"printWidth": 80,

// An optional tabWidth for the prettier pretty-printer
// @default 4
"tabWidth": 4
}
]
// other plugins
Expand All @@ -62,28 +82,43 @@ You will need all the following configuration blocks for all parts of `auto` to

```xml
<developers>
<developer>
<name>Andrew Lisowski</name>
<email>[email protected]</email>
</developer>
<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>
<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>
```

3. Versions Maven Plugin **RECOMMENDED** (Optional)

```xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
```

> :warning: Don't forget to set enviornment variables `GH_USER`, `GH_TOKEN`
3. Version

```xml
<version>1.0.0-SNAPSHOT</version>
```

[maven]: https://maven.apache.org/
[versions-maven-plugin]: https://www.mojohaus.org/versions-maven-plugin/
Loading

0 comments on commit eda05a6

Please sign in to comment.