Skip to content

Commit eda05a6

Browse files
Support both "versions-maven-plugin" and auto-native DOM/XML
`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"`
1 parent 1fbede9 commit eda05a6

File tree

7 files changed

+1202
-212
lines changed

7 files changed

+1202
-212
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@fortawesome/fontawesome-svg-core": "^1.2.27",
4343
"@fortawesome/free-solid-svg-icons": "^5.12.1",
4444
"@fortawesome/react-fontawesome": "^0.1.9",
45+
"@types/jest": "^26.0.0",
4546
"@types/parse-github-url": "1.0.0",
4647
"@typescript-eslint/eslint-plugin": "^2.7.0",
4748
"@typescript-eslint/parser": "^2.7.0",
@@ -61,6 +62,7 @@
6162
"husky": "^4.0.7",
6263
"ignite": "1.11.2",
6364
"jest": "~25.5.4",
65+
"jest-circus": "^26.0.1",
6466
"jest-serializer-path": "^0.1.15",
6567
"jest-snapshot-serializer-ansi": "^1.0.0",
6668
"lerna": "^3.13.4",
@@ -102,6 +104,7 @@
102104
"!**/dist/**/*",
103105
"!**/scripts/template-plugin/**/*"
104106
],
107+
"testRunner": "jest-circus/runner",
105108
"snapshotSerializers": [
106109
"jest-serializer-path",
107110
"jest-snapshot-serializer-ansi"

plugins/maven/README.md

+45-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Maven Plugin
22

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

55
## Installation
66

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

1515
## Usage
1616

17+
`auto` will detect if the parent `pom.xml` file has the [`versions-maven-plugin`][versions-maven-plugin] configured, and
18+
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
19+
and all child `pom.xml` files using a DOM parser and XML serializer. This has the effect of losing formatting. Therefore
20+
it then runs the serialized XML through the `prettier` "html" pretty-printer.
21+
22+
This means that if the `versions-maven-plugin` isn't available, the `pom.xml` files will be pretty-printed using `prettier`
23+
formatter with the following default settings:
24+
25+
- `printWidth: 120` (configurable - see below)
26+
- `tabWidth: 4` (configurable - see below)
27+
- `parser: "html"`
28+
1729
```jsonc
1830
{
1931
"plugins": [
@@ -35,7 +47,15 @@ yarn add -D @auto-it/maven
3547

3648
// An optional path to a maven settings.xml file
3749
// @default ""
38-
"mavenSettings": "./.github/maven/settings.xml"
50+
"mavenSettings": "./.github/maven/settings.xml",
51+
52+
// An optional printWidth for the prettier pretty-printer
53+
// @default 120
54+
"printWidth": 80,
55+
56+
// An optional tabWidth for the prettier pretty-printer
57+
// @default 4
58+
"tabWidth": 4
3959
}
4060
]
4161
// other plugins
@@ -62,28 +82,43 @@ You will need all the following configuration blocks for all parts of `auto` to
6282

6383
```xml
6484
<developers>
65-
<developer>
66-
<name>Andrew Lisowski</name>
67-
<email>[email protected]</email>
68-
</developer>
85+
<developer>
86+
<name>Andrew Lisowski</name>
87+
<email>[email protected]</email>
88+
</developer>
6989
</developers>
7090
```
7191

7292
2. SCM
7393

7494
```xml
7595
<scm>
76-
<connection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</connection>
77-
<developerConnection>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</developerConnection>
78-
<url>https://github.com/Fuego-Tools/java-test-project</url>
79-
<tag>HEAD</tag>
96+
<connection
97+
>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</connection>
98+
<developerConnection
99+
>scm:git:https://${env.GH_USER}:${env.GH_TOKEN}@github.com/Fuego-Tools/java-test-project.git</developerConnection>
100+
<url>https://github.com/Fuego-Tools/java-test-project</url>
101+
<tag>HEAD</tag>
80102
</scm>
81103
```
82104

105+
3. Versions Maven Plugin **RECOMMENDED** (Optional)
106+
107+
```xml
108+
<plugin>
109+
<groupId>org.codehaus.mojo</groupId>
110+
<artifactId>versions-maven-plugin</artifactId>
111+
<version>2.7</version>
112+
</plugin>
113+
```
114+
83115
> :warning: Don't forget to set enviornment variables `GH_USER`, `GH_TOKEN`
84116
85117
3. Version
86118

87119
```xml
88120
<version>1.0.0-SNAPSHOT</version>
89121
```
122+
123+
[maven]: https://maven.apache.org/
124+
[versions-maven-plugin]: https://www.mojohaus.org/versions-maven-plugin/

0 commit comments

Comments
 (0)