This action sets up Maven environments for use in GitHub Actions by:
interactiveMode
to false - useful in CI systemThis project uses Semantic Versioning. We recommended to use the latest and specific release version.
In order to keep your project dependencies up to date you can watch this repository (Releases only) or use automatic tools like Dependabot.
You can try our action Setup Maven Action for completely maven environment setup.
See action.yml
settings.xml
steps:
- uses: s4u/maven-settings-action@v3.1.0
settings.xml
with servers sectionsteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
Also you can use path
argument if your settings.xml is stored in different location.
All server
attributes may be specified:
id
(required)username
password
privateKey
passphrase
filePermissions
directoryPermissions
configuration
Please refer to the servers documentation for more information.
settings.xml
with servers section and additional configurationsteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
servers: |
[{
"id": "serverId",
"configuration": {
"item1": "value1",
"item2": {
"item21": "value21",
"item22": "value22"
}
}
}]
result will be:
<servers><server>
<id>serverId</id>
<configuration>
<item1>value1</item1>
<item2>
<item21>value21</item21>
<item22>value22</item22>
</item1>
</configuration>
</server></servers>
settings.xml
with mirrors sectionsteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
settings.xml
with proxies sectionstep:
- uses: s4u/maven-settings-action@v3.1.0
with:
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost", "user": "proxUser", "password": "proxPassword"}]'
Note: Authentication details are optional.
settings.xml
with propertiessteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
settings.xml
with https://oss.sonatype.org/content/repositories/snapshots in repository liststeps:
- uses: s4u/maven-settings-action@v3.1.0
with:
sonatypeSnapshots: true
settings.xml
with https://repository.apache.org/snapshots/ in repository liststeps:
- uses: s4u/maven-settings-action@v3.1.0
with:
apacheSnapshots: true
settings.xml
, from version 2.0 file is override by default :steps:
- uses: s4u/maven-settings-action@v3.1.0
with:
override: false
settings.xml
, by default is added:steps:
- uses: s4u/maven-settings-action@v3.1.0
with:
githubServer: false
settings.xml
with special server item configuration for oracle repository Oracle Maven Repositorysteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
settings.xml
with Oracle Maven Repositorysteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
oracleRepo: true
settings.xml
with custom repositoriessteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
repositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
settings.xml
with custom plugin repositoriessteps:
- uses: s4u/maven-settings-action@v3.1.0
with:
pluginRepositories: '[{"id":"repoId","name":"repoName","url":"url","snapshots":{"enabled":true}}]'
It is also possible pass in Github Secrets e.g.
steps:
- uses: s4u/maven-settings-action@v3.1.0
with:
servers: |
[{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
Note: secrets are not passed in if the workflow is triggered from a forked repository. See here for further information. This can be avoided by using if
triggers on the job e.g. if: github.event_name == 'push'
.
maven-settings-action should be put at the latest position before maven run in order to avoid override setting.xml
by another action
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: maven-
- uses: actions/setup-java@v1
with:
java-version: 8
- uses: s4u/maven-settings-action@v3.1.0
- run: mvn verify
The scripts and documentation in this project are released under the MIT License.