├── .asf.yaml
├── .git-blame-ignore-revs
├── .github
├── ISSUE_TEMPLATE
│ ├── BUG.yml
│ ├── FEATURE.yml
│ └── config.yml
├── dependabot.yml
├── pull_request_template.md
├── release-drafter-3.x.yml
├── release-drafter.yml
└── workflows
│ ├── maven-verify.yml
│ ├── pr-automation.yml
│ ├── release-drafter.yml
│ └── stale.yml
├── .gitignore
├── Jenkinsfile
├── LICENSE
├── NOTICE
├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── org
│ └── apache
│ └── maven
│ └── shared
│ └── archiver
│ ├── ManifestConfiguration.java
│ ├── ManifestSection.java
│ ├── MavenArchiveConfiguration.java
│ ├── MavenArchiver.java
│ ├── MavenArchiverException.java
│ └── PomPropertiesUtil.java
├── site
├── apt
│ └── examples
│ │ ├── classpath.apt
│ │ ├── manifest.apt
│ │ ├── manifestEntries.apt
│ │ ├── manifestFile.apt
│ │ └── manifestSections.apt
├── resources
│ └── download.cgi
├── site.xml
└── xdoc
│ ├── download.xml.vm
│ └── index.xml.vm
└── test
├── java
└── org
│ └── apache
│ └── maven
│ └── shared
│ └── archiver
│ ├── ManifestConfigurationTest.java
│ ├── MavenArchiveConfigurationTest.java
│ ├── MavenArchiverTest.java
│ └── PomPropertiesUtilTest.java
└── resources
├── custom-pom.properties
├── dummy.dot-1.5.jar
├── dummy1-1.0.jar
├── dummy1-1.1-20081022.112233-1.jar
├── dummy2-1.5.jar
├── dummy3-2.0.jar
└── pom.xml
/.asf.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | # see https://s.apache.org/asfyaml
18 | github:
19 | description: "Apache Maven Archiver"
20 | homepage: https://maven.apache.org/shared/maven-archiver/
21 | labels:
22 | - java
23 | - build-management
24 | - maven-shared
25 | - maven
26 | enabled_merge_buttons:
27 | squash: true
28 | merge: false
29 | rebase: true
30 | autolink_jira:
31 | - MSHARED
32 | del_branch_on_merge: true
33 | features:
34 | issues: true
35 | notifications:
36 | commits: commits@maven.apache.org
37 | issues: issues@maven.apache.org
38 | pullrequests: issues@maven.apache.org
39 | jira_options: link label comment
40 |
--------------------------------------------------------------------------------
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one
3 | # or more contributor license agreements. See the NOTICE file
4 | # distributed with this work for additional information
5 | # regarding copyright ownership. The ASF licenses this file
6 | # to you under the Apache License, Version 2.0 (the
7 | # "License"); you may not use this file except in compliance
8 | # with the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing,
13 | # software distributed under the License is distributed on an
14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | # KIND, either express or implied. See the License for the
16 | # specific language governing permissions and limitations
17 | # under the License.
18 | #
19 |
20 | # Change maven code style
21 | 670da42432fbfd2d28b29458095716a117d27b7c
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/BUG.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
19 |
20 | name: Bug Report
21 | description: File a bug report
22 | labels: ["bug"]
23 |
24 | body:
25 | - type: markdown
26 | attributes:
27 | value: |
28 | Thanks for taking the time to fill out this bug report.
29 |
30 | Simple fixes in single PRs do not require issues.
31 |
32 | **Do you use the latest project version?**
33 |
34 | - type: input
35 | id: version
36 | attributes:
37 | label: Affected version
38 | validations:
39 | required: true
40 |
41 | - type: textarea
42 | id: message
43 | attributes:
44 | label: Bug description
45 | validations:
46 | required: true
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/FEATURE.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema
19 |
20 | name: Feature request
21 | description: File a proposal for new feature, improvement
22 | labels: ["enhancement"]
23 |
24 | body:
25 | - type: markdown
26 | attributes:
27 | value: |
28 | Thanks for taking the time to fill out this new feature, improvement proposal.
29 |
30 | - type: textarea
31 | id: message
32 | attributes:
33 | label: New feature, improvement proposal
34 | validations:
35 | required: true
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Licensed to the Apache Software Foundation (ASF) under one or more
3 | # contributor license agreements. See the NOTICE file distributed with
4 | # this work for additional information regarding copyright ownership.
5 | # The ASF licenses this file to You under the Apache License, Version 2.0
6 | # (the "License"); you may not use this file except in compliance with
7 | # the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
19 |
20 | blank_issues_enabled: false
21 |
22 | contact_links:
23 |
24 | - name: Project Mailing Lists
25 | url: https://maven.apache.org/mailing-lists.html
26 | about: Please ask a question or discuss here
27 |
28 | - name: Old JIRA Issues
29 | url: https://issues.apache.org/jira/issues/?jql=project%3DMSHARED+AND+component%3Dmaven-archiver
30 | about: Please search old JIRA issues
31 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | version: 2
19 | updates:
20 | - package-ecosystem: "maven"
21 | directory: "/"
22 | schedule:
23 | interval: "daily"
24 | ignore:
25 | # Ignore Maven Core updates
26 | - dependency-name: "org.apache.maven:*"
27 | - package-ecosystem: "github-actions"
28 | directory: "/"
29 | schedule:
30 | interval: "daily"
31 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Following this checklist to help us incorporate your
2 | contribution quickly and easily:
3 |
4 | - [ ] Your pull request should address just one issue, without pulling in other changes.
5 | - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
6 | - [ ] Each commit in the pull request should have a meaningful subject line and body.
7 | Note that commits might be squashed by a maintainer on merge.
8 | - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
9 | This may not always be possible but is a best-practice.
10 | - [ ] Run `mvn verify` to make sure basic checks pass.
11 | A more thorough check will be performed on your pull request automatically.
12 | - [ ] You have run the integration tests successfully (`mvn -Prun-its verify`).
13 |
14 | If your pull request is about ~20 lines of code you don't need to sign an
15 | [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
16 | please ask on the developers list.
17 |
18 | To make clear that you license your contribution under
19 | the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
20 | you have to acknowledge this by using the following check-box.
21 |
22 | - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
23 | - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
24 |
--------------------------------------------------------------------------------
/.github/release-drafter-3.x.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | _extends: maven-gh-actions-shared:.github/release-drafter.yml
19 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | _extends: maven-gh-actions-shared
19 |
20 | include-pre-releases: true
21 | prerelease: true
22 |
--------------------------------------------------------------------------------
/.github/workflows/maven-verify.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: Verify
19 |
20 | on:
21 | push:
22 | pull_request:
23 |
24 | jobs:
25 | build:
26 | name: Verify
27 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
28 | with:
29 | ff-maven: "4.0.0-rc-1" # Maven version for fail-fast-build
30 | maven-matrix: '[ "4.0.0-rc-1" ]'
31 | jdk-matrix: '[ "17", "21" ]'
32 | ff-goal: verify
33 | verify-goal: verify
34 |
--------------------------------------------------------------------------------
/.github/workflows/pr-automation.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: PR Automation
19 | on:
20 | pull_request_target:
21 | types:
22 | - closed
23 |
24 | jobs:
25 | pr-automation:
26 | name: PR Automation
27 | uses: apache/maven-gh-actions-shared/.github/workflows/pr-automation.yml@v4
28 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: Release Drafter
19 | on:
20 | push:
21 | branches:
22 | - master
23 | workflow_dispatch:
24 |
25 | jobs:
26 | update_release_draft:
27 | uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4
28 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: Stale
19 |
20 | on:
21 | schedule:
22 | - cron: '19 3 * * *'
23 | issue_comment:
24 | types: [ 'created' ]
25 |
26 | jobs:
27 | stale:
28 | uses: 'apache/maven-gh-actions-shared/.github/workflows/stale.yml@v4'
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .project
3 | .classpath
4 | .settings/
5 | .svn/
6 | bin/
7 | # Intellij
8 | *.ipr
9 | *.iml
10 | .idea
11 | out/
12 | .DS_Store
13 | /bootstrap
14 | /dependencies.xml
15 | .java-version
16 | .checkstyle
17 | .apt_generated/
18 | .apt_generated_tests/
19 | .factorypath
20 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | asfMavenTlpStdBuild(jdks:[ "17", "21" ])
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Apache Maven Archiver
2 | Copyright 2007-2024 The Apache Software Foundation
3 |
4 | This product includes software developed at
5 | The Apache Software Foundation (http://www.apache.org/).
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
17 | Contributing to [Apache Maven Archiver](https://maven.apache.org/shared/maven-archiver/)
18 | ======================
19 |
20 | [][license]
21 | [](https://search.maven.org/artifact/org.apache.maven/maven-archiver)
22 | [](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/shared/archiver/README.md)
23 | [][build]
24 | [][test-results]
25 |
26 |
27 | You have found a bug, or you have an idea for a cool new feature? Contributing
28 | code is a great way to give something back to the open source community. Before
29 | you dig right into the code, there are a few guidelines that we need
30 | contributors to follow so that we can have a chance of keeping on top of
31 | things.
32 |
33 | Getting Started
34 | ---------------
35 |
36 | + Make sure you have a [GitHub account](https://github.com/signup/free).
37 | + If you're planning to implement a new feature, it makes sense to discuss your changes
38 | on the [dev list][ml-list] first.
39 | This way you can make sure you're not wasting your time on something that isn't
40 | considered to be in Apache Maven's scope.
41 | + Submit a ticket for your issue, assuming one does not already exist.
42 | + Clearly describe the issue, including steps to reproduce when it is a bug.
43 | + Make sure you fill in the earliest version that you know has the issue.
44 | + Fork the repository on GitHub.
45 |
46 | Making and Submitting Changes
47 | --------------
48 |
49 | We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the
50 | main channel of communication for contributors.
51 | There are some guidelines which will make applying PRs easier for us:
52 | + Create a topic branch from where you want to base your work (this is usually the master branch).
53 | Push your changes to a topic branch in your fork of the repository.
54 | + Make commits of logical units.
55 | + Respect the original code style: by using the same [codestyle][code-style],
56 | patches should only highlight the actual difference, not being disturbed by any formatting issues:
57 | + Only use spaces for indentation.
58 | + Create minimal diffs - disable on save actions like reformat source code or organize imports.
59 | If you feel the source code should be reformatted, create a separate PR for this change.
60 | + Check for unnecessary whitespace with `git diff --check` before committing.
61 | + Make sure you have added the necessary tests (JUnit/IT) for your changes.
62 | + Run all the tests with `mvn -Prun-its verify` to assure nothing else was accidentally broken.
63 | + Submit a pull request to the repository in the Apache organization.
64 |
65 | If you plan to contribute on a regular basis, please consider filing a [contributor license agreement][cla].
66 |
67 | Additional Resources
68 | --------------------
69 |
70 | + [Contributing patches](https://maven.apache.org/guides/development/guide-maven-development.html#Creating_and_submitting_a_patch)
71 | + [Contributor License Agreement][cla]
72 | + [General GitHub documentation](https://help.github.com/)
73 | + [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
74 | + [Apache Maven X Account](https://x.com/ASFMavenProject)
75 | + [Apache Maven Bluesky Account](https://bsky.app/profile/maven.apache.org)
76 | + [Apache Maven Mastodon Account](https://mastodon.social/deck/@ASFMavenProject@fosstodon.org)
77 |
78 | [license]: https://www.apache.org/licenses/LICENSE-2.0
79 | [ml-list]: https://maven.apache.org/mailing-lists.html
80 | [code-style]: https://maven.apache.org/developers/conventions/code.html
81 | [cla]: https://www.apache.org/licenses/#clas
82 | [maven-wiki]: https://cwiki.apache.org/confluence/display/MAVEN/Index
83 | [test-results]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-archiver/job/master/lastCompletedBuild/testReport/
84 | [build]: https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-archiver/job/master/
85 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
Getter for the field mainClass
.
Getter for the field packageName
.
isAddClasspath.
108 | * 109 | * @return if addClasspath true or false. 110 | */ 111 | public boolean isAddClasspath() { 112 | return addClasspath; 113 | } 114 | 115 | /** 116 | *isAddDefaultEntries.
117 | * 118 | * @return {@link #addDefaultEntries} 119 | */ 120 | public boolean isAddDefaultEntries() { 121 | return addDefaultEntries; 122 | } 123 | 124 | /** 125 | *isAddBuildEnvironmentEntries.
126 | * 127 | * @return {@link #addBuildEnvironmentEntries} 128 | */ 129 | public boolean isAddBuildEnvironmentEntries() { 130 | return addBuildEnvironmentEntries; 131 | } 132 | 133 | /** 134 | *isAddDefaultImplementationEntries.
135 | * 136 | * @return {@link #addDefaultImplementationEntries} 137 | */ 138 | public boolean isAddDefaultImplementationEntries() { 139 | return addDefaultImplementationEntries; 140 | } 141 | 142 | /** 143 | *isAddDefaultSpecificationEntries.
144 | * 145 | * @return {@link #addDefaultSpecificationEntries} 146 | */ 147 | public boolean isAddDefaultSpecificationEntries() { 148 | return addDefaultSpecificationEntries; 149 | } 150 | 151 | /** 152 | *isAddExtensions.
153 | * 154 | * @return {@link #addExtensions} 155 | */ 156 | public boolean isAddExtensions() { 157 | return addExtensions; 158 | } 159 | 160 | /** 161 | *Setter for the field addClasspath
.
Setter for the field addDefaultEntries
.
Setter for the field addBuildEnvironmentEntries
.
Setter for the field addDefaultImplementationEntries
.
Setter for the field addDefaultSpecificationEntries
.
Setter for the field addExtensions
.
Setter for the field classpathPrefix
.
Setter for the field mainClass
.
Setter for the field packageName
.
Getter for the field classpathPrefix
.
addManifestEntry.
35 | * 36 | * @param key The key of the manifest entry. 37 | * @param value The appropriate value. 38 | */ 39 | public void addManifestEntry(String key, String value) { 40 | manifestEntries.put(key, value); 41 | } 42 | 43 | /** 44 | *Getter for the field manifestEntries
.
Getter for the field name
.
Setter for the field name
.
addManifestEntries.
72 | * 73 | * @param map The map to add. 74 | */ 75 | public void addManifestEntries(MapisManifestEntriesEmpty.
81 | * 82 | * @return true if empty false otherwise. 83 | */ 84 | public boolean isManifestEntriesEmpty() { 85 | return manifestEntries.isEmpty(); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/archiver/MavenArchiveConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.archiver; 20 | 21 | import java.nio.file.Path; 22 | import java.util.LinkedHashMap; 23 | import java.util.LinkedList; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | /** 28 | * Capture common archive configuration. 29 | * 30 | * @author Brett Porter 31 | */ 32 | // TODO Is this general enough to be in Plexus Archiver? 33 | public class MavenArchiveConfiguration { 34 | private boolean compress = true; 35 | 36 | private boolean recompressAddedZips = true; 37 | 38 | private boolean addMavenDescriptor = true; 39 | 40 | private Path manifestFile; 41 | 42 | // TODO: Rename this attribute to manifestConfiguration; 43 | private ManifestConfiguration manifest; 44 | 45 | private MapisCompress.
61 | * 62 | * @return {@link #compress} 63 | */ 64 | public boolean isCompress() { 65 | return compress; 66 | } 67 | 68 | /** 69 | *isRecompressAddedZips.
70 | * 71 | * @return {@link #recompressAddedZips} 72 | */ 73 | public boolean isRecompressAddedZips() { 74 | return recompressAddedZips; 75 | } 76 | 77 | /** 78 | *Setter for the field recompressAddedZips
.
isAddMavenDescriptor.
88 | * 89 | * @return {@link #addMavenDescriptor} 90 | */ 91 | public boolean isAddMavenDescriptor() { 92 | return addMavenDescriptor; 93 | } 94 | 95 | /** 96 | *Getter for the field manifestFile
.
Getter for the field manifest
.
Setter for the field compress
.
Setter for the field addMavenDescriptor
.
Setter for the field manifestFile
.
Setter for the field manifest
.
addManifestEntry.
155 | * 156 | * @param key The key of the entry. 157 | * @param value The value of the entry. 158 | */ 159 | public void addManifestEntry(String key, String value) { 160 | manifestEntries.put(key, value); 161 | } 162 | 163 | /** 164 | *addManifestEntries.
165 | * 166 | * @param map The whole map which should be added. 167 | */ 168 | public void addManifestEntries(MapisManifestEntriesEmpty.
174 | * 175 | * @return are there entries true yes false otherwise. 176 | */ 177 | public boolean isManifestEntriesEmpty() { 178 | return manifestEntries.isEmpty(); 179 | } 180 | 181 | /** 182 | *Getter for the field manifestEntries
.
Setter for the field manifestEntries
.
addManifestSection.
201 | * 202 | * @param section {@link ManifestSection} 203 | */ 204 | public void addManifestSection(ManifestSection section) { 205 | manifestSections.add(section); 206 | } 207 | 208 | /** 209 | *addManifestSections.
210 | * 211 | * @param list Added list of {@link ManifestSection}. 212 | */ 213 | public void addManifestSections(ListisManifestSectionsEmpty.
219 | * 220 | * @return if manifestSections is empty or not. 221 | */ 222 | public boolean isManifestSectionsEmpty() { 223 | return manifestSections.isEmpty(); 224 | } 225 | 226 | /** 227 | *Getter for the field manifestSections
.
Setter for the field manifestSections
.
246 | * Returns, whether recreating the archive is forced (default). Setting this option to false means, that the 247 | * archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the 248 | * archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically 249 | * offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't 250 | * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files 251 | * won't be detected. 252 | *
253 | *254 | * An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be 255 | * ignored. 256 | *
257 | * 258 | * @return True, if the target archive should always be created; false otherwise 259 | * @see #setForced(boolean) 260 | */ 261 | public boolean isForced() { 262 | return forced; 263 | } 264 | 265 | /** 266 | *267 | * Sets, whether recreating the archive is forced (default). Setting this option to false means, that the archiver 268 | * should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive 269 | * only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a 270 | * performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't 271 | * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files 272 | * won't be detected. 273 | *
274 | *275 | * An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be 276 | * ignored. 277 | *
278 | * 279 | * @param forced True, if the target archive should always be created; false otherwise 280 | * @see #isForced() 281 | */ 282 | public void setForced(boolean forced) { 283 | this.forced = forced; 284 | } 285 | 286 | /** 287 | * Returns the location of the "pom.properties" file. May be null, in which case a default value is choosen. 288 | * 289 | * @return "pom.properties" location or null. 290 | */ 291 | public Path getPomPropertiesFile() { 292 | return pomPropertiesFile; 293 | } 294 | 295 | /** 296 | * Sets the location of the "pom.properties" file. May be null, in which case a default value is choosen. 297 | * 298 | * @param pomPropertiesFile "pom.properties" location or null. 299 | */ 300 | public void setPomPropertiesFile(Path pomPropertiesFile) { 301 | this.pomPropertiesFile = pomPropertiesFile; 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.archiver; 20 | 21 | import javax.lang.model.SourceVersion; 22 | 23 | import java.io.File; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.nio.file.Files; 27 | import java.nio.file.Path; 28 | import java.nio.file.Paths; 29 | import java.nio.file.attribute.FileTime; 30 | import java.time.Instant; 31 | import java.time.OffsetDateTime; 32 | import java.time.ZoneOffset; 33 | import java.time.format.DateTimeParseException; 34 | import java.time.temporal.ChronoUnit; 35 | import java.util.ArrayList; 36 | import java.util.Collections; 37 | import java.util.List; 38 | import java.util.Map; 39 | import java.util.Optional; 40 | import java.util.Properties; 41 | import java.util.jar.Attributes; 42 | import java.util.regex.Matcher; 43 | import java.util.regex.Pattern; 44 | 45 | import org.apache.maven.api.Dependency; 46 | import org.apache.maven.api.PathScope; 47 | import org.apache.maven.api.Project; 48 | import org.apache.maven.api.Session; 49 | import org.apache.maven.api.services.DependencyResolver; 50 | import org.apache.maven.api.services.DependencyResolverResult; 51 | import org.codehaus.plexus.archiver.jar.JarArchiver; 52 | import org.codehaus.plexus.archiver.jar.Manifest; 53 | import org.codehaus.plexus.archiver.jar.ManifestException; 54 | import org.codehaus.plexus.interpolation.InterpolationException; 55 | import org.codehaus.plexus.interpolation.Interpolator; 56 | import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; 57 | import org.codehaus.plexus.interpolation.PrefixedObjectValueSource; 58 | import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource; 59 | import org.codehaus.plexus.interpolation.RecursionInterceptor; 60 | import org.codehaus.plexus.interpolation.StringSearchInterpolator; 61 | import org.codehaus.plexus.interpolation.ValueSource; 62 | 63 | import static org.apache.maven.shared.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM; 64 | import static org.apache.maven.shared.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_REPOSITORY; 65 | import static org.apache.maven.shared.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_SIMPLE; 66 | 67 | /** 68 | * MavenArchiver class. 69 | */ 70 | public class MavenArchiver { 71 | 72 | private static final String CREATED_BY = "Maven Archiver"; 73 | 74 | /** 75 | * The simple layout. 76 | */ 77 | public static final String SIMPLE_LAYOUT = 78 | "${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}"; 79 | 80 | /** 81 | * Repository layout. 82 | */ 83 | public static final String REPOSITORY_LAYOUT = 84 | "${artifact.groupIdPath}/${artifact.artifactId}/" + "${artifact.baseVersion}/${artifact.artifactId}-" 85 | + "${artifact.version}${dashClassifier?}.${artifact.extension}"; 86 | 87 | /** 88 | * simple layout non unique. 89 | */ 90 | public static final String SIMPLE_LAYOUT_NONUNIQUE = 91 | "${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}"; 92 | 93 | /** 94 | * Repository layout non unique. 95 | */ 96 | public static final String REPOSITORY_LAYOUT_NONUNIQUE = 97 | "${artifact.groupIdPath}/${artifact.artifactId}/" + "${artifact.baseVersion}/${artifact.artifactId}-" 98 | + "${artifact.baseVersion}${dashClassifier?}.${artifact.extension}"; 99 | 100 | private static final Instant DATE_MIN = Instant.parse("1980-01-01T00:00:02Z"); 101 | 102 | private static final Instant DATE_MAX = Instant.parse("2099-12-31T23:59:59Z"); 103 | 104 | private static final ListgetManifest.
127 | * 128 | * @param session the Maven Session 129 | * @param project the Maven Project 130 | * @param config the MavenArchiveConfiguration 131 | * @return the {@link org.codehaus.plexus.archiver.jar.Manifest} 132 | * @throws MavenArchiverException in case of a failure 133 | */ 134 | public Manifest getManifest(Session session, Project project, MavenArchiveConfiguration config) 135 | throws MavenArchiverException { 136 | boolean hasManifestEntries = !config.isManifestEntriesEmpty(); 137 | MapgetManifest.
227 | * 228 | * @param session {@link org.apache.maven.api.Session} 229 | * @param project {@link org.apache.maven.api.Project} 230 | * @param config {@link ManifestConfiguration} 231 | * @param entries The entries. 232 | * @return {@link org.codehaus.plexus.archiver.jar.Manifest} 233 | * @throws MavenArchiverException exception 234 | */ 235 | protected Manifest getManifest( 236 | Session session, Project project, ManifestConfiguration config, MapGetter for the field archiver
.
Setter for the field archiver
.
setOutputFile.
478 | * 479 | * @param outputFile Set output file. 480 | */ 481 | public void setOutputFile(File outputFile) { 482 | archiveFile = outputFile; 483 | } 484 | 485 | /** 486 | *createArchive.
487 | * 488 | * @param session {@link org.apache.maven.api.Session} 489 | * @param project {@link org.apache.maven.api.Project} 490 | * @param archiveConfiguration {@link MavenArchiveConfiguration} 491 | * @throws MavenArchiverException Archiver Exception. 492 | */ 493 | public void createArchive(Session session, Project project, MavenArchiveConfiguration archiveConfiguration) 494 | throws MavenArchiverException { 495 | try { 496 | doCreateArchive(session, project, archiveConfiguration); 497 | } catch (ManifestException | IOException e) { 498 | throw new MavenArchiverException(e); 499 | } 500 | } 501 | 502 | public void doCreateArchive(Session session, Project project, MavenArchiveConfiguration archiveConfiguration) 503 | throws ManifestException, IOException { 504 | // we have to clone the project instance so we can write out the pom with the deployment version, 505 | // without impacting the main project instance... 506 | boolean forced = archiveConfiguration.isForced(); 507 | if (archiveConfiguration.isAddMavenDescriptor()) { 508 | // ---------------------------------------------------------------------- 509 | // We want to add the metadata for the project to the JAR in two forms: 510 | // 511 | // The first form is that of the POM itself. Applications that wish to 512 | // access the POM for an artifact using maven tools they can. 513 | // 514 | // The second form is that of a properties file containing the basic 515 | // top-level POM elements so that applications that wish to access 516 | // POM information without the use of maven tools can do so. 517 | // ---------------------------------------------------------------------- 518 | 519 | String groupId = project.getGroupId(); 520 | 521 | String artifactId = project.getArtifactId(); 522 | 523 | String version; 524 | if (project.getPomArtifact().isSnapshot()) { 525 | version = project.getPomArtifact().getVersion().toString(); 526 | } else { 527 | version = project.getVersion(); 528 | } 529 | 530 | archiver.addFile( 531 | project.getPomPath().toFile(), "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml"); 532 | 533 | // ---------------------------------------------------------------------- 534 | // Create pom.properties file 535 | // ---------------------------------------------------------------------- 536 | 537 | Path customPomPropertiesFile = archiveConfiguration.getPomPropertiesFile(); 538 | Path dir = Paths.get(project.getBuild().getDirectory(), "maven-archiver"); 539 | Path pomPropertiesFile = dir.resolve("pom.properties"); 540 | 541 | new PomPropertiesUtil() 542 | .createPomProperties( 543 | groupId, artifactId, version, archiver, customPomPropertiesFile, pomPropertiesFile); 544 | } 545 | 546 | // ---------------------------------------------------------------------- 547 | // Create the manifest 548 | // ---------------------------------------------------------------------- 549 | 550 | archiver.setMinimalDefaultManifest(true); 551 | Path manifestFile = archiveConfiguration.getManifestFile(); 552 | if (manifestFile != null) { 553 | archiver.setManifest(manifestFile.toFile()); 554 | } 555 | Manifest manifest = getManifest(session, project, archiveConfiguration); 556 | // Configure the jar 557 | archiver.addConfiguredManifest(manifest); 558 | archiver.setCompress(archiveConfiguration.isCompress()); 559 | archiver.setRecompressAddedZips(archiveConfiguration.isRecompressAddedZips()); 560 | archiver.setDestFile(archiveFile); 561 | archiver.setForced(forced); 562 | if (!archiveConfiguration.isForced() && archiver.isSupportingForced()) { 563 | // TODO Should issue a warning here, but how do we get a logger? 564 | // TODO getLog().warn( 565 | // "Forced build is disabled, but disabling the forced mode isn't supported by the archiver." ); 566 | } 567 | String automaticModuleName = manifest.getMainSection().getAttributeValue("Automatic-Module-Name"); 568 | if (automaticModuleName != null) { 569 | if (!isValidModuleName(automaticModuleName)) { 570 | throw new ManifestException("Invalid automatic module name: '" + automaticModuleName + "'"); 571 | } 572 | } 573 | 574 | // create archive 575 | archiver.createArchive(); 576 | } 577 | 578 | private void handleDefaultEntries(Manifest m, MapEither as {@link java.time.format.DateTimeFormatter#ISO_OFFSET_DATE_TIME} or as a number representing seconds
668 | * since the epoch (like SOURCE_DATE_EPOCH).
669 | *
670 | * @param outputTimestamp the value of {@code ${project.build.outputTimestamp}} (may be {@code null})
671 | * @return the parsed timestamp as an {@code Optional ${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository. ${project.name} is distributed under the Apache License, version 2.0. This is the current stable version of ${project.name}. It is essential that you verify the integrity of the downloaded file
62 | using the checksum (.sha512 file)
63 | or using the signature (.asc file) against the public KEYS used by the Apache Maven developers.
64 | It is strongly recommended to use the latest release version of ${project.name} to take advantage of the newest features and bug fixes. Older non-recommended releases can be found on our archive site.
29 | The Maven Archiver is mainly used by plugins to handle packaging. The
30 | version numbers referenced in the Since column on this page are the
31 | version of the Maven Archiver component - not for any specific plugin.
32 | To see which version of Maven Archiver a plugin uses, go to the site
33 | for that plugin.
34 |
123 | An archiver doesn't necessarily support checks for uptodate. If
124 | so, setting this option to
136 | Whether the created archive will contain an
137 |
140 | The default value is
186 | The auto created pom.properties
file
37 | * in META-INF/maven/${groupId}/${artifactId}
.
38 | *
39 | * @author slachiewicz
40 | * @version $Id: $Id
41 | */
42 | public class PomPropertiesUtil {
43 | private Properties loadPropertiesFile(Path file) throws IOException {
44 | Properties fileProps = new Properties();
45 | try (InputStream istream = Files.newInputStream(file)) {
46 | fileProps.load(istream);
47 | return fileProps;
48 | }
49 | }
50 |
51 | private void createPropertiesFile(Properties properties, Path outputFile) throws IOException {
52 | Path outputDir = outputFile.getParent();
53 | if (outputDir != null) {
54 | Files.createDirectories(outputDir);
55 | }
56 | // For reproducible builds, sort the properties and drop comments.
57 | // The java.util.Properties class doesn't guarantee order so we have
58 | // to write the file using a Writer.
59 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
60 | properties.store(baos, null);
61 | // The encoding can be either UTF-8 or ISO-8859-1, as any non ascii character
62 | // is transformed into a \\uxxxx sequence anyway
63 | String output = baos.toString(StandardCharsets.ISO_8859_1)
64 | .lines()
65 | .filter(line -> !line.startsWith("#"))
66 | .sorted()
67 | .collect(Collectors.joining("\n", "", "\n")); // system independent new line
68 | try (Writer writer = new CachingWriter(outputFile, StandardCharsets.ISO_8859_1)) {
69 | writer.write(output);
70 | }
71 | }
72 |
73 | /**
74 | * Creates the pom.properties file.
75 | *
76 | * @param project {@link org.apache.maven.api.Project}
77 | * @param archiver {@link org.codehaus.plexus.archiver.Archiver}
78 | * @param customPomPropertiesFile optional custom pom properties file
79 | * @param pomPropertiesFile The pom properties file.
80 | * @throws org.codehaus.plexus.archiver.ArchiverException archiver exception.
81 | * @throws java.io.IOException IO exception.
82 | */
83 | public void createPomProperties(
84 | Project project, Archiver archiver, Path customPomPropertiesFile, Path pomPropertiesFile)
85 | throws IOException {
86 | final String groupId = project.getGroupId();
87 | final String artifactId = project.getArtifactId();
88 | final String version = project.getVersion();
89 | createPomProperties(groupId, artifactId, version, archiver, customPomPropertiesFile, pomPropertiesFile);
90 | }
91 |
92 | public void createPomProperties(
93 | String groupId,
94 | String artifactId,
95 | String version,
96 | Archiver archiver,
97 | Path customPomPropertiesFile,
98 | Path pomPropertiesFile)
99 | throws IOException {
100 | Properties p;
101 |
102 | if (customPomPropertiesFile != null) {
103 | p = loadPropertiesFile(customPomPropertiesFile);
104 | } else {
105 | p = new Properties();
106 | }
107 |
108 | p.setProperty("groupId", groupId);
109 |
110 | p.setProperty("artifactId", artifactId);
111 |
112 | p.setProperty("version", version);
113 |
114 | createPropertiesFile(p, pomPropertiesFile);
115 |
116 | archiver.addFile(
117 | pomPropertiesFile.toFile(), "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties");
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/site/apt/examples/classpath.apt:
--------------------------------------------------------------------------------
1 | ------
2 | Set Up The Classpath
3 | ------
4 | Dennis Lundberg
5 | ------
6 | 2008-01-01
7 | ------
8 |
9 | ~~ Licensed to the Apache Software Foundation (ASF) under one
10 | ~~ or more contributor license agreements. See the NOTICE file
11 | ~~ distributed with this work for additional information
12 | ~~ regarding copyright ownership. The ASF licenses this file
13 | ~~ to you under the Apache License, Version 2.0 (the
14 | ~~ "License"); you may not use this file except in compliance
15 | ~~ with the License. You may obtain a copy of the License at
16 | ~~
17 | ~~ http://www.apache.org/licenses/LICENSE-2.0
18 | ~~
19 | ~~ Unless required by applicable law or agreed to in writing,
20 | ~~ software distributed under the License is distributed on an
21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 | ~~ KIND, either express or implied. See the License for the
23 | ~~ specific language governing permissions and limitations
24 | ~~ under the License.
25 |
26 | Set Up The Classpath
27 |
28 | * {Contents}
29 |
30 | * {{{Add}Add A Class-Path Entry To The Manifest}}
31 |
32 | * {{{Make}Make The Jar Executable}}
33 |
34 | * {{{Prefix}Altering The Classpath: Defining a Classpath Directory Prefix}}
35 |
36 | * {{{Repository}Altering The Classpath: Using a Maven Repository-Style Classpath}}
37 |
38 | * {{{Custom}Altering The Classpath: Using a Custom Classpath Format}}
39 |
40 | * {{{Snapshot}Handling Snapshot Versions}}
41 |
42 | []
43 |
44 | * {Add} A Class-Path Entry To The Manifest
45 |
46 | \[{{{Contents}Top}}\]
47 |
48 | Maven Archiver can add the classpath of your project to the manifest. This is
49 | done with the <<<\
43 |
44 |
60 |
61 |
45 |
50 |
51 |
52 |
46 | Link
47 | Checksum
48 | Signature
49 |
53 |
58 |
59 | ${project.name} ${project.version} (Source zip)
54 | ${project.artifactId}-${project.version}-source-release.zip
55 | ${project.artifactId}-${project.version}-source-release.zip.sha512
56 | ${project.artifactId}-${project.version}-source-release.zip.asc
57 |
76 |
181 |
77 |
82 | Element
78 | Description
79 | Type
80 | Since
81 |
83 |
101 | addMavenDescriptor
84 |
85 | Whether the created archive will contain these two Maven files:
86 |
98 |
87 |
96 | The default value is META-INF/maven/${groupId}/${artifactId}/pom.xml
90 | META-INF/maven/${groupId}/${artifactId}/pom.properties
94 | true
.
97 | boolean
99 |
100 |
102 |
110 | compress
103 |
104 | Activate compression for the archive.
105 | The default value is
107 | true
.
106 | boolean
108 |
109 |
111 |
131 | forced
112 |
113 | Whether recreating the archive is forced (default) or not. Setting
114 | this option to
128 | false
, means that the archiver should compare the
115 | timestamps of included files with the timestamp of the target archive
116 | and rebuild the archive, only if the latter timestamp precedes the
117 | former timestamps. Checking for timestamps will typically offer a
118 | performance gain (in particular, if the following steps in a build
119 | can be suppressed, if an archive isn't recreated) on the cost that
120 | you get inaccurate results from time to time. In particular, removal
121 | of source files won't be detected.
122 | true
will simply be ignored.
125 | true
.
127 | boolean
129 | 2.2
130 |
132 |
146 | index
133 |
134 | Deprecated: See JDK-8305597
135 |
143 | INDEX.LIST
file.
138 | false
.
141 | boolean
144 |
145 |
147 |
156 | pomPropertiesFile
148 |
149 | Use this to override the auto created
150 | pom.properties file
151 | (only if
153 | addMavenDescriptor
is set to true
)
152 | File
154 | 2.3
155 |
157 |
162 | manifestFile
158 | With this you can supply your own manifest file.
159 | File
160 |
161 |
163 |
168 | manifest
164 |
165 |
166 |
167 |
169 |
174 | manifestEntries
170 | A list of key/value pairs to add to the manifest.
171 | Map
172 |
173 |
175 |
180 | manifestSections
176 |
177 |
178 |
179 | pom.properties
file will contain the
187 | following content:
188 |
198 |
340 |
199 |
204 | Element
200 | Description
201 | Type
202 | Since
203 |
205 |
213 | addClasspath
206 |
207 | Whether to create a
210 | Class-Path
manifest entry.
208 | The default value is false
.
209 | boolean
211 |
212 |
214 |
227 | addDefaultEntries
215 |
216 | If the manifest will contain these entries:
217 |
224 | Created-By
entry can be overridden using
221 | MavenArchiver.setCreatedBy(...) API.
222 | The default value is true
.
223 | boolean
225 | 3.4.0
226 |
228 |
240 | addDefaultImplementationEntries
229 |
230 | If the manifest will contain these entries:
231 |
237 | false
.
236 | boolean
238 | 2.1 and 2.6
239 |
241 |
253 | addDefaultSpecificationEntries
242 |
243 | If the manifest will contain these entries:
244 |
250 | false
.
249 | boolean
251 | 2.1
252 |
254 |
266 | addBuildEnvironmentEntries
255 |
256 | If the manifest will contain these entries:
257 |
263 | false
.
262 | boolean
264 | 3.4.0
265 |
267 |
276 | addExtensions
268 |
269 | Whether to create an
273 | Extension-List
manifest
270 | entry.
271 | The default value is false
.
272 | boolean
274 |
275 |
277 |
291 | classpathLayoutType
278 |
279 | The type of layout to use when formatting entries in the created
280 |
288 | Class-Path
. Valid values are: simple
,
281 | repository
(the same as a Maven classpath layout) and
282 | custom
.
283 |
284 | Note: If you specify a type of custom
you
285 | must also set customClasspathLayout
.
286 | The default value is simple
.
287 | String
289 | 2.4
290 |
292 |
301 | classpathPrefix
293 |
294 | A text that will be prefixed to all your
298 | Class-Path
295 | entries.
296 | The default value is ""
.
297 | String
299 |
300 |
302 |
318 | customClasspathLayout
303 |
304 | The layout expression to use when the layout type set in
305 |
315 | classpathLayoutType
has the value custom
.
306 | Expressions will be evaluated against the following ordered list
307 | of classpath-related objects:
308 |
309 |
312 | Note: If you specify a layout type of custom
313 | you must set this layout expression.
314 | String
316 | 2.4
317 |
319 |
324 | mainClass
320 | The
321 | Main-Class
manifest entry.String
322 |
323 |
325 |
330 | packageName
326 | Package manifest entry.
327 | String
328 |
329 |
331 |
339 | useUniqueVersions
332 |
333 | Whether to use unique timestamp Snapshot versions rather than -SNAPSHOT versions.
334 | The default value is
336 | true
.
335 | boolean
337 | 2.4
338 |
345 |
366 |
346 |
351 | Element
347 | Description
348 | Type
349 | Since
350 |
352 |
359 | name
353 |
354 | The name of the section.
355 |
356 | String
357 |
358 |
360 |
365 | manifestEntries
361 | A list of key/value pairs to add to the manifest.
362 | Map
363 |
364 |