Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whelk-io/maven-settings-xml-action
Github Action to create maven settings (~/.m2/settings.xml)
https://github.com/whelk-io/maven-settings-xml-action
github-actions maven
Last synced: 3 months ago
JSON representation
Github Action to create maven settings (~/.m2/settings.xml)
- Host: GitHub
- URL: https://github.com/whelk-io/maven-settings-xml-action
- Owner: whelk-io
- License: apache-2.0
- Created: 2019-12-31T04:21:27.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T10:39:34.000Z (7 months ago)
- Last Synced: 2024-10-25T01:18:52.055Z (3 months ago)
- Topics: github-actions, maven
- Language: JavaScript
- Homepage: http://whelk.io
- Size: 2.78 MB
- Stars: 70
- Watchers: 2
- Forks: 27
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-actions - Generate ~/.m2/settings.xml for Maven builds
- fucking-awesome-actions - Generate ~/.m2/settings.xml for Maven builds
- awesome-workflows - Generate ~/.m2/settings.xml for Maven builds
README
# maven-settings-xml-action
[![CodeFactor](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action/badge)](https://www.codefactor.io/repository/github/whelk-io/maven-settings-xml-action) ![build-test](https://github.com/whelk-io/maven-settings-xml-action/workflows/build-test/badge.svg) [![CodeQL](https://github.com/whelk-io/maven-settings-xml-action/actions/workflows/codeql-analysis.yml/badge.svg?branch=main)](https://github.com/whelk-io/maven-settings-xml-action/actions/workflows/codeql-analysis.yml)
Github Action to create maven settings (`~/.m2/settings.xml`).
Supports ``, ``, ``, ``, ``, ``, ``, and ``.
## Inputs
### `servers`
**Optional** json array of servers to add to settings.xml.
* **id** - The ID of the server (not of the user to login as) that matches the id element of the repository/mirror that Maven tries to connect to.
* **username**, **password** - These elements appear as a pair denoting the login and password required to authenticate to this server.
* **privateKey**, **passphrase** - Like the previous two elements, this pair specifies a path to a private key (default is `${user.home}/.ssh/id_dsa`) and a `passphrase`, if required.
* **filePermissions**, **directoryPermissions** - When a repository file or directory is created on deployment, these are the permissions to use. The legal values of each is a three digit number corresponding to *nix file permissions, e.g. 664, or 775.
* **configuration** - Any additional custom configuration for server in JSON format.Reference: [Maven Settings > Servers](http://maven.apache.org/settings.html#servers)
### `mirrors`
* **id** - The unique identifier of this mirror. The `id` is used to differentiate between mirror elements and to pick the corresponding credentials from the `` section when connecting to the mirror.
* **mirrorOf** - The `id` of the repository that this is a mirror of. For example, to point to a mirror of the Maven central repository (`https://repo.maven.apache.org/maven2/`), set this element to `central`. More advanced mappings like `repo1,repo2` or `*,!inhouse` are also possible. This must not match the mirror `id`.
* **url** - The base URL of this mirror. The build system will use this URL to connect to a repository rather than the original repository URL.Reference: [Maven Settings > Mirrors](http://maven.apache.org/settings.html#mirrors)
### `repositories`
**Optional** json array of repositories to add to settings.xml
* **id** - The ID of the repository that matches the id element of the server.
* **name** - Name of the repository.
* **url** - URL to connect to repository.
* **releases.enabled** - Enable release policy.
* **snapshots.enabled** - Enable snapshot policy.When not `repostories` is empty or null, the Maven Central repository is applied by default:
```yaml
repositories: |
[
{
"id": "central",
"name": "Maven Central",
"url": "https://repo1.maven.org/maven2",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
```Reference: [Maven Settings > Repositories](http://maven.apache.org/settings.html#repositories)
### `plugin_repositories`
**Optional** json array of repositories to add to settings.xml
* **id** - The ID of the repository that matches the id element of the server.
* **name** - Name of the repository.
* **url** - URL to connect to repository.
* **releases.enabled** - Enable release policy.
* **snapshots.enabled** - Enable snapshot policy.Reference: [Maven Settings > Plugin Repositories](http://maven.apache.org/settings.html#Plugin_Repositories)
### `plugin_groups`
**Optional** json array of plugin groups to add to settings.xmlReference: [Maven Settings > Plugin Groups](http://maven.apache.org/settings.html#Plugin_Groups)
### `profiles`
**Optional** json array of profiles to add to settings.xmlThe `profile` element in the `settings.xml` is a truncated version of the `pom.xml` `profile` element. It consists of the `activation`, `repositories`, `pluginRepositories` and `properties` elements. The `profile` elements only include these four elements because they concerns themselves with the build system as a whole (which is the role of the `settings.xml` file), not about individual project object model settings.
Reference: [Maven Settings > Profiles](http://maven.apache.org/settings.html#profiles)
### `active_profiles`
**Optional** json array of active profiles to add to settings.xmlSet of `activeProfile` elements, which each have a value of a `profile` `id`. Any `profile` `id` defined as an `activeProfile` will be active, regardless of any environment settings. If no matching profile is found nothing will happen. For example, if `env-test` is an `activeProfile`, a profile in a `pom.xml` (or `profile.xml`) with a corresponding `id` will be active. If no such profile is found then execution will continue as normal.
Reference: [Maven Settings > Active Profiles](https://maven.apache.org/settings.html#Active_Profiles)
### `proxies`
**Optional** json array of proxies to add to settings.xml.
* **id** - The unique identifier for this proxy. This is used to differentiate between proxy elements.
* **active** - true if this proxy is active. This is useful for declaring a set of proxies, but only one may be active at a time.
* **protocol, host, port** - The protocol://host:port of the proxy, separated into discrete elements.
* **username, password** - These elements appear as a pair denoting the login and password required to authenticate to this proxy server.
* **nonProxyHosts** - This is a list of hosts which should not be proxied. The delimiter of the list is the expected type of the proxy server; the example above is pipe delimited - comma delimited is also common.Reference: [Maven Settings > Proxies](https://maven.apache.org/settings.html#proxies)
### `output_file`
**Optional** String path of to generate `settings.xml`. By default, `~/.m2/settings.xml` is used.When using a custom `output_file`, for example:
```yaml
- uses: whelk-io/maven-settings-xml-action@v22
with:
output_file: foo/custom.xml
```The generated `settings.xml` will be created at `/home/runner/work/{repo}/foo/custom.xml`, which can be referenced in maven steps using `mvn --settings foo/custom.xml {goal}`.
---
## Basic Usage
````yaml
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: '[{ "id": "some-repository", "url": "http://some.repository.url" }]'
plugin_repositories: '[{ "id": "some-plugin-repository", "url": "http://some.plugin.repository.url" }]'
servers: '[{ "id": "some-server", "username": "some.user", "password": "some.password" }]'
````**Output**
````xml
github
github
some-repository
http://some.repository.url
some-plugin-repository
http://some.plugin.repository.url
foo
fu
bar
````
----
## Full Usage
````yaml
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: >
[
{
"id": "some-repository",
"name": "some-repository-name",
"url": "http://some.repository.url",
"releases": {
"enabled": "true",
"updatePolicy": "always",
"checksumPolicy": "fail"
},
"snapshots": {
"enabled": "false",
"updatePolicy": "always",
"checksumPolicy": "fail"
}
}
]
plugin_repositories: >
[
{
"id": "some-plugin-repository",
"name": "some-plugin-repository-name",
"url": "http://some.plugin.repository.url",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
servers: >
[
{
"id": "some-id",
"username": "${env.USER}",
"password": "${env.PASS}",
"configuration": {
"httpConfiguration": {
"all": {
"usePreemptive": "true"
}
}
}
}
]
mirrors: >
[
{
"id": "nexus",
"mirrorOf": "!my-org-snapshots,*",
"url": "http://redacted/nexus/content/groups/public"
}
]
profiles: >
[
{
"id": "foo.profile",
"name": "foo.profile",
"url": "http://foo.bar.profile",
"properties": {
"foo": "property-1",
"bar": "property-2"
}
}
]
plugin_groups: >
[
"some.plugin.group.id",
"some.other.plugin.group.id"
]
proxies: >
[
{
"id": "foo-proxy",
"active": "true",
"protocol": "http",
"host": "https://proxy.example.com",
"port": "443",
"username": "foo",
"password": "bar",
"nonProxyHosts": "noproxy1.example.com|noproxy2.example.com"
}
]
active_profiles: >
[
"some-profile"
]
output_file: .m2/settings.xml
````**Output**
````xml
some-profile
github
some-repository
some-repository-name
http://some.repository.url
true
always
fail
false
always
fail
some-plugin-repository
some-plugin-repository-name
http://some.plugin.repository.url
true
false
foo.profile
foo.profile
http://foo.bar.profile
property-1
property-2
foo
fu
bar
${user.home}/.ssh/id_dsa
some_passphrase
664
775
true
nexus
!my-org-snapshots,*
http://redacted/nexus/content/groups/public
some.plugin.group.id
some.other.plugin.group.id
foo-proxy
true
http
https://proxy.example.com
443
foo
bar
noproxy1.example.com|noproxy2.example.com
````
----
## Local Setup
See [Contributing](CONTRIBUTING.md) for guidelines for forking and contributing to this project.
**Install Dependencies**
`npm ci`
**Run Linter**
`npm run lint`
**Run Unit-Tests**
`npm test`
**Create Distribution**
`npm run build`
## Run Actions Locally
**Install [`Act`](https://github.com/nektos/act)**
`brew install act`
**Run Step**
`act -s GITHUB_TOKEN={token} -j {step}`
Example: `act -s GITHUB_TOKEN=lk34j56lk34j5lk34j5dkllsldf -j test-basic`