• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

whelk-io/maven-settings-xml-action: Github Action to create maven settings (~/.m ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

whelk-io/maven-settings-xml-action

开源软件地址(OpenSource Url):

https://github.com/whelk-io/maven-settings-xml-action

开源编程语言(OpenSource Language):

JavaScript 98.3%

开源软件介绍(OpenSource Introduction):

maven-settings-xml-action

CodeFactor build-test CodeQL

Github Action to create maven settings (~/.m2/settings.xml).

Supports <servers>, <repositories>, <pluginRepositories>, <pluginGroups>, <mirrors>, <activeProfiles>, <proxies>, and <profiles>.

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

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 <servers> 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

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:

repositories: |
  [
    {
      "id": "central",
      "name": "Maven Central",
      "url": "https://repo1.maven.org/maven2",
      "releases": {
        "enabled": "true"
      },
      "snapshots": {
        "enabled": "false"
      }
    }
  ]

Reference: Maven Settings > 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

plugin_groups

Optional json array of plugin groups to add to settings.xml

Reference: Maven Settings > Plugin Groups

profiles

Optional json array of profiles to add to settings.xml

The 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

active_profiles

Optional json array of active profiles to add to settings.xml

Set 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

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

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:

- uses: whelk-io/maven-settings-xml-action@v20
  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

- name: maven-settings-xml-action
  uses: whelk-io/maven-settings-xml-action@v20
  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

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">
  
    <activeProfiles>
        <activeProfile>github</activeProfile>
    </activeProfiles>
  
    <profiles>
        <profile>
            <id>github</id>
            <repositories>
                <repository>
                    <id>some-repository</id>
                    <url>http://some.repository.url</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>some-plugin-repository</id>
                    <url>http://some.plugin.repository.url</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
  
    <servers>
        <server>
            <id>foo</id>
            <username>fu</username>
            <password>bar</password>
        </server>
    </servers>
  
</settings>

Full Usage

- name: maven-settings-xml-action
  uses: whelk-io/maven-settings-xml-action@v20
  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

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">
  
    <activeProfiles>
        <activeProfile>some-profile</activeProfile>
    </activeProfiles>
  
    <profiles>
        <profile>
            <id>github</id>
            <repositories>
                <repository>
                    <id>some-repository</id>
                    <name>some-repository-name</name>
                    <url>http://some.repository.url</url>
                    <releases>
                        <enabled>true</enabled>
                        <updatePolicy>always</updatePolicy>
                        <checksumPolicy>fail</checksumPolicy>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                        <updatePolicy>always</updatePolicy>
                        <checksumPolicy>fail</checksumPolicy>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>some-plugin-repository</id>
                    <name>some-plugin-repository-name</name>
                    <url>http://some.plugin.repository.url</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        <profile>
            <id>foo.profile</id>
            <name>foo.profile</name>
            <url>http://foo.bar.profile</url>
            <properties>
                <foo>property-1</foo>
                <bar>property-2</bar>
            </properties>
        </profile>
    </profiles>
  
    <servers>
        <server>
            <id>foo</id>
            <username>fu</username>
            <password>bar</password>
            <privateKey>${user.home}/.ssh/id_dsa</privateKey>
            <passphrase>some_passphrase</passphrase>
            <filePermissions>664</filePermissions>
            <directoryPermissions>775</directoryPermissions>
            <configuration>
                <httpConfiguration>
                    <all>
                        <usePreemptive>true</usePreemptive>
                    </all>
                </httpConfiguration>
            </configuration>
        </server>
    </servers>
  
    <mirrors>
        <mirror>
            <id>nexus</id>
            <mirrorOf>!my-org-snapshots,*</mirrorOf>
            <url>http://redacted/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
  
    <pluginGroups>
        <pluginGroup>some.plugin.group.id</pluginGroup>
        <pluginGroup>some.other.plugin.group.id</pluginGroup>
    </pluginGroups>

    <proxies>
        <proxy>
            <id>foo-proxy</id>
            <active>true</active>
            <protocol>http</protocol>
            <host>https://proxy.example.com</host>
            <port>443</port>
            <username>foo</username>
            <password>bar</password>
            <nonProxyHosts>noproxy1.example.com|noproxy2.example.com</nonProxyHosts>
        </proxy>
    </proxies>
  
</settings>

Local Setup

See 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

brew install act

Run Step

act -s GITHUB_TOKEN={token} -j {step}

Example: act -s GITHUB_TOKEN=lk34j56lk34j5lk34j5dkllsldf -j test-basic




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap