├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src
├── main
├── java
│ └── de
│ │ └── oppermann
│ │ └── pomutils
│ │ ├── Main.java
│ │ ├── PomMergeDriver.java
│ │ ├── PomVersionReplacer.java
│ │ ├── commands
│ │ ├── CommandMain.java
│ │ ├── CommandPomMergeDriver.java
│ │ ├── CommandPomVersionReplacer.java
│ │ └── SelectionStrategyConverter.java
│ │ ├── rules
│ │ ├── AbstractRule.java
│ │ ├── ProjectAndParentVersionRule.java
│ │ ├── PropertyRule.java
│ │ ├── Rule.java
│ │ ├── Ruleset.java
│ │ └── ScmTagRule.java
│ │ ├── select
│ │ ├── OurVersionSelector.java
│ │ ├── PersistentVersionSelector.java
│ │ ├── SelectionStrategy.java
│ │ ├── StreamVersionSelector.java
│ │ ├── TheirVersionSelector.java
│ │ └── VersionSelector.java
│ │ └── util
│ │ ├── ManifestUtils.java
│ │ ├── POM.java
│ │ └── VersionFieldType.java
└── resources
│ └── logback.xml
└── test
├── java
└── de
│ └── oppermann
│ └── pomutils
│ ├── ConfigTest.java
│ ├── IssuesTest.java
│ ├── MainCallTest.java
│ ├── PomMergeDriverTest.java
│ ├── RulesetTest.java
│ ├── TestUtils.java
│ ├── VersionReplaceTest.java
│ └── select
│ ├── PersistentVersionSelectorTest.java
│ └── StreamVersionSelectorTest.java
└── resources
├── config
└── defaultconfig.yaml
├── mainCall
├── versionReplace
│ └── replace.pom.xml
├── withRuleset
│ ├── base.pom.xml
│ ├── our.pom.xml
│ ├── ruleset.yaml
│ └── their.pom.xml
└── withoutRuleset
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── merge
├── autoMergeFailed
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeSucceded
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeSucceded_noConflict_our
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeSucceded_noConflict_their
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeSucceded_prompt
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeSucceded_their
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── autoMergeWithNoBaseCommit
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
└── issues
│ └── #15
│ ├── base.pom.xml
│ ├── our.pom.xml
│ └── their.pom.xml
├── rulesets
├── rulesetProjectAndParentVersion
│ ├── ourStrategy
│ │ ├── base.pom.xml
│ │ ├── our.pom.xml
│ │ ├── ruleset.yaml
│ │ └── their.pom.xml
│ └── theirStrategy
│ │ ├── base.pom.xml
│ │ ├── our.pom.xml
│ │ ├── ruleset.yaml
│ │ └── their.pom.xml
├── rulesetPropertyRule
│ ├── ourStrategy
│ │ ├── base.pom.xml
│ │ ├── our.pom.xml
│ │ ├── ruleset.yaml
│ │ └── their.pom.xml
│ └── theirStrategy
│ │ ├── base.pom.xml
│ │ ├── our.pom.xml
│ │ ├── ruleset.yaml
│ │ └── their.pom.xml
└── rulesetScmTag
│ ├── ourStrategy
│ ├── base.pom.xml
│ ├── our.pom.xml
│ ├── ruleset.yaml
│ └── their.pom.xml
│ └── theirStrategy
│ ├── base.pom.xml
│ ├── our.pom.xml
│ ├── ruleset.yaml
│ └── their.pom.xml
└── versionReplacer
├── parent.and.project.version
└── pom.xml
├── parent.version
└── pom.xml
└── project.version
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .settings
3 | .classpath
4 | .project
5 | dependency-reduced-pom.xml
6 | /.idea
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | POMUtils
2 | =============
3 |
4 | This library is for making the day easier while using git and maven.
5 | If you do almost weekly or daily releases you get in trouble with merge
6 | conflicts regarding to the parent and/or project version of your pom.xml files.
7 | In a project with many child modules this is a real pain.
8 |
9 | There are some tools out there which also try to accomplish this goal,
10 | but IMO they don't do it in the right way. Some are doing a search and
11 | replace of `...` and they don't make sure that only
12 | the parent and project version has changed. Some others are using a DOM Parser,
13 | adjusting the versions via xpath and save it.
14 | That way you get a new formatted xml file. What you also don't want.
15 |
16 | Here you find a library which solves this problem, imo, in the right way ;-).
17 | It just adjusts the parent and/or project version. Nothing else.
18 | Internally it uses classes of the `versions-maven-plugin`,
19 | that why it is a java program.
20 | There is only one downside. It's slow, because git starts a new JVM for every pom file merge.
21 | For ~100 pom.xml files it takes around 20 seconds to merge them.
22 |
23 |
24 | Installation
25 | ------------
26 |
27 | Download the [jar](https://github.com/cecom/pomutils/releases/latest) file or create it with `mvn clean install` and execute it with java >1.6.
28 | It's a shaded jar, which contains all necessary dependencies.
29 |
30 | For usage, call: `java -jar pomutils-X.X.jar --help`
31 |
32 | ```
33 | java -jar target/pomutils-1.0.jar --help
34 | Usage: [options] [command] [command options]
35 | Options:
36 | --debug
37 | If you want to print debug information add this option.
38 | Default: false
39 | --help
40 | Used to print this information.
41 | Default: false
42 | Commands:
43 | merge Used as merge driver in git. Updates the version of 'our' pom or 'their' pom (based on the value of --select), and then does a normal 'git merge-file'
44 | Usage: merge [options]
45 | Options:
46 | * -b, --base
47 | Base Pom
48 | * -o, --our
49 | Our Pom
50 | * -t, --their
51 | Their Pom
52 | -s, --select
53 | Which version to select to resolve conflicts. 'our', 'their', or
54 | 'prompt'. If 'prompt' is specified, then you will be prompted via
55 | stdout/stdin to select a version.
56 | Default: our
57 | -r, --ruleset
58 | The ruleset to use when you merge poms. If you don't specify a ruleset,
59 | a default ruleset will be used. Default is ProjectAndParentVersionRule with our strategy.
60 |
61 | replace Updates the parent version and/or the project version in the given pom.xml
62 | Usage: replace [options]
63 | Options:
64 | * -p, --pom
65 | The pom where you want to replace the parent and project version
66 | * -v, --version
67 | The new version you want to set
68 |
69 | ```
70 |
71 | *merge* Command Usage
72 | ------------
73 | This command is used as pom merge driver in git. To configure it you have to do the following:
74 |
75 | 1. In your git project, edit the `.gitattributes` file (or create it if it doesn't exist) and add the following line:
76 |
77 | ```
78 | pom.xml merge=pom
79 | ```
80 |
81 | 2. In your `.git/config`, you have to define how the `pom` merge driver should be called. Add the following lines:
82 |
83 | ```
84 | [merge "pom"]
85 | name = Automatically resolve project and/or parent version conflicts in pom files. The rest is a normal merge.
86 | driver = java -jar /pomutils-X.X.jar merge --base=%O --our=%A --their=%B
87 | ```
88 |
89 | To speed up the vm start, I use the following line:
90 |
91 | ```driver = java -jar -client -Xverify:none -Xms32m -Xmx32m /pomutils-X.X.jar merge --base=%O --our=%A --their=%B```
92 |
93 | 3. Done.
94 |
95 | By default, project/parent version conflicts will be resolved using *our* version.
96 | You can change this behaviour by specifying `--select their` or `--select prompt` on the command line.
97 | Select `their` to always resolve version conflicts using *their* version.
98 | Select `prompt` to prompt the user via stdout/stdin to select a version at merge time.
99 | Note that you must be performing merges from the command line for `prompt` to work.
100 | If you use a GUI to perform merge, do not use `--select prompt`, unless the GUI provides
101 | a way to enter input on the git merge console.
102 |
103 | Internally, the merge driver will adjust the parent/project version
104 | of either *their* pom.xml file or *our* pom.xml file (depending on the value of `--select`),
105 | then run the `git merge-file` command (which is used by the default merge driver).
106 |
107 | *merge* Command *ADVANCED* Usage
108 | ------------
109 |
110 | It is also possible to write your own *Rule* for conflict resolution. Currently there are three implemented rules:
111 |
112 | - de.oppermann.pomutils.rules.ProjectAndParentVersionRule
113 | - de.oppermann.pomutils.rules.PropertyRule
114 | - de.oppermann.pomutils.rules.ScmTagRule
115 |
116 | If you don't specify `--ruleset` on command line the *de.oppermann.pomutils.rules.ProjectAndParentVersionRule*
117 | rule is used. But if you want e.g. to resolve conflicts on maven properties too, or want
118 | to evaluate your own rule, you have to create a ruleset configuration file. This file looks like (yaml format):
119 |
120 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
121 | strategy: OUR # possible values: OUR|THEIR|PROMPT
122 | # resolves all parent and project version conflicts, using the *OUR* strategy
123 | --- !!de.oppermann.pomutils.rules.PropertyRule
124 | strategy : OUR # possible values: OUR|THEIR
125 | properties: # resolves the two given properties in the global and profile property section, using the *OUR* strategy
126 | - jdbc.user.name
127 | - foobar.version
128 | propertiesRegex: # resolves properties in the global and profile property section matching regex expression, using the *OUR* strategy
129 | - .+\.version
130 |
131 | --- !!de.oppermann.pomutils.rules.ScmTagRule
132 | strategy: OUR # possible values: OUR|THEIR
133 | # resolves the ... element conflicts, using the *OUR* strategy
134 |
135 | Basically you define the rules which should be used by adding the implementation class of the rule with *--- !!*,
136 | followed by the configuration. If you want to write your own rule, have a look at the implemented ones and perhaps send
137 | a pull request to merge it ;-)
138 |
139 | After you wrote your ruleset configuration file, add it to your git project *somewhere* and change the `driver` entry in your `.git/config`, e.g.:
140 |
141 | ```
142 | [merge "pom"]
143 | name = Automatically resolve project and/or parent version and properties in pom files. The rest is a normal merge.
144 | driver = java -jar /pomutils-X.X.jar merge --base=%O --our=%A --their=%B --ruleset=.pomutilsMergeRuleset
145 | ```
146 |
147 | *replace* Command Usage
148 | ------------
149 | This command is used to set the parent/project version of a single pom.xml file. The version-maven-plugin always adjust the child's too, sometimes you don't want that.
150 |
151 | `java -jar /pomutils-X.X.jar replace --pom= --version=`
152 |
153 |
154 | HINTS
155 | ------------
156 | In my project's I ship the pomutils.jar within the project. My .git/config entry looks like:
157 |
158 | ```
159 | [merge "pom"]
160 | driver = java -jar ./buildmgr/pomutils.jar merge --base=%O --our=%A --their=%B --ruleset=./buildmgr/ruleset
161 | ```
162 |
163 | Now all developers can use the merge driver without downloading first the jar. They only have to add the .git/config entry.
164 |
165 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | 1.7.0
6 |
7 |
8 |
9 | The Apache Software License, Version 2.0
10 | http://www.apache.org/licenses/LICENSE-2.0.txt
11 |
12 |
13 |
14 |
15 | UTF-8
16 |
17 |
18 |
19 |
20 | Sven Oppermann
21 | sven.oppermann@gmail.com
22 |
23 | Lead Developer
24 |
25 | +1
26 |
27 |
28 |
29 |
30 |
31 |
32 | org.apache.maven.plugins
33 | maven-jar-plugin
34 | 2.5
35 |
36 |
37 |
38 | true
39 | true
40 |
41 |
42 |
43 |
44 |
45 | org.apache.maven.plugins
46 | maven-shade-plugin
47 | 2.3
48 |
49 |
50 | package
51 |
52 | shade
53 |
54 |
55 |
56 |
57 |
58 | de.oppermann.pomutils.Main
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-compiler-plugin
69 | 3.2
70 |
71 | 1.6
72 | 1.6
73 | true
74 | false
75 | true
76 |
77 |
78 |
79 |
80 |
81 |
82 | org.apache.maven.plugins
83 | maven-surefire-plugin
84 | 2.17
85 |
86 | false
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | org.codehaus.plexus
99 | plexus-utils
100 | 3.1.1
101 |
102 |
103 | org.codehaus.mojo
104 | versions-maven-plugin
105 | 2.7
106 | maven-plugin
107 |
108 |
109 | org.apache.maven
110 | maven-artifact-manager
111 |
112 |
113 | org.apache.maven
114 | maven-core
115 |
116 |
117 | org.apache.maven
118 | maven-plugin-api
119 |
120 |
121 | org.apache.maven
122 | maven-plugin-registry
123 |
124 |
125 | org.apache.maven
126 | maven-plugin-descriptor
127 |
128 |
129 | org.apache.maven
130 | maven-settings
131 |
132 |
133 | org.apache.maven.reporting
134 | maven-reporting-api
135 |
136 |
137 | org.apache.maven.reporting
138 | maven-reporting-impl
139 |
140 |
141 | org.apache.maven.shared
142 | maven-common-artifact-filters
143 |
144 |
145 | org.apache.maven.wagon
146 | wagon-provider-api
147 |
148 |
149 | org.apache.maven.wagon
150 | wagon-file
151 |
152 |
153 | org.apache.maven.doxia
154 | doxia-core
155 |
156 |
157 | org.apache.maven.doxia
158 | doxia-sink-api
159 |
160 |
161 | org.apache.maven.doxia
162 | doxia-site-renderer
163 |
164 |
165 | org.codehaus.plexus
166 | plexus-container-default
167 |
168 |
169 | org.codehaus.plexus
170 | plexus-interactivity-api
171 |
172 |
173 | org.codehaus.plexus
174 | plexus-i18n
175 |
176 |
177 | org.codehaus.plexus
178 | plexus-interpolation
179 |
180 |
181 | org.slf4j
182 | slf4j-nop
183 |
184 |
185 | org.slf4j
186 | slf4j-jdk14
187 |
188 |
189 |
190 |
191 | com.beust
192 | jcommander
193 | 1.35
194 |
195 |
196 | org.slf4j
197 | slf4j-api
198 | 1.7.7
199 |
200 |
201 | org.slf4j
202 | slf4j-simple
203 | 1.7.7
204 |
205 |
206 | org.yaml
207 | snakeyaml
208 | 1.26
209 |
210 |
211 |
212 |
213 |
214 | junit
215 | junit
216 | 4.13.1
217 | test
218 |
219 |
220 | org.mockito
221 | mockito-core
222 | 1.10.17
223 | test
224 |
225 |
226 | commons-io
227 | commons-io
228 | 2.7
229 | test
230 |
231 |
232 |
233 |
234 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/Main.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import org.apache.commons.lang.StringUtils;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 | import org.slf4j.impl.SimpleLogger;
26 |
27 | import com.beust.jcommander.JCommander;
28 | import com.beust.jcommander.ParameterException;
29 |
30 | import de.oppermann.pomutils.commands.CommandMain;
31 | import de.oppermann.pomutils.commands.CommandPomMergeDriver;
32 | import de.oppermann.pomutils.commands.CommandPomVersionReplacer;
33 | import de.oppermann.pomutils.util.ManifestUtils;
34 |
35 | /**
36 | * Main Class. Provides an entry Point to all Commands.
37 | *
38 | * @author Sven Oppermann
39 | *
40 | */
41 |
42 | public class Main {
43 |
44 | private static Logger logger = null;
45 |
46 | public static void main(String... args) {
47 | int resultValue = 0;
48 | try {
49 | resultValue = mainInternal(args);
50 | logger.debug("Exiting with exit code {}", resultValue);
51 | } catch (Exception e) {
52 | System.err.println("We got an exception on merge: " + StringUtils.join(args, " "));
53 | e.printStackTrace();
54 | System.exit(1);
55 | }
56 |
57 | System.exit(resultValue);
58 | }
59 |
60 | protected static int mainInternal(String... args) {
61 | CommandMain mainCommand = new CommandMain();
62 | CommandPomMergeDriver mergeCommand = new CommandPomMergeDriver();
63 | CommandPomVersionReplacer versionReplacerCommand = new CommandPomVersionReplacer();
64 |
65 | JCommander jc = new JCommander(mainCommand);
66 | jc.addCommand("merge", mergeCommand);
67 | jc.addCommand("replace", versionReplacerCommand);
68 |
69 | try {
70 | jc.parse(args);
71 | } catch (ParameterException e) {
72 | System.err.println(e.getMessage());
73 | return 1;
74 | }
75 |
76 | String logLevel = mainCommand.isDebug() ? "debug" : "error";
77 | System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, logLevel);
78 |
79 | logger = LoggerFactory.getLogger(Main.class);
80 |
81 | if (logger.isInfoEnabled()) {
82 | logger.info("PomUtils version {}", ManifestUtils.getImplementationVersion());
83 | }
84 |
85 | if ("merge".equals(jc.getParsedCommand())) {
86 | return executePomMergeDriver(mergeCommand);
87 | } else if ("replace".equals(jc.getParsedCommand())) {
88 | executePomVersionReplacer(versionReplacerCommand);
89 | return 0;
90 | }
91 | jc.usage();
92 | return 1;
93 | }
94 |
95 | private static int executePomMergeDriver(CommandPomMergeDriver mergeCommand) {
96 | PomMergeDriver pomMergeDriver = new PomMergeDriver(mergeCommand.getRuleSet(), mergeCommand.getBasePom(),
97 | mergeCommand.getOurPom(), mergeCommand.getTheirPom());
98 | return pomMergeDriver.merge();
99 | }
100 |
101 | private static void executePomVersionReplacer(CommandPomVersionReplacer versionReplacerCommand) {
102 | PomVersionReplacer pomVersionReplacer = new PomVersionReplacer(versionReplacerCommand.getPom());
103 | pomVersionReplacer.setVersionTo(versionReplacerCommand.getVersion());
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/PomMergeDriver.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.BufferedInputStream;
23 | import java.io.IOException;
24 |
25 | import javax.xml.stream.XMLStreamException;
26 |
27 | import org.codehaus.plexus.util.IOUtil;
28 | import org.slf4j.Logger;
29 | import org.slf4j.LoggerFactory;
30 |
31 | import de.oppermann.pomutils.rules.Ruleset;
32 | import de.oppermann.pomutils.util.POM;
33 |
34 | /**
35 | *
36 | * @author Sven Oppermann
37 | *
38 | */
39 |
40 | public class PomMergeDriver {
41 |
42 | private final Logger logger = LoggerFactory.getLogger(PomMergeDriver.class);
43 |
44 | private Ruleset ruleset;
45 | private final String basePomFile;
46 | private final String ourPomFile;
47 | private final String theirPomFile;
48 |
49 | public PomMergeDriver(Ruleset ruleset, String basePomFile, String ourPomFile, String theirPomFile) {
50 | this.ruleset = ruleset;
51 | this.basePomFile = basePomFile;
52 | this.ourPomFile = ourPomFile;
53 | this.theirPomFile = theirPomFile;
54 | }
55 |
56 | public int merge() {
57 | try {
58 | logger.debug("Doing merge [our={}] [base={}] [their={}]", ourPomFile,
59 | basePomFile, theirPomFile);
60 |
61 | POM basePom = new POM(basePomFile);
62 | POM ourPom = new POM(ourPomFile);
63 | POM theirPom = new POM(theirPomFile);
64 |
65 | ruleset.evaluate(basePom, ourPom, theirPom);
66 |
67 | basePom.savePom();
68 | theirPom.savePom();
69 | ourPom.savePom();
70 | } catch (IOException e) {
71 | logger.warn("Exception when attempting to merge pom versions. Falling back to default merge.", e);
72 | } catch (XMLStreamException e) {
73 | logger.warn("Exception when attempting to merge pom versions. Falling back to default merge.", e);
74 | }
75 |
76 | return doGitMerge();
77 | }
78 |
79 | private int doGitMerge() {
80 | ProcessBuilder processBuilder = new ProcessBuilder("git", "merge-file", "-L", "ours", "-L", "base", "-L",
81 | "theirs",
82 | ourPomFile, basePomFile, theirPomFile);
83 | processBuilder.redirectErrorStream(true);
84 | try {
85 | final Process p = processBuilder.start();
86 |
87 | consumeGitOutput(p);
88 |
89 | return p.waitFor();
90 | } catch (InterruptedException e) {
91 | throw new RuntimeException(e);
92 | } catch (IOException e) {
93 | throw new RuntimeException(e);
94 | }
95 | }
96 |
97 | private void consumeGitOutput(final Process p) throws IOException {
98 |
99 | String output = IOUtil.toString(new BufferedInputStream(p.getInputStream(), 256));
100 |
101 | logger.debug("Git merge output:\n{}", output);
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/PomVersionReplacer.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.IOException;
23 |
24 | import javax.xml.stream.XMLStreamException;
25 |
26 | import de.oppermann.pomutils.util.POM;
27 |
28 | /**
29 | *
30 | * @author Sven Oppermann
31 | *
32 | */
33 |
34 | public class PomVersionReplacer {
35 |
36 | private final String pomFileAsString;
37 |
38 | public PomVersionReplacer(String pomFileAsString) {
39 | this.pomFileAsString = pomFileAsString;
40 | }
41 |
42 | public void setVersionTo(String newVersion) {
43 | try {
44 | POM pomFile = new POM(pomFileAsString);
45 | pomFile.setParentVersion(newVersion);
46 | pomFile.setProjectVersion(newVersion);
47 | pomFile.savePom();
48 | } catch (IOException e) {
49 | throw new RuntimeException(e);
50 | } catch (XMLStreamException e) {
51 | throw new RuntimeException(e);
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/commands/CommandMain.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.commands;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import com.beust.jcommander.Parameter;
23 | import com.beust.jcommander.Parameters;
24 |
25 | /**
26 | *
27 | * @author Sven Oppermann
28 | *
29 | */
30 |
31 | @Parameters(separators = "=")
32 | public class CommandMain {
33 |
34 | @Parameter(names = "--help", help = true, description = "Used to print this information.")
35 | private boolean help;
36 |
37 | @Parameter(names = "--debug", description = "If you want to print debug information add this option.")
38 | private boolean debug = false;
39 |
40 | public boolean isDebug() {
41 | return debug;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/commands/CommandPomMergeDriver.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.commands;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 |
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | import de.oppermann.pomutils.rules.Ruleset;
28 | import de.oppermann.pomutils.select.SelectionStrategy;
29 |
30 | /**
31 | *
32 | * @author Sven Oppermann
33 | *
34 | */
35 |
36 | @Parameters(separators = "=", commandDescription = "Used as merge driver in git. Updates the version of 'our' pom or 'their' pom (based on the value of --select), and then does a normal 'git merge-file'")
37 | public class CommandPomMergeDriver {
38 |
39 | @Parameter(names = { "-b", "--base" }, description = "Base Pom", required = true)
40 | private String basePom;
41 |
42 | @Parameter(names = { "-o", "--our" }, description = "Our Pom", required = true)
43 | private String ourPom;
44 |
45 | @Parameter(names = { "-t", "--their" }, description = "Their Pom", required = true)
46 | private String theirPom;
47 |
48 | @Parameter(names = { "-s", "--select" }, description = "Which version to select to resolve conflicts. 'our', 'their', or 'prompt'. If 'prompt' is specified, then you will be prompted via stdout/stdin to select a version.", required = false, converter = SelectionStrategyConverter.class)
49 | private SelectionStrategy selectionStrategy = SelectionStrategy.OUR;
50 |
51 | @Parameter(names = { "-r", "--ruleset" }, description = "The ruleset to use when you merge poms. If you don't specify a ruleset, a default ruleset will be used. Default is ProjectAndParentVersionRule with our strategy.")
52 | private File ruleSetfile;
53 |
54 | public String getBasePom() {
55 | return basePom;
56 | }
57 |
58 | public String getOurPom() {
59 | return ourPom;
60 | }
61 |
62 | public String getTheirPom() {
63 | return theirPom;
64 | }
65 |
66 | public SelectionStrategy getSelectionStrategy() {
67 | return selectionStrategy;
68 | }
69 |
70 | public File getRuleSetFile() {
71 | return ruleSetfile;
72 | }
73 |
74 | public Ruleset getRuleSet() {
75 | if (getRuleSetFile() == null) {
76 | return new Ruleset(getSelectionStrategy());
77 | }
78 | return new Ruleset(getRuleSetFile());
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/commands/CommandPomVersionReplacer.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.commands;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import com.beust.jcommander.Parameter;
23 | import com.beust.jcommander.Parameters;
24 |
25 | /**
26 | *
27 | * @author Sven Oppermann
28 | *
29 | */
30 |
31 | @Parameters(separators = "=", commandDescription = "Updates the parent version and/or the project version in the given pom.xml")
32 | public class CommandPomVersionReplacer {
33 |
34 | @Parameter(names = { "-p", "--pom" }, description = "The pom where you want to replace the parent and project version", required = true)
35 | private String pom;
36 |
37 | @Parameter(names = { "-v", "--version" }, description = "The new version you want to set", required = true)
38 | private String version;
39 |
40 | public String getPom() {
41 | return pom;
42 | }
43 |
44 | public String getVersion() {
45 | return version;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/commands/SelectionStrategyConverter.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.commands;
2 |
3 | import com.beust.jcommander.IStringConverter;
4 | import com.beust.jcommander.ParameterException;
5 |
6 | import de.oppermann.pomutils.select.SelectionStrategy;
7 |
8 | public class SelectionStrategyConverter implements IStringConverter {
9 |
10 | @Override
11 | public SelectionStrategy convert(String value) {
12 | if (value == null) {
13 | return SelectionStrategy.OUR;
14 | }
15 |
16 | try {
17 | return SelectionStrategy.valueOf(value.toUpperCase());
18 | } catch (IllegalArgumentException e) {
19 | throw new ParameterException("--select must be one of 'our', 'their', or 'prompt'");
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/AbstractRule.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | import de.oppermann.pomutils.select.SelectionStrategy;
4 |
5 | /*
6 | * Licensed to the Apache Software Foundation (ASF) under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The ASF licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | */
23 |
24 | /**
25 | *
26 | * @author Sven Oppermann
27 | *
28 | */
29 |
30 | public abstract class AbstractRule implements Rule {
31 |
32 | private SelectionStrategy strategy;
33 |
34 | public AbstractRule() {
35 | // for snakeyaml
36 | }
37 |
38 | public AbstractRule(SelectionStrategy strategy) {
39 | this.strategy = strategy;
40 | }
41 |
42 | public SelectionStrategy getStrategy() {
43 | return strategy;
44 | }
45 |
46 | public void setStrategy(SelectionStrategy strategy) {
47 | this.strategy = strategy;
48 | }
49 |
50 | public void setStrategy(String strategy) {
51 | this.strategy = SelectionStrategy.valueOf(strategy.toUpperCase());
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/ProjectAndParentVersionRule.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | import de.oppermann.pomutils.select.SelectionStrategy;
7 | import de.oppermann.pomutils.util.POM;
8 | import de.oppermann.pomutils.util.VersionFieldType;
9 |
10 | /*
11 | * Licensed to the Apache Software Foundation (ASF) under one
12 | * or more contributor license agreements. See the NOTICE file
13 | * distributed with this work for additional information
14 | * regarding copyright ownership. The ASF licenses this file
15 | * to you under the Apache License, Version 2.0 (the
16 | * "License"); you may not use this file except in compliance
17 | * with the License. You may obtain a copy of the License at
18 | *
19 | * http://www.apache.org/licenses/LICENSE-2.0
20 | *
21 | * Unless required by applicable law or agreed to in writing,
22 | * software distributed under the License is distributed on an
23 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24 | * KIND, either express or implied. See the License for the
25 | * specific language governing permissions and limitations
26 | * under the License.
27 | */
28 |
29 | /**
30 | *
31 | * @author Sven Oppermann
32 | *
33 | */
34 |
35 | public class ProjectAndParentVersionRule extends AbstractRule {
36 |
37 | private final Logger logger = LoggerFactory.getLogger(ProjectAndParentVersionRule.class);
38 |
39 | public ProjectAndParentVersionRule() {
40 | // for creating this instance via snakeyaml
41 | }
42 |
43 | public ProjectAndParentVersionRule(SelectionStrategy strategy) {
44 | super(strategy);
45 | logger.debug("Using ProjectAndParentVersionRule with strategy [{}]", strategy.toString());
46 | }
47 |
48 | @Override
49 | public void evaluate(POM basePom, POM ourPom, POM theirPom) {
50 | adjustVersion(basePom, ourPom, theirPom, VersionFieldType.PROJECT);
51 | adjustVersion(basePom, ourPom, theirPom, VersionFieldType.PARENT);
52 | }
53 |
54 | private void adjustVersion(POM basePom, POM ourPom, POM theirPom, VersionFieldType versionFieldType) {
55 | String baseVersion = versionFieldType.get(basePom);
56 | String ourVersion = versionFieldType.get(ourPom);
57 | String theirVersion = versionFieldType.get(theirPom);
58 | if (baseVersion != null && ourVersion != null && theirVersion != null && !ourVersion.equals(theirVersion)) {
59 | String newVersion;
60 | if (baseVersion.equals(ourVersion)) {
61 | /*
62 | * Our version hasn't changed, so no conflict. Just use theirVersion.
63 | */
64 | newVersion = theirVersion;
65 | } else if (baseVersion.equals(theirVersion)) {
66 | /*
67 | * Their version hasn't changed, so no conflict. Just use ourVersion.
68 | */
69 | newVersion = ourVersion;
70 | } else {
71 | /*
72 | * Both our version and their version have changed from the base, so conflict.
73 | */
74 | newVersion = getStrategy().getSelector().selectVersion(
75 | ourPom.getProjectIdentifier(),
76 | versionFieldType,
77 | ourVersion,
78 | theirVersion);
79 | }
80 |
81 | if (newVersion != null) {
82 | /*
83 | * newVersion can be null if the user wants to skip resolution.
84 | */
85 |
86 | POM pomToAdjust = newVersion.equals(ourVersion)
87 | ? theirPom
88 | : ourPom;
89 |
90 | versionFieldType.set(pomToAdjust, newVersion);
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/PropertyRule.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | import java.io.IOException;
22 | import java.util.Arrays;
23 | import java.util.List;
24 | import java.util.regex.Pattern;
25 | import java.util.regex.PatternSyntaxException;
26 |
27 | import javax.xml.stream.XMLStreamException;
28 |
29 | import org.apache.maven.model.Profile;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 |
33 | import de.oppermann.pomutils.select.SelectionStrategy;
34 | import de.oppermann.pomutils.util.POM;
35 |
36 | /**
37 | *
38 | * @author Sven Oppermann
39 | *
40 | */
41 |
42 | public class PropertyRule extends AbstractRule {
43 |
44 | private final Logger logger = LoggerFactory.getLogger(PropertyRule.class);
45 |
46 | private List properties;
47 |
48 | private List propertiesRegex;
49 |
50 | public PropertyRule() {
51 | // for creating this instance via snakeyaml
52 | }
53 |
54 | public PropertyRule(SelectionStrategy strategy, List properties) {
55 | super(strategy);
56 | this.properties = properties;
57 | logger.debug("Using ProjectAndParentVersionRule with strategy [{}] for properties [{}]", strategy.toString(), Arrays.toString(properties.toArray()));
58 | }
59 |
60 | public List getProperties() {
61 | return properties;
62 | }
63 |
64 | public void setProperties(List properties) {
65 | this.properties = properties;
66 | }
67 |
68 | public List getPropertiesRegex() {
69 | return propertiesRegex;
70 | }
71 |
72 | public void setPropertiesRegex(List propertiesRegex) {
73 | this.propertiesRegex = propertiesRegex;
74 | }
75 |
76 | @Override
77 | public void evaluate(POM basePom, POM ourPom, POM theirPom) throws IOException, XMLStreamException {
78 | POM adjustPom;
79 | POM withValueOfPom;
80 |
81 | switch (getStrategy()) {
82 | case OUR:
83 | adjustPom = theirPom;
84 | withValueOfPom = ourPom;
85 | break;
86 | case THEIR:
87 | adjustPom = ourPom;
88 | withValueOfPom = theirPom;
89 | break;
90 | default:
91 | throw new IllegalArgumentException("Strategy [" + getStrategy().toString() + "] not implemented.");
92 | }
93 |
94 | if (getProperties() != null) {
95 | for (String property : getProperties()) {
96 | logger.debug("Process property [{}]", property);
97 | resolvePropertyValue(property, adjustPom, withValueOfPom);
98 | }
99 | }
100 |
101 | if (getPropertiesRegex() != null) {
102 | for (String propertyRegex : getPropertiesRegex()) {
103 | logger.debug("Process property regex [{}]", propertyRegex);
104 | Pattern regex = compilePropertyRegex(propertyRegex);
105 | for (String property : adjustPom.getMatchingProperties(regex)) {
106 | resolvePropertyValue(property, adjustPom, withValueOfPom);
107 | }
108 | }
109 | }
110 | }
111 |
112 | private void resolvePropertyValue(String property, POM adjustPom, POM withValueOfPom) throws XMLStreamException, IOException {
113 | adjustPom.setPropertyToValue(property, withValueOfPom.getProperties().getProperty(property));
114 | for (Profile profile : adjustPom.getProfiles()) {
115 | adjustPom.setPropertyToValue(profile.getId(), property, withValueOfPom.getProfileProperty(profile.getId(), property));
116 | }
117 | }
118 |
119 | private Pattern compilePropertyRegex(String propertyRegex) {
120 | Pattern regex;
121 | try {
122 | regex = Pattern.compile(propertyRegex);
123 | } catch (PatternSyntaxException e) {
124 | throw new IllegalArgumentException("Invalid regex expression for property regex [" + propertyRegex + "] ");
125 | }
126 | return regex;
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/Rule.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.xml.stream.XMLStreamException;
6 |
7 | import de.oppermann.pomutils.util.POM;
8 |
9 | /*
10 | * Licensed to the Apache Software Foundation (ASF) under one
11 | * or more contributor license agreements. See the NOTICE file
12 | * distributed with this work for additional information
13 | * regarding copyright ownership. The ASF licenses this file
14 | * to you under the Apache License, Version 2.0 (the
15 | * "License"); you may not use this file except in compliance
16 | * with the License. You may obtain a copy of the License at
17 | *
18 | * http://www.apache.org/licenses/LICENSE-2.0
19 | *
20 | * Unless required by applicable law or agreed to in writing,
21 | * software distributed under the License is distributed on an
22 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 | * KIND, either express or implied. See the License for the
24 | * specific language governing permissions and limitations
25 | * under the License.
26 | */
27 |
28 | /**
29 | *
30 | * @author Sven Oppermann
31 | *
32 | */
33 |
34 | public interface Rule {
35 |
36 | void evaluate(POM basePom, POM ourPom, POM theirPom) throws IOException, XMLStreamException;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/Ruleset.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileNotFoundException;
6 | import java.io.IOException;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import javax.xml.stream.XMLStreamException;
11 |
12 | import org.yaml.snakeyaml.Yaml;
13 |
14 | import de.oppermann.pomutils.select.SelectionStrategy;
15 | import de.oppermann.pomutils.util.POM;
16 |
17 | /*
18 | * Licensed to the Apache Software Foundation (ASF) under one
19 | * or more contributor license agreements. See the NOTICE file
20 | * distributed with this work for additional information
21 | * regarding copyright ownership. The ASF licenses this file
22 | * to you under the Apache License, Version 2.0 (the
23 | * "License"); you may not use this file except in compliance
24 | * with the License. You may obtain a copy of the License at
25 | *
26 | * http://www.apache.org/licenses/LICENSE-2.0
27 | *
28 | * Unless required by applicable law or agreed to in writing,
29 | * software distributed under the License is distributed on an
30 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
31 | * KIND, either express or implied. See the License for the
32 | * specific language governing permissions and limitations
33 | * under the License.
34 | */
35 |
36 | /**
37 | *
38 | * @author Sven Oppermann
39 | *
40 | */
41 |
42 | public class Ruleset {
43 |
44 | private List rules = new ArrayList();
45 |
46 | /**
47 | * Creates the default Ruleset with the ProjectAndParentVersionRule.
48 | */
49 | public Ruleset(SelectionStrategy strategy) {
50 | rules.add(new ProjectAndParentVersionRule(strategy));
51 | }
52 |
53 | public Ruleset(File rulesetFile) {
54 | if (!rulesetFile.exists()) {
55 | throw new IllegalArgumentException("File [" + rulesetFile.getAbsolutePath() + "] does not exist");
56 | }
57 |
58 | Yaml yaml = new Yaml();
59 |
60 | FileInputStream is = null;
61 | try {
62 | is = new FileInputStream(rulesetFile);
63 | for (Object data : yaml.loadAll(is)) {
64 | rules.add((Rule) data);
65 | }
66 | } catch (FileNotFoundException e) {
67 | throw new RuntimeException(e);
68 | }
69 | finally {
70 | if (is != null) {
71 | try {
72 | is.close();
73 | } catch (IOException e) {
74 | throw new RuntimeException(e);
75 | }
76 | }
77 | }
78 | }
79 |
80 | public void evaluate(POM basePom, POM ourPom, POM theirPom) throws IOException, XMLStreamException {
81 | for (Rule rule : rules) {
82 | rule.evaluate(basePom, ourPom, theirPom);
83 | }
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/rules/ScmTagRule.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.rules;
2 |
3 | import de.oppermann.pomutils.select.SelectionStrategy;
4 | import de.oppermann.pomutils.util.POM;
5 | import de.oppermann.pomutils.util.VersionFieldType;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /*
10 | * Licensed to the Apache Software Foundation (ASF) under one
11 | * or more contributor license agreements. See the NOTICE file
12 | * distributed with this work for additional information
13 | * regarding copyright ownership. The ASF licenses this file
14 | * to you under the Apache License, Version 2.0 (the
15 | * "License"); you may not use this file except in compliance
16 | * with the License. You may obtain a copy of the License at
17 | *
18 | * http://www.apache.org/licenses/LICENSE-2.0
19 | *
20 | * Unless required by applicable law or agreed to in writing,
21 | * software distributed under the License is distributed on an
22 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 | * KIND, either express or implied. See the License for the
24 | * specific language governing permissions and limitations
25 | * under the License.
26 | */
27 |
28 | /**
29 | *
30 | * @author Sébastien Latre
31 | *
32 | */
33 |
34 | public class ScmTagRule extends AbstractRule {
35 |
36 | private final Logger logger = LoggerFactory.getLogger(ScmTagRule.class);
37 |
38 | public ScmTagRule() {
39 | // for creating this instance via snakeyaml
40 | }
41 |
42 | public ScmTagRule(SelectionStrategy strategy) {
43 | super(strategy);
44 | logger.debug("Using ScmTagRule with strategy [{}]", strategy.toString());
45 | }
46 |
47 | @Override
48 | public void evaluate(POM basePom, POM ourPom, POM theirPom) {
49 | String baseScmTag = basePom.getScmTag();
50 | String ourScmTag = ourPom.getScmTag();
51 | String theirScmTag = theirPom.getScmTag();
52 | if (baseScmTag != null && ourScmTag != null && theirScmTag != null && !ourScmTag.equals(theirScmTag)) {
53 | String newScmTag;
54 | if (baseScmTag.equals(ourScmTag)) {
55 | /*
56 | * Our ScmTag hasn't changed, so no conflict. Just use theirScmTag.
57 | */
58 | newScmTag = theirScmTag;
59 | } else if (baseScmTag.equals(theirScmTag)) {
60 | /*
61 | * Their scmTag hasn't changed, so no conflict. Just use ourScmTag.
62 | */
63 | newScmTag = ourScmTag;
64 | } else {
65 | /*
66 | * Both our scmTag and their scmTag have changed from the base, so conflict.
67 | */
68 | switch (getStrategy()) {
69 | case OUR:
70 | newScmTag = ourScmTag;
71 | break;
72 | case THEIR:
73 | newScmTag = theirScmTag;
74 | break;
75 | default:
76 | throw new IllegalArgumentException("Strategy [" + getStrategy().toString() + "] not implemented.");
77 | }
78 | }
79 |
80 | if (newScmTag != null) {
81 | /*
82 | * newScmTag can be null if the user wants to skip resolution.
83 | */
84 |
85 | POM pomToAdjust = newScmTag.equals(ourScmTag)
86 | ? theirPom
87 | : ourPom;
88 |
89 | pomToAdjust.setScmTag(newScmTag);
90 | }
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/OurVersionSelector.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import de.oppermann.pomutils.util.VersionFieldType;
4 |
5 | /**
6 | * Always select 'our' version.
7 | */
8 | public class OurVersionSelector implements VersionSelector {
9 |
10 | @Override
11 | public String selectVersion(String projectIdentifier, VersionFieldType versionFieldType, String ourVersion, String theirVersion) {
12 | return ourVersion;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/PersistentVersionSelector.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import java.io.File;
4 | import java.io.FileReader;
5 | import java.io.FileWriter;
6 | import java.io.IOException;
7 | import java.util.Properties;
8 |
9 | import org.codehaus.plexus.util.IOUtil;
10 |
11 | import de.oppermann.pomutils.util.VersionFieldType;
12 |
13 | /**
14 | * Persists a selected version from a {@link #delegate} version selector to disk,
15 | * and returns any valid previously selected version on future invocations.
16 | *
17 | * This is used to store user selection between process invocations.
18 | * The user's selection will be valid for 2 mins.
19 | */
20 | public class PersistentVersionSelector implements VersionSelector {
21 |
22 | /**
23 | * Default file that is used to persist selection.
24 | * Found in the working directory.
25 | */
26 | private static final File DEFAULT_PERSISTENT_FILE = new File(".pomVersionSelection");
27 |
28 | /**
29 | * Timeout in milliseconds after which the selection is considered timed out.
30 | * A user will have to make a new selection after this time has elapsed.
31 | *
32 | * Since pomutils is invoked for every file, and there's no indication
33 | * of the first or last invocation, we rely on a timeout to clear
34 | * state between merge invocations.
35 | */
36 | private static final long TIMEOUT = 2 * 60 * 1000; // 2 mins
37 |
38 | /**
39 | * File that is used to persist selection state.
40 | */
41 | private final File persistentFile;
42 |
43 | /**
44 | * Used to select the version if the persistent state does not exist or is no longer valid.
45 | */
46 | private final VersionSelector delegate;
47 |
48 | /**
49 | * Represents the user's selection for a given conflict.
50 | */
51 | private static class SelectionState {
52 | private static final String PROPERTY_OUR_VERSION = "ourVersion";
53 | private static final String PROPERTY_THEIR_VERSION = "theirVersion";
54 | private static final String PROPERTY_SELECTED_VERSION = "selectedVersion";
55 |
56 | private final String ourVersion;
57 | private final String theirVersion;
58 | /**
59 | * Version that the user selected, or null if the user chose to skip resolution.
60 | */
61 | private final String selectedVersion;
62 |
63 | private SelectionState(
64 | String ourVersion,
65 | String theirVersion,
66 | String selectedVersion) {
67 |
68 | super();
69 | this.ourVersion = ourVersion;
70 | this.theirVersion = theirVersion;
71 | this.selectedVersion = selectedVersion;
72 | }
73 |
74 | public static SelectionState fromProperties(Properties properties) {
75 | String ourVersion = properties.getProperty(PROPERTY_OUR_VERSION);
76 | String theirVersion = properties.getProperty(PROPERTY_THEIR_VERSION);
77 | String selectedVersion = properties.getProperty(PROPERTY_SELECTED_VERSION);
78 |
79 | if (ourVersion == null || theirVersion == null) {
80 | return null;
81 | }
82 | return new SelectionState(ourVersion, theirVersion, selectedVersion);
83 | }
84 |
85 | public Properties toProperties() {
86 | Properties properties = new Properties();
87 | properties.setProperty(PROPERTY_OUR_VERSION, ourVersion);
88 | properties.setProperty(PROPERTY_THEIR_VERSION, theirVersion);
89 | if (selectedVersion != null) {
90 | properties.setProperty(PROPERTY_SELECTED_VERSION, selectedVersion);
91 | }
92 | return properties;
93 | }
94 |
95 | public String getSelectedVersion() {
96 | return selectedVersion;
97 | }
98 |
99 | public boolean isValidFor(String ourVersion, String theirVersion) {
100 | return this.ourVersion.equals(ourVersion)
101 | && this.theirVersion.equals(theirVersion);
102 | }
103 | }
104 |
105 | public PersistentVersionSelector(VersionSelector delegate) {
106 | this(delegate, DEFAULT_PERSISTENT_FILE);
107 | }
108 |
109 | public PersistentVersionSelector(VersionSelector delegate, File persistentFile) {
110 | super();
111 | this.delegate = delegate;
112 | this.persistentFile = persistentFile;
113 | }
114 |
115 | @Override
116 | public String selectVersion(String projectIdentifier, VersionFieldType versionFieldType, String ourVersion, String theirVersion) {
117 | try {
118 | SelectionState selectionState = readState();
119 |
120 | String selectedVersion;
121 | if (selectionState != null && selectionState.isValidFor(ourVersion, theirVersion)) {
122 | selectedVersion = selectionState.getSelectedVersion();
123 | } else {
124 | selectedVersion = delegate.selectVersion(projectIdentifier, versionFieldType, ourVersion, theirVersion);
125 | writeState(new SelectionState(ourVersion, theirVersion, selectedVersion));
126 | }
127 | return selectedVersion;
128 | } catch (IOException e) {
129 | return null;
130 | }
131 | }
132 |
133 | /**
134 | * Reads the selection state from {@link #persistentFile}.
135 | */
136 | private SelectionState readState() throws IOException {
137 | if (!persistentFile.canRead()) {
138 | return null;
139 | }
140 |
141 | if (persistentFile.lastModified() < System.currentTimeMillis() - TIMEOUT) {
142 | return null;
143 | }
144 |
145 | FileReader reader = null;
146 |
147 | try {
148 | reader = new FileReader(persistentFile);
149 | Properties properties = new Properties();
150 | properties.load(reader);
151 |
152 | return SelectionState.fromProperties(properties);
153 | } finally {
154 | IOUtil.close(reader);
155 | }
156 | }
157 |
158 | /**
159 | * Writes the selection state to {@link #persistentFile}.
160 | */
161 | private void writeState(SelectionState selectionState) throws IOException {
162 | FileWriter writer = null;
163 |
164 | try {
165 | writer = new FileWriter(persistentFile);
166 | Properties properties = selectionState.toProperties();
167 | properties.store(
168 | writer,
169 | String.format("Used by the 'pomutils' merge driver to store version selections%n"
170 | + "within the same invocation of git merge%n"
171 | + "(to avoid repeatedly prompting the user to select a version).%n"
172 | + "Selected versions will only be reused for 2 minutes.%n"
173 | + "It is safe to delete this file between git merge invocations%n"
174 | + "(which will cause the user to be prompted again).%n"));
175 | } finally {
176 | IOUtil.close(writer);
177 | }
178 | }
179 |
180 | }
181 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/SelectionStrategy.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | /**
4 | * Strategy to use to select a version to resolve conflicts.
5 | */
6 | public enum SelectionStrategy {
7 |
8 | /**
9 | * Always select 'our' version (the default).
10 | */
11 | OUR(new OurVersionSelector()),
12 |
13 | /**
14 | * Always select 'their' version.
15 | */
16 | THEIR(new TheirVersionSelector()),
17 |
18 | /**
19 | * Prompt the user via stdout/stdin for them to select the version.
20 | */
21 | PROMPT(new PersistentVersionSelector(new StreamVersionSelector()));
22 |
23 | private final VersionSelector selector;
24 |
25 | private SelectionStrategy(VersionSelector selector) {
26 | this.selector = selector;
27 | }
28 |
29 | /*
30 | * Overridden so that the proper string appears in --help output.
31 | */
32 | public String toString() {
33 | return name().toLowerCase();
34 | }
35 |
36 | public VersionSelector getSelector() {
37 | return selector;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/StreamVersionSelector.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.io.OutputStream;
8 | import java.io.PrintStream;
9 |
10 | import de.oppermann.pomutils.util.VersionFieldType;
11 |
12 | /**
13 | * A {@link VersionSelector} that prompts the user
14 | * via an output stream and reads the response via an input stream.
15 | */
16 | public class StreamVersionSelector implements VersionSelector {
17 |
18 | private final PrintStream out;
19 | private final BufferedReader in;
20 |
21 | /**
22 | * Uses {@link System#out} and {@link System#in}.
23 | */
24 | public StreamVersionSelector() {
25 | this(System.out, System.in);
26 | }
27 |
28 | public StreamVersionSelector(OutputStream out, InputStream in) {
29 | this.out = (out instanceof PrintStream) ? (PrintStream) out : new PrintStream(out);
30 | this.in = new BufferedReader(new InputStreamReader(in));
31 | }
32 |
33 | @Override
34 | public String selectVersion(String projectIdentifier, VersionFieldType versionFieldType, String ourVersion, String theirVersion) {
35 |
36 | out.printf("%n%s version conflict found in pom file for %s.%n%n",
37 | versionFieldType == VersionFieldType.PROJECT ? "Project" : "Parent",
38 | projectIdentifier);
39 |
40 | out.println("Select the version to use to resolve the conflict:");
41 | out.println();
42 |
43 | out.printf(" 1) %s (ours)%n", ourVersion);
44 | out.printf(" 2) %s (theirs)%n", theirVersion);
45 | out.println(" s) Skip and resolve later");
46 | out.println();
47 |
48 | out.println("If the same conflict is found in other pom files in this merge");
49 | out.println("or any future merges that occur in the next 2 minutes),");
50 | out.println("your selection will be used for them as well.");
51 | out.println();
52 |
53 | try {
54 | do {
55 | out.printf("Preferred version? [1/2/s]: ");
56 | out.flush();
57 |
58 | String selection = in.readLine();
59 |
60 | if (selection == null || selection.equalsIgnoreCase("s")) {
61 | out.println();
62 | return null;
63 | } else if (selection.trim().equalsIgnoreCase("1") || selection.trim().equals(ourVersion)) {
64 | return ourVersion;
65 | } else if (selection.trim().equalsIgnoreCase("2") || selection.trim().equals(theirVersion)) {
66 | return theirVersion;
67 | }
68 |
69 | } while (true);
70 | } catch (IOException e) {
71 | throw new RuntimeException();
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/TheirVersionSelector.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import de.oppermann.pomutils.util.VersionFieldType;
4 |
5 | /**
6 | * Always select 'their' version.
7 | */
8 | public class TheirVersionSelector implements VersionSelector {
9 |
10 | @Override
11 | public String selectVersion(String projectIdentifier, VersionFieldType versionFieldType, String ourVersion, String theirVersion) {
12 | return theirVersion;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/select/VersionSelector.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import de.oppermann.pomutils.util.VersionFieldType;
4 |
5 | /**
6 | * Callback used to select a version.
7 | */
8 | public interface VersionSelector {
9 |
10 | /**
11 | * Selects the version to use to resolve a version conflict.
12 | *
13 | * @param projectIdentifier Human-readable string used to identify the pom project.
14 | * @param versionFieldType type of version field where the conflict was found.
15 | * @param ourVersion version of 'our' pom file
16 | * @param theirVersion version of 'their' pom file
17 | * @return the version to use to resolve the conflict. (either ourVersion, theirVersion, or null)
18 | * if null, then the conflict will not be resolved.
19 | */
20 | String selectVersion(String projectIdentifier, VersionFieldType versionFieldType, String ourVersion, String theirVersion);
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/util/ManifestUtils.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.util;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | /**
24 | *
25 | * @author Sven Oppermann
26 | *
27 | */
28 |
29 | public class ManifestUtils {
30 |
31 | public static String getImplementationVersion() {
32 | String version = ManifestUtils.class.getPackage().getImplementationVersion();
33 | return (version == null)
34 | ? "Unknown (not a jar)"
35 | : version;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/util/POM.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.util;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 | import java.util.Properties;
27 | import java.util.regex.Pattern;
28 |
29 | import javax.xml.stream.FactoryConfigurationError;
30 | import javax.xml.stream.XMLInputFactory;
31 | import javax.xml.stream.XMLStreamException;
32 |
33 | import org.apache.maven.model.Model;
34 | import org.apache.maven.model.Profile;
35 | import org.codehaus.mojo.versions.api.PomHelper;
36 | import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
37 | import org.codehaus.plexus.util.FileUtils;
38 | import org.codehaus.stax2.XMLInputFactory2;
39 | import org.slf4j.Logger;
40 | import org.slf4j.LoggerFactory;
41 |
42 | import com.ctc.wstx.stax.WstxInputFactory;
43 |
44 | /**
45 | *
46 | * @author Sven Oppermann
47 | *
48 | * this class is a wrapper class to the version-maven-plugin
49 | *
50 | */
51 | public class POM {
52 |
53 | private static final XMLInputFactory XML_INPUT_FACTORY = initializeXmlInputFactory();
54 |
55 | private final Logger logger = LoggerFactory.getLogger(POM.class);
56 |
57 | private File pomFile;
58 | private ModifiedPomXMLEventReader pom;
59 |
60 | /**
61 | * did we changed the pom?
62 | */
63 | private boolean changed = false;
64 |
65 | private String projectVersion;
66 | private String parentVersion;
67 | private String projectIdentifier;
68 | private String scmTag;
69 | private Model rawModel;
70 |
71 | public POM(String pomFileAsString) throws IOException, XMLStreamException {
72 | pomFile = new File(pomFileAsString);
73 | if (!pomFile.exists()) {
74 | throw new IllegalArgumentException("File [" + pomFile.getAbsolutePath() + "] not found.");
75 | }
76 |
77 | if (pomFile.length() == 0L) {
78 | /*
79 | * If we use git merge --allow-unrelated-histories, the base pom file
80 | * can be empty, so it cannot be parsed
81 | */
82 | rawModel = null;
83 | projectIdentifier = null;
84 | projectVersion = "";
85 | parentVersion = "";
86 | scmTag = "";
87 | return;
88 | }
89 |
90 | initialize();
91 | }
92 |
93 | private static XMLInputFactory initializeXmlInputFactory()
94 | throws FactoryConfigurationError {
95 | XMLInputFactory inputFactory = new WstxInputFactory();
96 | inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE);
97 | return inputFactory;
98 | }
99 |
100 | private void initialize() throws IOException, XMLStreamException {
101 | StringBuilder input = new StringBuilder(FileUtils.fileRead(pomFile));
102 | pom = new ModifiedPomXMLEventReader(input, XML_INPUT_FACTORY);
103 | rawModel = PomHelper.getRawModel(pom);
104 | projectIdentifier = calculateProjectIdentifier();
105 | projectVersion = rawModel.getVersion();
106 | parentVersion = rawModel.getParent() != null
107 | ? rawModel.getParent().getVersion()
108 | : null;
109 | scmTag = rawModel.getScm() != null
110 | ? rawModel.getScm().getTag()
111 | : null;
112 | }
113 |
114 | private String calculateProjectIdentifier() {
115 | String groupId = rawModel.getGroupId();
116 | String parentGroupId = rawModel.getParent() != null ? rawModel.getParent().getGroupId() : null;
117 | String artifactId = rawModel.getArtifactId();
118 | String projectName = rawModel.getName();
119 |
120 | StringBuilder identifier = new StringBuilder(64);
121 |
122 | if (projectName != null) {
123 | identifier.append(projectName);
124 | identifier.append(" (");
125 | }
126 |
127 | if (groupId != null) {
128 | identifier.append(groupId);
129 | identifier.append(":");
130 | } else if (parentGroupId != null) {
131 | identifier.append(parentGroupId);
132 | identifier.append(":");
133 | }
134 |
135 | if (artifactId != null) {
136 | identifier.append(artifactId);
137 | }
138 |
139 | if (projectName != null) {
140 | identifier.append(")");
141 | }
142 |
143 | return identifier.toString();
144 | }
145 |
146 | /**
147 | *
148 | * @return the version and null if the project version doesn't exist
149 | */
150 | public String getProjectVersion() {
151 | return projectVersion;
152 | }
153 |
154 | /**
155 | *
156 | * @return the version of the parent, null if there is no parent
157 | */
158 | public String getParentVersion() {
159 | return parentVersion;
160 | }
161 |
162 | /**
163 | * Gets an identifier that can be used for logging/prompting.
164 | */
165 | public String getProjectIdentifier() {
166 | return projectIdentifier;
167 | }
168 |
169 | /**
170 | *
171 | * @return the SCM tag or null if the SCM tag is unset
172 | */
173 | public String getScmTag() {
174 | return scmTag;
175 | }
176 |
177 | /**
178 | * Sets the parent version to the given one, if it exists
179 | * @param newVersion
180 | */
181 | public void setParentVersion(String newVersion) {
182 | if (this.parentVersion == null || this.parentVersion.equals(newVersion)) {
183 | return;
184 | }
185 | logger.debug("Adjusting parent version from [{}] to [{}] of [{}] for [{}]", this.parentVersion, newVersion, getPath(), this.projectIdentifier);
186 | this.parentVersion = newVersion;
187 | this.changed = true;
188 | }
189 |
190 | /**
191 | * Sets the project version to the given one, if it exists
192 | * @param newVersion
193 | */
194 | public void setProjectVersion(String newVersion) {
195 | if (this.projectVersion == null || this.projectVersion.equals(newVersion)) {
196 | return;
197 | }
198 | logger.debug("Adjusting project version from [{}] to [{}] of [{}] for [{}]", this.projectVersion, newVersion, getPath(), this.projectIdentifier);
199 | this.projectVersion = newVersion;
200 | this.changed = true;
201 |
202 | }
203 |
204 | /**
205 | * Sets the SCM tag to the given one, if it exists
206 | * @param newScmTag
207 | */
208 | public void setScmTag(String newScmTag) {
209 | if (this.scmTag == null || this.scmTag.equals(newScmTag)) {
210 | return;
211 | }
212 | logger.debug("Adjusting scm tag from [{}] to [{}] of [{}] for [{}]", this.scmTag, newScmTag, getPath(), this.projectIdentifier);
213 | this.scmTag = newScmTag;
214 | this.changed = true;
215 |
216 | }
217 |
218 | /**
219 | * Saves the pom, if it was changed.
220 | */
221 | public void savePom() throws IOException, XMLStreamException {
222 | if (!changed) {
223 | return;
224 | }
225 |
226 | if (this.projectVersion != null) {
227 | changed |= PomHelper.setProjectVersion(pom, this.projectVersion);
228 | }
229 |
230 | if (this.parentVersion != null) {
231 | changed |= PomHelper.setProjectParentVersion(pom, this.parentVersion);
232 | }
233 |
234 | if (this.scmTag != null) {
235 | changed |= PomHelper.setProjectValue(pom, "/project/scm/tag", this.scmTag);
236 | }
237 |
238 | if (!changed) {
239 | return;
240 | }
241 |
242 | FileUtils.fileWrite(pomFile.getAbsolutePath(), pom.asStringBuilder().toString());
243 | }
244 |
245 | /**
246 | *
247 | * @return the pom file path
248 | */
249 | public String getPath() {
250 | return pomFile.getPath();
251 | }
252 |
253 | public String getProfileProperty(String profileId, String property) {
254 | Properties properties = getProfileProperties(profileId);
255 | return properties.getProperty(property);
256 | }
257 |
258 | public Properties getProfileProperties(String profileId) {
259 | if (profileId == null) {
260 | throw new IllegalArgumentException("profileId is null");
261 | }
262 | for (Profile profile : getRawModel().getProfiles()) {
263 | if (profileId.equals(profile.getId())) {
264 | return profile.getProperties();
265 | }
266 | }
267 | return new Properties();
268 | }
269 |
270 | public Properties getProperties() {
271 | return getRawModel().getProperties();
272 | }
273 |
274 | public List getMatchingProperties(Pattern regex) {
275 | List propertyNames = new ArrayList();
276 | propertyNames.addAll(getGlobalPropertyNames());
277 | propertyNames.addAll(getProfilesPropertyNames());
278 |
279 | List matchingProperties = new ArrayList();
280 | for (String propertyName : propertyNames) {
281 | if (regex.matcher(propertyName).matches()) {
282 | matchingProperties.add(propertyName);
283 | }
284 | }
285 | return matchingProperties;
286 | }
287 |
288 | private List getGlobalPropertyNames() {
289 | List propertyNames = new ArrayList();
290 | propertyNames.addAll(getProperties().stringPropertyNames());
291 | return propertyNames;
292 | }
293 |
294 | private List getProfilesPropertyNames() {
295 | List propertyNames = new ArrayList();
296 | for (Profile profile : getProfiles()) {
297 | propertyNames.addAll(getProfileProperties(profile.getId()).stringPropertyNames());
298 | }
299 | return propertyNames;
300 | }
301 |
302 | public void setPropertyToValue(String property, String newPropertyValue) throws XMLStreamException, IOException {
303 | setPropertyToValue(null, property, newPropertyValue);
304 | }
305 |
306 | public void setPropertyToValue(String profileId, String property, String newPropertyValue) throws XMLStreamException, IOException {
307 | if (property == null) {
308 | logger.debug("Property is null, nothing to do.");
309 | return;
310 | }
311 | if (newPropertyValue == null) {
312 | logger.debug("newPropertyValue of property [{}] is null, nothing to do.", property);
313 | return;
314 | }
315 |
316 | if (profileId == null && newPropertyValue.equals(getProperties().getProperty(property))) {
317 | return;
318 | }
319 |
320 | if (profileId != null && newPropertyValue.equals(getProfileProperties(profileId).getProperty(property))) {
321 | return;
322 | }
323 |
324 | if (profileId == null) {
325 | logger.debug("Adjusting property [{}] from [{}] to [{}] of [{}]", property, getProperties().getProperty(property), newPropertyValue, getPath());
326 |
327 | } else {
328 | logger.debug("Adjusting property [{}] from [{}] to [{}] of profile [{}] of [{}]", property, getProperties().getProperty(property),
329 | newPropertyValue,
330 | profileId, getPath());
331 | }
332 | boolean propertyChanged = PomHelper.setPropertyVersion(pom, profileId, property, newPropertyValue);
333 | if (propertyChanged) {
334 | changed = true;
335 | rawModel = PomHelper.getRawModel(pom);
336 | }
337 | }
338 |
339 | public List getProfiles() {
340 | return getRawModel().getProfiles();
341 | }
342 |
343 | private Model getRawModel() {
344 | return rawModel;
345 | }
346 |
347 | }
348 |
--------------------------------------------------------------------------------
/src/main/java/de/oppermann/pomutils/util/VersionFieldType.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.util;
2 |
3 | /**
4 | * Type of version field.
5 | */
6 | public enum VersionFieldType {
7 | PROJECT {
8 | @Override
9 | public String get(POM pom) {
10 | return pom.getProjectVersion();
11 | }
12 |
13 | @Override
14 | public void set(POM pom, String newVersion) {
15 | pom.setProjectVersion(newVersion);
16 | }
17 |
18 | },
19 | PARENT {
20 | @Override
21 | public String get(POM pom) {
22 | return pom.getParentVersion();
23 | }
24 |
25 | @Override
26 | public void set(POM pom, String newVersion) {
27 | pom.setParentVersion(newVersion);
28 | }
29 |
30 | };
31 |
32 | public abstract String get(POM pom);
33 |
34 | public abstract void set(POM pom, String newVersion);
35 | }
--------------------------------------------------------------------------------
/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TRACE
5 |
6 |
7 | %green(%d{HH:mm:ss.SSS}) [%30.30thread] [%mdc{request.id:-noRequestId}] %highlight(%-5level) %cyan(%40.40logger:%-4.4line) - %msg%n
8 |
9 |
10 |
12 |
13 | TRACE
14 |
15 | /busdata/batch/tid_mod_cus/log/tid_mod_cus.log
16 |
17 | /busdata/batch/tid_mod_cus/log/tid_mod_cus.log.%d{yyyy-MM-dd}.%i
18 | 32MB
19 | 90
20 | 1GB
21 |
22 |
23 | %d{ISO8601} %-5level [%10.10thread] [%mdc{request.id:-noRequestId}] %-50.50logger:%-4.4line - %msg%n
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/ConfigTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import junit.framework.TestCase;
23 |
24 | /**
25 | *
26 | * @author Sven Oppermann
27 | *
28 | */
29 | public class ConfigTest extends TestCase {
30 |
31 | public void testConfig() throws Exception {
32 | // todo
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/IssuesTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 |
24 | import org.codehaus.mojo.versions.api.PomHelper;
25 |
26 | import de.oppermann.pomutils.rules.Ruleset;
27 | import de.oppermann.pomutils.select.SelectionStrategy;
28 | import de.oppermann.pomutils.util.POM;
29 | import junit.framework.TestCase;
30 |
31 | /**
32 | *
33 | * @author Sven Oppermann
34 | *
35 | */
36 |
37 | public class IssuesTest extends TestCase {
38 |
39 | @Override
40 | protected void setUp() throws Exception {
41 | super.setUp();
42 | System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
43 | }
44 |
45 | public void testIssue15() throws Exception {
46 | String myTestSubFolder = "merge/issues/#15";
47 |
48 | TestUtils.prepareTestFolder(myTestSubFolder);
49 |
50 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
51 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
52 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
53 |
54 | Ruleset ruleset = new Ruleset(SelectionStrategy.OUR);
55 |
56 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
57 | int mergeReturnValue = pomMergeDriver.merge();
58 |
59 | assertTrue("merge succeeded", mergeReturnValue == 0);
60 |
61 | POM theirPom = new POM(theirPomFile);
62 | POM ourPom = new POM(ourPomFile);
63 |
64 | assertEquals("our", ourPom.getProjectVersion());
65 | assertEquals("our", theirPom.getProjectVersion());
66 |
67 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0)
68 | .getVersion();
69 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
70 |
71 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/MainCallTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import junit.framework.TestCase;
23 |
24 | /**
25 | *
26 | * @author Sven Oppermann
27 | *
28 | */
29 |
30 | public class MainCallTest extends TestCase {
31 |
32 | public void testMergeCommandWithoutRuleset() throws Exception {
33 | String myTestSubFolder = "mainCall/withoutRuleset";
34 |
35 | TestUtils.prepareTestFolder(myTestSubFolder);
36 |
37 | String[] args = {
38 | "merge"
39 | , "--our=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml"
40 | , "--base=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml"
41 | , "--their=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml" };
42 |
43 | assertEquals(0, Main.mainInternal(args));
44 | }
45 |
46 | public void testMergeCommandWithRuleset() throws Exception {
47 | String myTestSubFolder = "mainCall/withRuleset";
48 |
49 | TestUtils.prepareTestFolder(myTestSubFolder);
50 |
51 | String[] args = {
52 | "merge"
53 | , "--ruleset=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml"
54 | , "--our=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml"
55 | , "--base=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml"
56 | , "--their=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml" };
57 |
58 | assertEquals(0, Main.mainInternal(args));
59 | }
60 |
61 | public void testReplaceCommand() throws Exception {
62 | String myTestSubFolder = "mainCall/versionReplace";
63 |
64 | TestUtils.prepareTestFolder(myTestSubFolder);
65 | String[] args = {
66 | "replace"
67 | , "--pom=" + TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/replace.pom.xml"
68 | , "--version=\"5.0\"" };
69 |
70 | assertEquals(0, Main.mainInternal(args));
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/PomMergeDriverTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 |
24 | import junit.framework.TestCase;
25 |
26 | import org.apache.commons.io.FileUtils;
27 | import org.codehaus.mojo.versions.api.PomHelper;
28 | import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
29 |
30 | import com.ctc.wstx.stax.WstxInputFactory;
31 |
32 | import de.oppermann.pomutils.rules.Ruleset;
33 | import de.oppermann.pomutils.select.SelectionStrategy;
34 | import de.oppermann.pomutils.util.POM;
35 |
36 | /**
37 | *
38 | * @author Sven Oppermann
39 | *
40 | */
41 |
42 | public class PomMergeDriverTest extends TestCase {
43 |
44 | @Override
45 | protected void setUp() throws Exception {
46 | super.setUp();
47 | System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
48 | }
49 |
50 | public void testAutoMergeSucceded() throws Exception {
51 | String myTestSubFolder = "merge/autoMergeSucceded";
52 |
53 | TestUtils.prepareTestFolder(myTestSubFolder);
54 |
55 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
56 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
57 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
58 |
59 | Ruleset ruleset = new Ruleset(SelectionStrategy.OUR);
60 |
61 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
62 | int mergeReturnValue = pomMergeDriver.merge();
63 |
64 | assertTrue("merge succeeded", mergeReturnValue == 0);
65 |
66 | POM theirPom = new POM(theirPomFile);
67 | POM ourPom = new POM(ourPomFile);
68 |
69 | assertEquals("our", ourPom.getProjectVersion());
70 | assertEquals("our", theirPom.getProjectVersion());
71 |
72 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
73 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
74 |
75 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
76 | }
77 |
78 | public void testAutoMergeSucceded_their() throws Exception {
79 | String myTestSubFolder = "merge/autoMergeSucceded_their";
80 |
81 | TestUtils.prepareTestFolder(myTestSubFolder);
82 |
83 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
84 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
85 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
86 |
87 | Ruleset ruleset = new Ruleset(SelectionStrategy.THEIR);
88 |
89 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
90 | int mergeReturnValue = pomMergeDriver.merge();
91 |
92 | assertTrue("merge succeeded", mergeReturnValue == 0);
93 |
94 | POM theirPom = new POM(theirPomFile);
95 | POM ourPom = new POM(ourPomFile);
96 |
97 | assertEquals("their", ourPom.getProjectVersion());
98 | assertEquals("their", theirPom.getProjectVersion());
99 |
100 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
101 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
102 |
103 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
104 | }
105 |
106 | public void testAutoMergeSucceded_noConflict_our() throws Exception {
107 | String myTestSubFolder = "merge/autoMergeSucceded_noConflict_our";
108 |
109 | TestUtils.prepareTestFolder(myTestSubFolder);
110 |
111 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
112 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
113 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
114 |
115 | Ruleset ruleset = new Ruleset(SelectionStrategy.PROMPT);
116 |
117 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
118 | int mergeReturnValue = pomMergeDriver.merge();
119 |
120 | assertTrue("merge succeeded", mergeReturnValue == 0);
121 |
122 | POM theirPom = new POM(theirPomFile);
123 | POM ourPom = new POM(ourPomFile);
124 |
125 | assertEquals("our", ourPom.getProjectVersion());
126 | assertEquals("our", theirPom.getProjectVersion());
127 |
128 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
129 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
130 |
131 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
132 | }
133 |
134 | public void testAutoMergeSucceded_noConflict_their() throws Exception {
135 | String myTestSubFolder = "merge/autoMergeSucceded_noConflict_their";
136 |
137 | TestUtils.prepareTestFolder(myTestSubFolder);
138 |
139 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
140 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
141 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
142 |
143 | Ruleset ruleset = new Ruleset(SelectionStrategy.PROMPT);
144 |
145 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
146 | int mergeReturnValue = pomMergeDriver.merge();
147 |
148 | assertTrue("merge succeeded", mergeReturnValue == 0);
149 |
150 | POM theirPom = new POM(theirPomFile);
151 | POM ourPom = new POM(ourPomFile);
152 |
153 | assertEquals("their", ourPom.getProjectVersion());
154 | assertEquals("their", theirPom.getProjectVersion());
155 |
156 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
157 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
158 |
159 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
160 | }
161 |
162 | public void testAutoMergeSucceded_prompt() throws Exception {
163 | String myTestSubFolder = "merge/autoMergeSucceded_prompt";
164 |
165 | TestUtils.prepareTestFolder(myTestSubFolder);
166 |
167 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
168 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
169 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
170 |
171 | Ruleset ruleset = new Ruleset(SelectionStrategy.THEIR);
172 |
173 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
174 | int mergeReturnValue = pomMergeDriver.merge();
175 |
176 | assertTrue("merge succeeded", mergeReturnValue == 0);
177 | POM theirPom = new POM(theirPomFile);
178 | POM ourPom = new POM(ourPomFile);
179 |
180 | assertEquals("their", ourPom.getParentVersion());
181 | assertEquals("their", theirPom.getParentVersion());
182 |
183 | String theirDependecyVersoin = PomHelper.getRawModel(new File(theirPomFile)).getDependencies().get(0).getVersion();
184 | String ourDependencyVersion = PomHelper.getRawModel(new File(ourPomFile)).getDependencies().get(0).getVersion();
185 |
186 | assertEquals("dependency version change merged", theirDependecyVersoin, ourDependencyVersion);
187 | }
188 |
189 | public void testAutoMergeFailed() throws Exception {
190 | String myTestSubFolder = "merge/autoMergeFailed";
191 |
192 | TestUtils.prepareTestFolder(myTestSubFolder);
193 |
194 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
195 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
196 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
197 |
198 | Ruleset ruleset = new Ruleset(SelectionStrategy.OUR);
199 |
200 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
201 | int mergeReturnValue = pomMergeDriver.merge();
202 |
203 | assertTrue("merge conflict", mergeReturnValue == 1);
204 |
205 | POM theirPom = new POM(theirPomFile);
206 |
207 | StringBuilder ourPomString = new StringBuilder(FileUtils.readFileToString(new File(ourPomFile)));
208 | String ourProjectVersion = PomHelper.getProjectVersion(new ModifiedPomXMLEventReader(ourPomString, new WstxInputFactory()));
209 |
210 | assertEquals("same version now", ourProjectVersion, theirPom.getProjectVersion());
211 | }
212 |
213 | public void testAutoMergeWithNoBaseCommit() throws Exception {
214 | String myTestSubFolder = "merge/autoMergeSucceded_noConflict_their";
215 |
216 | TestUtils.prepareTestFolder(myTestSubFolder);
217 |
218 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
219 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
220 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
221 |
222 | Ruleset ruleset = new Ruleset(SelectionStrategy.THEIR);
223 |
224 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
225 | int mergeReturnValue = pomMergeDriver.merge();
226 |
227 | assertTrue("merge succeeded", mergeReturnValue == 0);
228 |
229 | POM theirPom = new POM(theirPomFile);
230 | POM ourPom = new POM(ourPomFile);
231 |
232 | assertEquals("their", ourPom.getProjectVersion());
233 | assertEquals("their", theirPom.getProjectVersion());
234 | }
235 |
236 | }
237 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/RulesetTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | import java.io.File;
4 |
5 | import junit.framework.TestCase;
6 | import de.oppermann.pomutils.rules.Ruleset;
7 | import de.oppermann.pomutils.util.POM;
8 |
9 | /*
10 | * Licensed to the Apache Software Foundation (ASF) under one
11 | * or more contributor license agreements. See the NOTICE file
12 | * distributed with this work for additional information
13 | * regarding copyright ownership. The ASF licenses this file
14 | * to you under the Apache License, Version 2.0 (the
15 | * "License"); you may not use this file except in compliance
16 | * with the License. You may obtain a copy of the License at
17 | *
18 | * http://www.apache.org/licenses/LICENSE-2.0
19 | *
20 | * Unless required by applicable law or agreed to in writing,
21 | * software distributed under the License is distributed on an
22 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 | * KIND, either express or implied. See the License for the
24 | * specific language governing permissions and limitations
25 | * under the License.
26 | */
27 |
28 | /**
29 | *
30 | * @author Sven Oppermann
31 | *
32 | */
33 | public class RulesetTest extends TestCase {
34 |
35 | @Override
36 | protected void setUp() throws Exception {
37 | super.setUp();
38 | System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
39 | }
40 |
41 | public void testProjectAndParentVersionWithOurStrategy() throws Exception {
42 | String myTestSubFolder = "rulesets/rulesetProjectAndParentVersion/ourStrategy";
43 |
44 | TestUtils.prepareTestFolder(myTestSubFolder);
45 |
46 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
47 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
48 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
49 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
50 |
51 | String versionBeforeMerge = new POM(ourPomFile).getProjectVersion();
52 | Ruleset ruleset = new Ruleset(rulesetFile);
53 |
54 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
55 |
56 | assertTrue("merge succeeded", mergeReturnValue == 0);
57 |
58 | POM theirPom = new POM(theirPomFile);
59 | POM ourPom = new POM(ourPomFile);
60 |
61 | assertEquals("same version now", ourPom.getProjectVersion(), theirPom.getProjectVersion());
62 | assertEquals("our version should win", versionBeforeMerge, ourPom.getProjectVersion());
63 | }
64 |
65 | public void testProjectAndParentVersionWithTheirsStrategy() throws Exception {
66 | String myTestSubFolder = "rulesets/rulesetProjectAndParentVersion/theirStrategy";
67 |
68 | TestUtils.prepareTestFolder(myTestSubFolder);
69 |
70 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
71 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
72 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
73 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
74 |
75 | String versionBeforeMerge = new POM(theirPomFile).getProjectVersion();
76 | Ruleset ruleset = new Ruleset(rulesetFile);
77 |
78 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
79 |
80 | assertTrue("merge succeeded", mergeReturnValue == 0);
81 |
82 | POM theirPom = new POM(theirPomFile);
83 | POM ourPom = new POM(ourPomFile);
84 |
85 | assertEquals("same version now", ourPom.getProjectVersion(), theirPom.getProjectVersion());
86 | assertEquals("their version should win", versionBeforeMerge, ourPom.getProjectVersion());
87 | }
88 |
89 | private int doMerge(Ruleset ruleset, String basePomFile, String ourPomFile, String theirPomFile) {
90 | PomMergeDriver pomMergeDriver = new PomMergeDriver(ruleset, basePomFile, ourPomFile, theirPomFile);
91 | return pomMergeDriver.merge();
92 | }
93 |
94 | public void testPropertyRuleWithOurStrategy() throws Exception {
95 | String myTestSubFolder = "rulesets/rulesetPropertyRule/ourStrategy";
96 |
97 | TestUtils.prepareTestFolder(myTestSubFolder);
98 |
99 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
100 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
101 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
102 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
103 |
104 | String foobarPropertyExpectedResult = new POM(ourPomFile).getProperties().getProperty("foobar");
105 | String foobarVersionPropertyExpectedResult = new POM(ourPomFile).getProperties().getProperty("foobar.version");
106 | String jdbcBaseUrlExpectedResult = new POM(ourPomFile).getProperties().getProperty("jdbc.base.url");
107 | String regexVersionPropertyExpectedResult = new POM(ourPomFile).getProfileProperties("regex").getProperty("regex.version");
108 | Ruleset ruleset = new Ruleset(rulesetFile);
109 |
110 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
111 |
112 | assertTrue("merge succeeded", mergeReturnValue == 0);
113 |
114 | POM theirPom = new POM(theirPomFile);
115 | POM ourPom = new POM(ourPomFile);
116 |
117 | assertEquals(" property same content now", ourPom.getProperties().getProperty("foobar"), theirPom.getProperties().getProperty("foobar"));
118 | assertEquals(" property same content now", ourPom.getProperties().getProperty("jdbc.base.url"),
119 | theirPom.getProperties().getProperty("jdbc.base.url"));
120 | assertEquals("our version of should win", foobarPropertyExpectedResult, ourPom.getProperties().getProperty("foobar"));
121 | assertEquals("our version of should win", foobarVersionPropertyExpectedResult, ourPom.getProperties().getProperty("foobar.version"));
122 | assertEquals("our version of should win", jdbcBaseUrlExpectedResult, ourPom.getProperties().getProperty("jdbc.base.url"));
123 |
124 | assertNull("property in profile should not exist", ourPom.getProfileProperties("develop").getProperty("foobar"));
125 | assertEquals("property in profile should be empty", "", ourPom.getProfileProperties("delivery").getProperty("foobar"));
126 |
127 | assertEquals("our version of in profile should win", jdbcBaseUrlExpectedResult, ourPom.getProfileProperties("develop")
128 | .getProperty("jdbc.base.url"));
129 | assertEquals(" of profile should be empty", "", ourPom.getProfileProperties("delivery")
130 | .getProperty("jdbc.base.url"));
131 | assertEquals("our version of in profile should win", regexVersionPropertyExpectedResult, ourPom.getProfileProperties("regex")
132 | .getProperty("regex.version"));
133 | }
134 |
135 | public void testPropertyRuleWithTheirStrategy() throws Exception {
136 | String myTestSubFolder = "rulesets/rulesetPropertyRule/theirStrategy";
137 |
138 | TestUtils.prepareTestFolder(myTestSubFolder);
139 |
140 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
141 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
142 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
143 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
144 |
145 | String foobarPropertyExpectedResult = new POM(theirPomFile).getProperties().getProperty("foobar");
146 | String foobarVersionPropertyExpectedResult = new POM(theirPomFile).getProperties().getProperty("foobar.version");
147 | String jdbcBaseUrlExpectedResult = new POM(theirPomFile).getProperties().getProperty("jdbc.base.url");
148 | String regexVersionPropertyExpectedResult = new POM(theirPomFile).getProfileProperties("regex").getProperty("regex.version");
149 | Ruleset ruleset = new Ruleset(rulesetFile);
150 |
151 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
152 |
153 | assertTrue("merge succeeded", mergeReturnValue == 0);
154 |
155 | POM theirPom = new POM(theirPomFile);
156 | POM ourPom = new POM(ourPomFile);
157 |
158 | assertEquals(" property same content now", theirPom.getProperties().getProperty("foobar"), ourPom.getProperties().getProperty("foobar"));
159 | assertEquals(" property same content now",
160 | theirPom.getProperties().getProperty("jdbc.base.url"), ourPom.getProperties().getProperty("jdbc.base.url"));
161 | assertEquals("their version of should win", foobarPropertyExpectedResult, ourPom.getProperties().getProperty("foobar"));
162 | assertEquals("their version of should win", foobarVersionPropertyExpectedResult, ourPom.getProperties().getProperty("foobar.version"));
163 | assertEquals("their version of should win", jdbcBaseUrlExpectedResult, ourPom.getProperties().getProperty("jdbc.base.url"));
164 |
165 | assertNull("property in profile should not exist", ourPom.getProfileProperties("develop").getProperty("foobar"));
166 | assertEquals("property in profile should be empty", "", ourPom.getProfileProperties("delivery").getProperty("foobar"));
167 |
168 | assertEquals("their version of in profile should win", jdbcBaseUrlExpectedResult, ourPom.getProfileProperties("develop")
169 | .getProperty("jdbc.base.url"));
170 | assertEquals(" of profile should be empty", "", ourPom.getProfileProperties("delivery")
171 | .getProperty("jdbc.base.url"));
172 | assertEquals("their version of in profile should win", regexVersionPropertyExpectedResult, ourPom.getProfileProperties("regex")
173 | .getProperty("regex.version"));
174 | }
175 |
176 | public void testScmTagWithOurStrategy() throws Exception {
177 | String myTestSubFolder = "rulesets/rulesetScmTag/ourStrategy";
178 |
179 | TestUtils.prepareTestFolder(myTestSubFolder);
180 |
181 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
182 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
183 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
184 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
185 |
186 | String scmTagBeforeMerge = new POM(ourPomFile).getScmTag();
187 | Ruleset ruleset = new Ruleset(rulesetFile);
188 |
189 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
190 |
191 | assertTrue("merge succeeded", mergeReturnValue == 0);
192 |
193 | POM theirPom = new POM(theirPomFile);
194 | POM ourPom = new POM(ourPomFile);
195 |
196 | assertEquals("same version now", ourPom.getScmTag(), theirPom.getScmTag());
197 | assertEquals("our version should win", scmTagBeforeMerge, ourPom.getScmTag());
198 | }
199 |
200 | public void testScmTagWithTheirsStrategy() throws Exception {
201 | String myTestSubFolder = "rulesets/rulesetScmTag/theirStrategy";
202 |
203 | TestUtils.prepareTestFolder(myTestSubFolder);
204 |
205 | File rulesetFile = new File(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/ruleset.yaml");
206 | String basePomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/base.pom.xml";
207 | String ourPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/our.pom.xml";
208 | String theirPomFile = TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/their.pom.xml";
209 |
210 | String scmTagBeforeMerge = new POM(theirPomFile).getScmTag();
211 | Ruleset ruleset = new Ruleset(rulesetFile);
212 |
213 | int mergeReturnValue = doMerge(ruleset, basePomFile, ourPomFile, theirPomFile);
214 |
215 | assertTrue("merge succeeded", mergeReturnValue == 0);
216 |
217 | POM theirPom = new POM(theirPomFile);
218 | POM ourPom = new POM(ourPomFile);
219 |
220 | assertEquals("same version now", ourPom.getScmTag(), theirPom.getScmTag());
221 | assertEquals("their version should win", scmTagBeforeMerge, ourPom.getScmTag());
222 | }
223 |
224 | }
225 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/TestUtils.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 |
25 | import org.apache.commons.io.FileUtils;
26 |
27 | /**
28 | *
29 | * @author Sven Oppermann
30 | *
31 | */
32 | public class TestUtils {
33 |
34 | public static final String resourceBaseTestFolder = "target/testresources";
35 |
36 | public static void prepareTestFolder(String subFolder) throws IOException {
37 | String targetFolder = resourceBaseTestFolder + "/" + subFolder;
38 | File targetFolderFile = new File(targetFolder);
39 | FileUtils.deleteDirectory(targetFolderFile);
40 | FileUtils.copyDirectory(new File("src/test/resources/" + subFolder), targetFolderFile);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/VersionReplaceTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils;
2 |
3 | /*
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 |
25 | import javax.xml.stream.XMLStreamException;
26 |
27 | import junit.framework.TestCase;
28 |
29 | import org.apache.commons.io.FileUtils;
30 |
31 | import de.oppermann.pomutils.util.POM;
32 |
33 | /**
34 | *
35 | * @author Sven Oppermann
36 | *
37 | */
38 |
39 | public class VersionReplaceTest extends TestCase {
40 |
41 | @Override
42 | protected void setUp() throws Exception {
43 | super.setUp();
44 | System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "ERROR");
45 |
46 | File testTargetResourceFolder = new File("target/testresources/versionReplacer");
47 | FileUtils.deleteDirectory(testTargetResourceFolder);
48 | FileUtils.copyDirectory(new File("src/test/resources/versionReplacer"), testTargetResourceFolder);
49 | }
50 |
51 | private POM adjustPomToVersion(String pomToAdjust, String newVersion) throws IOException, XMLStreamException {
52 | PomVersionReplacer pomVersionReplacer = new PomVersionReplacer(pomToAdjust);
53 | pomVersionReplacer.setVersionTo(newVersion);
54 |
55 | return new POM(pomToAdjust);
56 | }
57 |
58 | public void testParentAndProjectVersionChange() throws Exception {
59 | String myTestSubFolder = "versionReplacer/parent.and.project.version";
60 | TestUtils.prepareTestFolder(myTestSubFolder);
61 |
62 | String newVersion = "5.0";
63 | POM resultPom = adjustPomToVersion(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/pom.xml", newVersion);
64 |
65 | assertTrue("parent version update succeeded", newVersion.equals(resultPom.getParentVersion()));
66 | assertTrue("project version update succeeded", newVersion.equals(resultPom.getProjectVersion()));
67 | }
68 |
69 | public void testParentVersionChange() throws Exception {
70 | String myTestSubFolder = "versionReplacer/parent.version";
71 | TestUtils.prepareTestFolder(myTestSubFolder);
72 |
73 | String newVersion = "5.0";
74 | POM resultPom = adjustPomToVersion(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/pom.xml", newVersion);
75 |
76 | assertTrue("parent version update succeeded", newVersion.equals(resultPom.getParentVersion()));
77 | assertNull("project version exists", resultPom.getProjectVersion());
78 | }
79 |
80 | public void testProjectVersionChange() throws Exception {
81 | String myTestSubFolder = "versionReplacer/project.version";
82 | TestUtils.prepareTestFolder(myTestSubFolder);
83 |
84 | String newVersion = "5.0";
85 | POM resultPom = adjustPomToVersion(TestUtils.resourceBaseTestFolder + "/" + myTestSubFolder + "/pom.xml", newVersion);
86 |
87 | assertNull("parent version exists", resultPom.getParentVersion());
88 | assertTrue("project version update succeeded", newVersion.equals(resultPom.getProjectVersion()));
89 | }
90 | }
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/select/PersistentVersionSelectorTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import static org.mockito.Mockito.verify;
4 | import static org.mockito.Mockito.when;
5 | import static org.junit.Assert.*;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 |
10 | import org.junit.Before;
11 | import org.junit.Rule;
12 | import org.junit.Test;
13 | import org.junit.rules.TemporaryFolder;
14 | import org.mockito.Mock;
15 | import org.mockito.junit.MockitoJUnit;
16 | import org.mockito.junit.MockitoRule;
17 |
18 | import de.oppermann.pomutils.util.VersionFieldType;
19 |
20 | public class PersistentVersionSelectorTest {
21 |
22 | @Rule
23 | public TemporaryFolder tempFolder = new TemporaryFolder();
24 |
25 | private File tempFile;
26 |
27 | @Rule
28 | public MockitoRule mockitoRule = MockitoJUnit.rule();
29 |
30 | @Mock
31 | private VersionSelector delegateSelector;
32 |
33 | private PersistentVersionSelector persistentSelector;
34 |
35 | @Before
36 | public void setup() throws IOException {
37 | tempFile = tempFolder.newFile();
38 | persistentSelector = new PersistentVersionSelector(delegateSelector, tempFile);
39 | }
40 |
41 |
42 | @Test
43 | public void testFileDoesNotExist() throws IOException {
44 | tempFile.delete();
45 | when(delegateSelector.selectVersion("id", VersionFieldType.PROJECT, "our", "their")).thenReturn("our");
46 | assertEquals("our", persistentSelector.selectVersion("id", VersionFieldType.PROJECT, "our", "their"));
47 |
48 | assertEquals("our", persistentSelector.selectVersion("id", VersionFieldType.PROJECT, "our", "their"));
49 |
50 | verify(delegateSelector).selectVersion("id", VersionFieldType.PROJECT, "our", "their");
51 | }
52 |
53 | @Test
54 | public void testSkip() throws IOException {
55 | assertNull(persistentSelector.selectVersion("id", VersionFieldType.PROJECT, "our", "their"));
56 |
57 | assertNull(persistentSelector.selectVersion("id", VersionFieldType.PROJECT, "our", "their"));
58 |
59 | verify(delegateSelector).selectVersion("id", VersionFieldType.PROJECT, "our", "their");
60 | }
61 |
62 | @Test
63 | public void testSelect() throws IOException {
64 | when(delegateSelector.selectVersion("id", VersionFieldType.PARENT, "our", "their")).thenReturn("their");
65 | assertEquals("their", persistentSelector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
66 |
67 | assertEquals("their", persistentSelector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
68 |
69 | verify(delegateSelector).selectVersion("id", VersionFieldType.PARENT, "our", "their");
70 | }
71 |
72 | @Test
73 | public void testNotValid() throws IOException {
74 | when(delegateSelector.selectVersion("id", VersionFieldType.PARENT, "our", "their")).thenReturn("their");
75 | when(delegateSelector.selectVersion("id", VersionFieldType.PARENT, "our2", "their2")).thenReturn("our2");
76 |
77 | assertEquals("their", persistentSelector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
78 |
79 | assertEquals("our2", persistentSelector.selectVersion("id", VersionFieldType.PARENT, "our2", "their2"));
80 |
81 | verify(delegateSelector).selectVersion("id", VersionFieldType.PARENT, "our", "their");
82 | verify(delegateSelector).selectVersion("id", VersionFieldType.PARENT, "our2", "their2");
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/test/java/de/oppermann/pomutils/select/StreamVersionSelectorTest.java:
--------------------------------------------------------------------------------
1 | package de.oppermann.pomutils.select;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.io.ByteArrayInputStream;
6 | import java.io.ByteArrayOutputStream;
7 |
8 | import org.junit.Test;
9 |
10 | import de.oppermann.pomutils.util.VersionFieldType;
11 |
12 | public class StreamVersionSelectorTest {
13 |
14 | @Test
15 | public void testEndOfStream() {
16 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
17 | ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
18 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
19 | assertNull(selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
20 | }
21 |
22 | @Test
23 | public void testSkip() {
24 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
25 | ByteArrayInputStream bais = new ByteArrayInputStream("s\n".getBytes());
26 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
27 | assertNull(selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
28 | }
29 |
30 | @Test
31 | public void testOur() {
32 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
33 | ByteArrayInputStream bais = new ByteArrayInputStream("1\n".getBytes());
34 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
35 | assertEquals("our", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
36 | }
37 |
38 | @Test
39 | public void testOurFullVersion() {
40 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
41 | ByteArrayInputStream bais = new ByteArrayInputStream("our\n".getBytes());
42 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
43 | assertEquals("our", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
44 | }
45 |
46 | @Test
47 | public void testTheir() {
48 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
49 | ByteArrayInputStream bais = new ByteArrayInputStream("2\n".getBytes());
50 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
51 | assertEquals("their", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
52 | }
53 |
54 | @Test
55 | public void testTheirFullVersion() {
56 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
57 | ByteArrayInputStream bais = new ByteArrayInputStream("their\n".getBytes());
58 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
59 | assertEquals("their", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
60 | }
61 |
62 | @Test
63 | public void testTrim() {
64 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
65 | ByteArrayInputStream bais = new ByteArrayInputStream(" 2 \n".getBytes());
66 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
67 | assertEquals("their", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
68 | }
69 |
70 | @Test
71 | public void testUnknown() {
72 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
73 | ByteArrayInputStream bais = new ByteArrayInputStream("x\n2\n".getBytes());
74 | StreamVersionSelector selector = new StreamVersionSelector(baos, bais);
75 | assertEquals("their", selector.selectVersion("id", VersionFieldType.PARENT, "our", "their"));
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/test/resources/config/defaultconfig.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: OUR # possible values: OUR|THEIR|PROMPT
3 | # resolves all parent and project version conflicts, using the given strategy
4 |
5 | --- !!de.oppermann.pomutils.rules.PropertyRule
6 | strategy : OUR # possible values: OUR|THEIR
7 | properties: # the given properties will be resolved, using the given strategy
8 | - jdbc.user.name
9 | - foobar.version
10 |
11 | --- !!de.oppermann.pomutils.rules.DependencyVersionRule
12 | strategy: OUR # possible values: OUR|THEIR
13 | # this rule isn't implemented. I'm working on this.
14 | groupIds:
15 | - de.oppermann.pomutils: # all dependencies which have as groupId de.oppermann.pomutils will have automatic version resolution
16 | - org.codehaus.mojo: # all dependencies which have as groupId org.codehaus.mojo
17 | - versions-maven-plugin # and have one of the following artifactId's will have automatic version resolution
18 | - foo
19 |
20 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/versionReplace/replace.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | 0.1
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withRuleset/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withRuleset/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withRuleset/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: OUR
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withRuleset/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withoutRuleset/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withoutRuleset/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/mainCall/withoutRuleset/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeFailed/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeFailed/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeFailed/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 3.0
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_our/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_our/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_our/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_their/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_their/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_noConflict_their/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_prompt/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | de.oppermann.git.pommergedriver
5 | pommergedriver
6 | base
7 |
8 |
9 |
10 | org.codehaus.mojo
11 | versions-maven-plugin
12 | 2.1
13 | maven-plugin
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_prompt/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | de.oppermann.git.pommergedriver
5 | pommergedriver
6 | our
7 |
8 |
9 |
10 | org.codehaus.mojo
11 | versions-maven-plugin
12 | 2.1
13 | maven-plugin
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_prompt/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | de.oppermann.git.pommergedriver
5 | pommergedriver
6 | their
7 |
8 |
9 |
10 | org.codehaus.mojo
11 | versions-maven-plugin
12 | 2.5
13 | maven-plugin
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_their/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_their/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeSucceded_their/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeWithNoBaseCommit/base.pom.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cecom/pomutils/cf55a74fc66cce1066535fff171c8996fc161b47/src/test/resources/merge/autoMergeWithNoBaseCommit/base.pom.xml
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeWithNoBaseCommit/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/autoMergeWithNoBaseCommit/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.git.pommergedriver
4 | pommergedriver
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/merge/issues/#15/base.pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | x123
5 | x123
6 | base
7 | pom
8 |
9 |
10 |
11 | org.codehaus.mojo
12 | versions-maven-plugin
13 | 2.1
14 | maven-plugin
15 |
16 |
17 |
18 |
19 |
20 | 1.8
21 | 1.8
22 | UTF-8
23 | jdt_apt
24 |
25 |
26 | banana
27 | banana
28 | banana
29 | banana
30 | banana
31 | banana
32 | banana
33 | banana
34 | banana
35 | banana
36 | banana
37 | banana
38 | banana
39 | banana
40 | banana
41 | banana
42 | banana
43 | banana
44 | banana
45 | banana
46 | banana
47 | banana
48 | banana
49 | banana
50 | banana
51 | banana
52 | banana
53 | banana
54 | banana
55 | banana
56 | banana
57 | banana
58 | banana
59 | banana
60 | banana
61 | banana
62 | banana
63 | banana
64 | banana
65 | banana
66 | banana
67 | banana
68 | banana
69 | banana
70 | banana
71 | banana
72 | banana
73 | banana
74 | banana
75 | banana
76 | banana
77 | banana
78 | banana
79 | banana
80 | banana
81 | banana
82 | banana
83 | banana
84 | banana
85 | banana
86 | banana
87 | banana
88 | banana
89 | banana
90 | banana
91 | banana
92 | banana
93 | banana
94 | banana
95 | banana
96 | banana
97 | banana
98 | banana
99 | banana
100 | banana
101 | banana
102 | banana
103 | banana
104 | banana
105 | banana
106 | banana
107 | banana
108 | banana
109 | banana
110 | banana
111 | banana
112 | banana
113 | banana
114 | banana
115 | banana
116 | banana
117 | banana
118 | banana
119 | banana
120 | banana
121 | banana
122 | banana
123 | banana
124 | banana
125 | banana
126 | banana
127 | banana
128 | banana
129 | banana
130 | banana
131 | banana
132 | banana
133 | banana
134 | banana
135 | banana
136 | banana
137 | banana
138 | banana
139 | banana
140 | banana
141 | banana
142 | banana
143 | banana
144 | banana
145 | banana
146 | banana
147 | banana
148 | banana
149 | banana
150 | banana
151 | banana
152 | banana
153 | banana
154 | banana
155 | banana
156 | banana
157 | banana
158 | banana
159 | banana
160 | banana
161 | banana
162 | banana
163 | banana
164 | banana
165 | banana
166 | banana
167 | banana
168 | banana
169 | banana
170 | banana
171 | banana
172 | banana
173 | banana
174 | banana
175 | banana
176 | banana
177 | banana
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 | download-validation
186 |
187 | ${maven.multiModuleProjectDirectory}/target
188 |
189 |
190 |
191 |
192 | maven-dependency-plugin
193 |
194 |
195 |
196 | do-download-validation
197 | initialize
198 |
199 | unpack
200 |
201 |
202 |
203 |
204 | junit
205 | junit
206 | 4.12
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
--------------------------------------------------------------------------------
/src/test/resources/merge/issues/#15/our.pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | x123
5 | x123
6 | our
7 | pom
8 |
9 |
10 |
11 | org.codehaus.mojo
12 | versions-maven-plugin
13 | 2.1
14 | maven-plugin
15 |
16 |
17 |
18 |
19 |
20 | 1.8
21 | 1.8
22 | UTF-8
23 | jdt_apt
24 |
25 |
26 | banana
27 | banana
28 | banana
29 | banana
30 | banana
31 | banana
32 | banana
33 | banana
34 | banana
35 | banana
36 | banana
37 | banana
38 | banana
39 | banana
40 | banana
41 | banana
42 | banana
43 | banana
44 | banana
45 | banana
46 | banana
47 | banana
48 | banana
49 | banana
50 | banana
51 | banana
52 | banana
53 | banana
54 | banana
55 | banana
56 | banana
57 | banana
58 | banana
59 | banana
60 | banana
61 | banana
62 | banana
63 | banana
64 | banana
65 | banana
66 | banana
67 | banana
68 | banana
69 | banana
70 | banana
71 | banana
72 | banana
73 | banana
74 | banana
75 | banana
76 | banana
77 | banana
78 | banana
79 | banana
80 | banana
81 | banana
82 | banana
83 | banana
84 | banana
85 | banana
86 | banana
87 | banana
88 | banana
89 | banana
90 | banana
91 | banana
92 | banana
93 | banana
94 | banana
95 | banana
96 | banana
97 | banana
98 | banana
99 | banana
100 | banana
101 | banana
102 | banana
103 | banana
104 | banana
105 | banana
106 | banana
107 | banana
108 | banana
109 | banana
110 | banana
111 | banana
112 | banana
113 | banana
114 | banana
115 | banana
116 | banana
117 | banana
118 | banana
119 | banana
120 | banana
121 | banana
122 | banana
123 | banana
124 | banana
125 | banana
126 | banana
127 | banana
128 | banana
129 | banana
130 | banana
131 | banana
132 | banana
133 | banana
134 | banana
135 | banana
136 | banana
137 | banana
138 | banana
139 | banana
140 | banana
141 | banana
142 | banana
143 | banana
144 | banana
145 | banana
146 | banana
147 | banana
148 | banana
149 | banana
150 | banana
151 | banana
152 | banana
153 | banana
154 | banana
155 | banana
156 | banana
157 | banana
158 | banana
159 | banana
160 | banana
161 | banana
162 | banana
163 | banana
164 | banana
165 | banana
166 | banana
167 | banana
168 | banana
169 | banana
170 | banana
171 | banana
172 | banana
173 | banana
174 | banana
175 | banana
176 | banana
177 | banana
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 | download-validation
186 |
187 | ${maven.multiModuleProjectDirectory}/target
188 |
189 |
190 |
191 |
192 | maven-dependency-plugin
193 |
194 |
195 |
196 | do-download-validation
197 | initialize
198 |
199 | unpack
200 |
201 |
202 |
203 |
204 | junit
205 | junit
206 | 4.12
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
--------------------------------------------------------------------------------
/src/test/resources/merge/issues/#15/their.pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | x123
5 | x123
6 | their
7 | pom
8 |
9 |
10 |
11 | org.codehaus.mojo
12 | versions-maven-plugin
13 | 2.5
14 | maven-plugin
15 |
16 |
17 |
18 |
19 |
20 | 1.8
21 | 1.8
22 | UTF-8
23 | jdt_apt
24 |
25 |
26 | banana
27 | banana
28 | banana
29 | banana
30 | banana
31 | banana
32 | banana
33 | banana
34 | banana
35 | banana
36 | banana
37 | banana
38 | banana
39 | banana
40 | banana
41 | banana
42 | banana
43 | banana
44 | banana
45 | banana
46 | banana
47 | banana
48 | banana
49 | banana
50 | banana
51 | banana
52 | banana
53 | banana
54 | banana
55 | banana
56 | banana
57 | banana
58 | banana
59 | banana
60 | banana
61 | banana
62 | banana
63 | banana
64 | banana
65 | banana
66 | banana
67 | banana
68 | banana
69 | banana
70 | banana
71 | banana
72 | banana
73 | banana
74 | banana
75 | banana
76 | banana
77 | banana
78 | banana
79 | banana
80 | banana
81 | banana
82 | banana
83 | banana
84 | banana
85 | banana
86 | banana
87 | banana
88 | banana
89 | banana
90 | banana
91 | banana
92 | banana
93 | banana
94 | banana
95 | banana
96 | banana
97 | banana
98 | banana
99 | banana
100 | banana
101 | banana
102 | banana
103 | banana
104 | banana
105 | banana
106 | banana
107 | banana
108 | banana
109 | banana
110 | banana
111 | banana
112 | banana
113 | banana
114 | banana
115 | banana
116 | banana
117 | banana
118 | banana
119 | banana
120 | banana
121 | banana
122 | banana
123 | banana
124 | banana
125 | banana
126 | banana
127 | banana
128 | banana
129 | banana
130 | banana
131 | banana
132 | banana
133 | banana
134 | banana
135 | banana
136 | banana
137 | banana
138 | banana
139 | banana
140 | banana
141 | banana
142 | banana
143 | banana
144 | banana
145 | banana
146 | banana
147 | banana
148 | banana
149 | banana
150 | banana
151 | banana
152 | banana
153 | banana
154 | banana
155 | banana
156 | banana
157 | banana
158 | banana
159 | banana
160 | banana
161 | banana
162 | banana
163 | banana
164 | banana
165 | banana
166 | banana
167 | banana
168 | banana
169 | banana
170 | banana
171 | banana
172 | banana
173 | banana
174 | banana
175 | banana
176 | banana
177 | banana
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 | download-validation
186 |
187 | ${maven.multiModuleProjectDirectory}/target
188 |
189 |
190 |
191 |
192 | maven-dependency-plugin
193 |
194 |
195 |
196 | do-download-validation
197 | initialize
198 |
199 | unpack
200 |
201 |
202 |
203 |
204 | junit
205 | junit
206 | 4.12
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/ourStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/ourStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/ourStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: OUR
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/ourStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/theirStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/theirStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.1
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/theirStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: THEIR
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetProjectAndParentVersion/theirStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | org.codehaus.mojo
9 | versions-maven-plugin
10 | 2.5
11 | maven-plugin
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/ourStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | base
9 | base
10 | base
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | base
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | base
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.1
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/ourStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | our
9 | our
10 | our
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | our
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | our
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.1
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/ourStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: OUR # possible values: OUR|THEIR
3 |
4 | --- !!de.oppermann.pomutils.rules.PropertyRule
5 | strategy : OUR # possible values: OUR|THEIR
6 | properties: # a list of property names
7 | - foobar
8 | - jdbc.base.url
9 | propertiesRegex: # a list of property name regexes
10 | - .+\.version
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/ourStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | their
9 | their
10 | their
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | their
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | their
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.5
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/theirStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | base
6 |
7 |
8 | base
9 | base
10 | base
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | base
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | base
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.1
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/theirStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | our
6 |
7 |
8 | our
9 | our
10 | our
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | our
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | our
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.1
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/theirStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ProjectAndParentVersionRule
2 | strategy: THEIR # possible values: OUR|THEIR
3 |
4 | --- !!de.oppermann.pomutils.rules.PropertyRule
5 | strategy : THEIR # possible values: OUR|THEIR
6 | properties: # a list of property names
7 | - foobar
8 | - jdbc.base.url
9 | propertiesRegex: # a list of property name regexes
10 | - .+\.version
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetPropertyRule/theirStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 | their
6 |
7 |
8 | their
9 | their
10 | their
11 |
12 |
13 |
14 |
15 | develop
16 |
17 | their
18 |
19 |
20 |
21 | delivery
22 |
23 |
24 |
25 |
26 |
27 |
28 | regex
29 |
30 | their
31 |
32 |
33 |
34 |
35 |
36 |
37 | org.codehaus.mojo
38 | versions-maven-plugin
39 | 2.5
40 | maven-plugin
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/ourStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.1
10 | maven-plugin
11 |
12 |
13 |
14 | base
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/ourStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.1
10 | maven-plugin
11 |
12 |
13 |
14 | our
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/ourStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ScmTagRule
2 | strategy: OUR
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/ourStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.5
10 | maven-plugin
11 |
12 |
13 |
14 | their
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/theirStrategy/base.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.1
10 | maven-plugin
11 |
12 |
13 |
14 | base
15 |
16 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/theirStrategy/our.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.1
10 | maven-plugin
11 |
12 |
13 |
14 | our
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/theirStrategy/ruleset.yaml:
--------------------------------------------------------------------------------
1 | --- !!de.oppermann.pomutils.rules.ScmTagRule
2 | strategy: THEIR
--------------------------------------------------------------------------------
/src/test/resources/rulesets/rulesetScmTag/theirStrategy/their.pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | de.oppermann.pomutils
4 | pomutils
5 |
6 |
7 | org.codehaus.mojo
8 | versions-maven-plugin
9 | 2.5
10 | maven-plugin
11 |
12 |
13 |
14 | their
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/test/resources/versionReplacer/parent.and.project.version/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | de.oppermann.pomutils
6 | bom
7 | 0.1
8 |
9 |
10 | de.oppermann.pomutils
11 | pomutils
12 | 0.1
13 |
14 |
15 | org.codehaus.mojo
16 | versions-maven-plugin
17 | 2.1
18 | maven-plugin
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/test/resources/versionReplacer/parent.version/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | de.oppermann.pomutils
6 | bom
7 | 0.1
8 |
9 |
10 | de.oppermann.pomutils
11 | pomutils
12 |
13 |
14 |
15 | org.codehaus.mojo
16 | versions-maven-plugin
17 | 2.1
18 | maven-plugin
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/test/resources/versionReplacer/project.version/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | de.oppermann.pomutils
5 | pomutils
6 | 0.1
7 |
8 |
9 | org.codehaus.mojo
10 | versions-maven-plugin
11 | 2.1
12 | maven-plugin
13 |
14 |
15 |
--------------------------------------------------------------------------------