diff --git a/LICENSE-ASL-2.0.txt b/LICENSE-ASL-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE-ASL-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
index 561d88a..f91e6b2 100644
--- a/README.md
+++ b/README.md
@@ -1,49 +1,191 @@
# Maven Dependency Management Extension
-A Maven core extension which allows additional dependency management features such as overriding a dependency version from the command line.
+A Maven core extension (lifecycle participant) which adds dependency management features to Maven to allow dependency and plugin versions to be overridden using a command line property.
-If any of the extension's options are used, they are recorded in .properties format in META-INF/maven/groupId/artifactId/, the same place that maven copies the normal pom file to. An "effective pom" representation of the post-modification model is written in the same directory as well. These actions help mitigate loss of build repeatability.
+
+
+|
+ WARNING : This extension has been deprecated and its functionality rolled into https://github.com/release-engineering/pom-manipulation-ext.
+ |
+
+
-## Usage
-Pass one or more properties to the maven build in the form:
+If any of the extension's options are used, the results are recorded in .properties format in META-INF/maven/groupId/artifactId/, the same place that maven copies the normal pom file to. An "effective pom" representation of the post-modification pom model is also written to this directory. These actions help mitigate loss of build repeatability.
+
+This extension is compatible with Maven 3. It has not been tested with Maven 2.x and will likely not work correctly.
+
+## Installation
+
+The extension jar can be downloaded from a [Maven repository](http://repo1.maven.org/maven2/org/jboss/maven/extension/dependency/maven-dependency-management-extension/), or it can be built from source. Once the jar is downloaded, it must be added to the directory `${MAVEN_HOME}/lib/ext`. The next time Maven is started, you should see a command line message showing that the extension has been installed.
- version::=
+ [INFO] Init Maven Dependency Management Extension 1.0.0
-to override **dependency versions**. Pass one or more properties to the maven build in the form:
+If you wish to remove the extension after installing it, remove the jar from the `lib/ext` directory:
- pluginVersion::=
+ rm ${MAVEN_HOME}/lib/ext/maven-dependency-management-extension*.jar
-to override **plugin versions**.
-It is possible to specify a remote POM for the purposes of affecting the plugin or dependency management instead of a series of properties. For dependencies, use:
+## Activate for an individual project
+As an alternative to installing the extension into your Maven installation, you can activate Maven Dependency Management Extension for a single project by adding this to your **pom.xml** (fill in **VERSION**, eg 1.0.1):
- dependencyManagement=::
+
+
+
+ org.jboss.maven.extension.dependency
+ maven-dependency-management-extension
+ VERSION
+
+
+
-and for plugins use:
+## Usage
+
+Dependency and plugin versions are overridden using command line system properties.
- pluginManagement=::
+### Overriding dependency versions
-### Examples
-The following overrides **junit** to version **4.10**
+The version of a specific dependency can be overridden using a command line property of the form "version:[groupId]:[artifactId]=[version]".
+
+For example, the version of **junit** can be set to **4.10** using a command line property.
mvn install -Dversion:junit:junit=4.10
-The following overrides **plexus-component-metadata** to version **1.5.5**
+Multiple version overrides can be performed using multiple command line properties.
+
+ mvn install -Dversion:junit:junit=4.10 -Dversion:commons-logging:commons-logging=1.1.1
+
+If a large set of versions needs to be overridden, or the dependencies of the current project need to be tested with a matching set of
+dependencies from another project, a remote dependency management pom can be specified.
+
+ mvn install -DdependencyManagement=org.foo:my-dep-pom:1.0
+
+This has the effect of taking the <dependencyManagement/> from the remote pom, and applying the dependency versions to the current build.
+By default, all dependencies listed in the remote pom will be added to the current build. This has the effect of overriding matching
+transitive dependencies, as well as those specified directly in the pom. If transitive dependencies should not be overridden, the option "overrideTransitive" can be set to false.
+
+ mvn install -DdependencyManagement=org.foo:my-dep-pom:1.0 -DoverrideTransitive=false
+
+As of version 1.1.0, multiple remote dependency management poms can be specified using a comma separated list of GAVs (groupId, artifactId, version).
+The poms are specified in order of priority, so if the remote boms contain some of the same dependencies,
+the versions listed in the first bom in the list will be used.
+
+ mvn install -DdependencyManagement=org.foo:my-dep-pom:1.0,org.bar:my-dep-pom:2.0
+
+
+
+### Overriding dependency versions of a specific module
+
+In a multi-module build it is considered good practice to coordinate dependency version among
+the modules using dependency management. In other words, if module A and B both use dependency X,
+both modules should use the same version of dependency X. Therefore, the default behaviour of this
+extension is to use a single set of dependency versions applied to all modules.
+
+However, there are certain cases where it is useful to use different versions of the same dependency
+in different modules. For example, if the project includes integration code for multiple
+versions of a particular API. In that case, it is possible to apply a version override to
+a specific module of a multi-module build.
+
+ mvn install -Dversion:[groupId]:[artifactId]@[moduleGroupId]:[moduleArtifactId]=[version]
+
+For example to apply a dependency override only to module B of project foo.
+
+ mvn install -Dversion:junit:junit@org.foo:moduleB=4.10
+
+
+#### Prevent overriding dependency versions per module
+
+It is also possible to prevent overriding dependency versions on a per module basis:
+
+ mvn install -Dversion:[groupId]:[artifactId]@[moduleGroupId]:[moduleArtifactId]=
+
+For example
+
+ mvn install -Dversion:junit:junit@org.foo:moduleB=
+
- mvn install -DpluginVersion:org.codehaus.plexus:plexus-component-metadata=1.5.5
+### Overriding plugin versions
-## Install
-After cloning the repo, you can make the extension active for all maven builds by running the following commands:
+Plugin versions can be overridden in the pom using a similar pattern to dependencies with the format "pluginVersion:[groupId]:[artifactId]=[version]".
- mvn package && sudo cp target/maven-dependency-management-extension*.jar /usr/share/maven/lib/ext/
+ mvn install -DpluginVersion:org.apache.maven.plugins:maven-compiler-plugin=3.0
-## Uninstall
-If you wish to remove the extension after installing it, run the following command:
+To override more than one Maven plugin version, multple override properties can be specified on the command line, or a remote plugin management pom can be specified.
- sudo rm -i /usr/share/maven/lib/ext/maven-dependency-management-extension*.jar
+ mvn install -DpluginManagement=org.jboss:jboss-parent:10
+
+This will apply all <pluginManagement/> versions from the remote pom, to the local pom.
+Multiple remote plugin management poms can be specified on the command line using a comma separated
+list of GAVs. The first pom specified will be given the highest priority if conflicts occur.
+
+ mvn install -DpluginManagement=org.company:pluginMgrA:1.0,org.company:pluginMgrB:2.0
+
+### Overriding Properties
+
+The extensions may also be used to override properties prior to interpolating the model. This requires
+the extension to be installed in lib/ext. Multiple property mappings can be overridden using a similar pattern
+to dependencies via a remote property management pom.
+
+ mvn install -DpropertyManagement=org.foo:property-management:10
+
+Properties may be overridden on the command line as per normal Maven usage (i.e. -Dversion.org.foo=1.0)
+
+## Using Dependency Properties
+
+The extension will automatically set properties which match the version overrides. These properties
+can be used, for example, in resource filtering in the build. By default the extension
+will set a property following the format "version:[groupId]:[artifactId]=[version]" for
+each overridden dependency. The format of this property can be customized using command line
+system properties.
+
+ versionPropertyPrefix - Defaults to "version:"
+ versionPropertyGASeparator - Defaults to ":"
+ versionPropertySuffix - Defaults to empty string ""
+
+For example, the version property format could be set to "my.[groupId]_[artifactId].version=[version]"
+
+ mvn install -DversionPropertyPrefix="my." -DversionPropertyGASeparator="_" -DversionPropertySuffix=".version"
+
+
+## Building from source
+
+You must have Maven 3 or higher installed to build the extension. The source repository can be downloaded from github.
+
+ git clone git://github.com/jboss/maven-dependency-management-extension.git
+
+After cloning the repo, just run a normal maven build.
+
+ mvn install
+
+The extension jar is created in the target directory.
+
+### Run Integration Tests
-## Run Integration Tests
The following command runs the integration tests as part of the build
mvn install -Prun-its
+
+## Known Issues/Limitations
+
+### Plugin Extensions
+
+The plugin management feature will override plugin versions, but this will not work on plugins which are
+configured as build extensions.
+
+ true
+
+These plugins are loaded early in the build lifecycle, before the dependency management extension takes effect.
+
+### Plugin Dependencies
+
+Some Maven builds configure a plugin with additional dependencies. This is common in the
+maven-antrun-plugin for example when using non-default tasks/features of Ant. This extension does not
+currently allow these dependencies to be overridden from the command line.
+
+### Intermodule dependencies
+
+It is common in a multi-module Maven build that one module has a dependency on another module. If the remote
+dependency management pom contains overrides for the modules of the current project, Maven will attempt
+to use the override versions instead of the local versions. In version 1.0.1 of this extension, a change was made
+to cause the overrides to ignore dependencies that are in the current reactor, however this problem could still
+occur when attempting to build a single module of a multi-module build.
diff --git a/docs/implementation-2013-02-26.graphml b/docs/implementation-2013-02-26.graphml
deleted file mode 100644
index 143d63d..0000000
--- a/docs/implementation-2013-02-26.graphml
+++ /dev/null
@@ -1,1211 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ModelBuildingModifier
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Modify Build Call
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ExtDepMgmtModelBuilder
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Object Creation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Create Hardcoded List<ModelBuildingModifier>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.buildModifierList
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Build Method Call
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- For each buildModifier
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Call modifyBuild Method
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Call DefaultModelBuilder's Build Method
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- More?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Return model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Model result
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DepVersionOverride / PluginVersionOverride
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Object Creation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getOverrideMap for relevent property prefix
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- this.groupOverrideMap
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Modify Build Call
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- For each Plugin/Dependency in the model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- More?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Check if target needs to be overridden
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Return modified model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- VersionOverrider
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Get Override Map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Process Java system properties for matches
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Convert K/V Map into 2K/V Override map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Return override map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- applyVersionToTargetInModel
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Check for groupID in override map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Check for artifactID in override map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Return Model
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Key?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Key?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Set target version to value from override map
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Yes
-
-
-
-
-
-
-
-
-
-
-
-
-
- No
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Yes
-
-
-
-
-
-
-
-
-
-
-
-
-
- No
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Not Found
-
-
-
-
-
-
-
-
-
-
-
-
-
- Found
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Not Found
-
-
-
-
-
-
-
-
-
-
-
-
-
- Found
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/implementation-2013-02-26.png b/docs/implementation-2013-02-26.png
deleted file mode 100644
index a3fca73..0000000
Binary files a/docs/implementation-2013-02-26.png and /dev/null differ
diff --git a/header.txt b/header.txt
new file mode 100755
index 0000000..632f405
--- /dev/null
+++ b/header.txt
@@ -0,0 +1,13 @@
+Copyright (C) 2013 Red Hat, Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/pom.xml b/pom.xml
index b3fdf6d..69cc8c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,20 +1,58 @@
+
+
4.0.0
+
+ org.jboss
+ jboss-parent
+ 11
+
+
org.jboss.maven.extension.dependency
maven-dependency-management-extension
- 1.0.0-SNAPSHOT
+ 1.2.2-SNAPSHOT
UTF-8
${basedir}/src/it/resources/apache-maven-3.0.4
+ 1.6
+ 1.6
+
+ org.apache.maven
+ maven-aether-provider
+ 3.0.3
+ provided
+
+
+
+ org.apache.maven
+ maven-artifact
+ 3.0.3
+ provided
+
+
org.apache.maven
maven-core
@@ -22,6 +60,27 @@
provided
+
+ org.apache.maven
+ maven-model
+ 3.0.3
+ provided
+
+
+
+ org.apache.maven
+ maven-model-builder
+ 3.0.3
+ provided
+
+
+
+ org.codehaus.plexus
+ plexus-utils
+ 2.0.7
+ provided
+
+
org.codehaus.plexus
plexus-component-annotations
@@ -31,36 +90,43 @@
org.sonatype.aether
- aether-impl
+ aether-api
1.13.1
provided
-
org.sonatype.aether
- aether-test-util
+ aether-impl
1.13.1
- test
+ provided
- junit
- junit
- 4.10
- test
+ org.sonatype.sisu
+ sisu-inject-plexus
+ 2.1.1
+ provided
+
- org.mockito
- mockito-core
- 1.9.0
+ junit
+ junit
+ 4.10
test
+
+
+ src/main/resources
+ true
+
+
+
org.codehaus.plexus
@@ -82,6 +148,18 @@
1.6
+
+ com.mycila.maven-license-plugin
+ maven-license-plugin
+ 1.9.0
+
+
+ true
+
+ src/main/java/**/*.java
+
+
+
@@ -122,7 +200,23 @@
1.8
- integration-test
+ integration-tests-pom-ext
+
+ install
+ run
+
+
+ ${project.build.directory}/it-pom-ext
+ ${project.build.directory}/local-repo-pom-ext
+
+ *-pom-ext/pom.xml
+
+ src/it
+ src/it/settings.xml
+
+
+
+ integration-test-lib-ext
run
@@ -135,11 +229,16 @@
${project.build.directory}/local-repo
${it.maven.home}
+
+ setup/*/pom.xml
+
*/pom.xml
+
+ *-pom-ext/pom.xml
+
src/it
- verify
src/it/settings.xml
diff --git a/src/it/basic-dependency-override-pom-ext/pom.xml b/src/it/basic-dependency-override-pom-ext/pom.xml
new file mode 100644
index 0000000..8b4bde1
--- /dev/null
+++ b/src/it/basic-dependency-override-pom-ext/pom.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-dependency-override
+ 1.0-SNAPSHOT
+
+ Test override dependency version using command line property
+
+
+ UTF-8
+
+
+
+
+
+ org.jboss.maven.extension.dependency
+ maven-dependency-management-extension
+ @project.version@
+
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/basic-remote-dependency-management/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-dependency-override-pom-ext/src/main/java/test/HelloWorldwithJUnit.java
similarity index 100%
rename from src/it/basic-remote-dependency-management/src/main/java/test/HelloWorldwithJUnit.java
rename to src/it/basic-dependency-override-pom-ext/src/main/java/test/HelloWorldwithJUnit.java
diff --git a/src/it/basic-remote-dependency-management/test.properties b/src/it/basic-dependency-override-pom-ext/test.properties
similarity index 65%
rename from src/it/basic-remote-dependency-management/test.properties
rename to src/it/basic-dependency-override-pom-ext/test.properties
index ac80b61..a334457 100644
--- a/src/it/basic-remote-dependency-management/test.properties
+++ b/src/it/basic-dependency-override-pom-ext/test.properties
@@ -1,4 +1,4 @@
# Override the version of JUnit
# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
-dependencyManagement=org.jboss.as\:jboss-as-parent\:7.2.0.Final
+version\:junit\:junit=4.1
\ No newline at end of file
diff --git a/src/it/basic-ignore-module-dependency-override/align/pom.xml b/src/it/basic-ignore-module-dependency-override/align/pom.xml
new file mode 100644
index 0000000..9a43f46
--- /dev/null
+++ b/src/it/basic-ignore-module-dependency-override/align/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ align
+ 1.0-SNAPSHOT
+
+ Test submodule
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/remote-plugin-management-override/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-ignore-module-dependency-override/align/src/main/java/test/HelloWorldwithJUnit.java
similarity index 100%
rename from src/it/remote-plugin-management-override/src/main/java/test/HelloWorldwithJUnit.java
rename to src/it/basic-ignore-module-dependency-override/align/src/main/java/test/HelloWorldwithJUnit.java
diff --git a/src/it/basic-ignore-module-dependency-override/no-align/pom.xml b/src/it/basic-ignore-module-dependency-override/no-align/pom.xml
new file mode 100644
index 0000000..075d829
--- /dev/null
+++ b/src/it/basic-ignore-module-dependency-override/no-align/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ no-align
+ 1.0-SNAPSHOT
+
+ Test submodule
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/basic-ignore-module-dependency-override/no-align/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-ignore-module-dependency-override/no-align/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..e7eefa9
--- /dev/null
+++ b/src/it/basic-ignore-module-dependency-override/no-align/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,15 @@
+package test;
+
+
+import junit.swingui.TestRunner;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+
+ // Just a dummy call to verify that we can compile again JUnit 3
+ new TestRunner ();
+ }
+}
diff --git a/src/it/basic-ignore-module-dependency-override/pom.xml b/src/it/basic-ignore-module-dependency-override/pom.xml
new file mode 100644
index 0000000..738f1dd
--- /dev/null
+++ b/src/it/basic-ignore-module-dependency-override/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-ignore-module-dependency-override
+ 1.0-SNAPSHOT
+
+ Test override dependency version excluding a single module
+
+ pom
+
+
+ UTF-8
+
+
+
+ align
+ no-align
+
+
+
diff --git a/src/it/basic-ignore-module-dependency-override/test.properties b/src/it/basic-ignore-module-dependency-override/test.properties
new file mode 100644
index 0000000..086a50f
--- /dev/null
+++ b/src/it/basic-ignore-module-dependency-override/test.properties
@@ -0,0 +1,5 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+version\:junit\:junit=4.1
+version\:junit\:junit@org.jboss.maven.extension.dependency\:no-align=
diff --git a/src/it/basic-invalid-dependency-override/pom.xml b/src/it/basic-invalid-dependency-override/pom.xml
new file mode 100644
index 0000000..b859fb4
--- /dev/null
+++ b/src/it/basic-invalid-dependency-override/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-invalid-dependency-override
+ 1.0-SNAPSHOT
+
+ Test override dependency version using an invalid command line property
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/basic-invalid-dependency-override/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-invalid-dependency-override/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..e7eefa9
--- /dev/null
+++ b/src/it/basic-invalid-dependency-override/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,15 @@
+package test;
+
+
+import junit.swingui.TestRunner;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+
+ // Just a dummy call to verify that we can compile again JUnit 3
+ new TestRunner ();
+ }
+}
diff --git a/src/it/basic-invalid-dependency-override/test.properties b/src/it/basic-invalid-dependency-override/test.properties
new file mode 100644
index 0000000..c0d37a9
--- /dev/null
+++ b/src/it/basic-invalid-dependency-override/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+version\:junit\:junit=
\ No newline at end of file
diff --git a/src/it/basic-property-override/pom.xml b/src/it/basic-property-override/pom.xml
new file mode 100644
index 0000000..7cee532
--- /dev/null
+++ b/src/it/basic-property-override/pom.xml
@@ -0,0 +1,69 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-property-override
+ 1.0-SNAPSHOT
+
+ Test override property version using command line property
+
+
+ UTF-8
+ 3.8.2
+
+
+
+
+ junit
+ junit
+ ${version.junit}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.2
+
+
+ package
+
+ shade
+
+
+
+
+ *junit*
+
+
+
+
+
+
+
+
+
diff --git a/src/it/basic-property-override/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-property-override/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/basic-property-override/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/basic-property-override/test.properties b/src/it/basic-property-override/test.properties
new file mode 100644
index 0000000..7ae91d7
--- /dev/null
+++ b/src/it/basic-property-override/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+propertyManagement=org.jboss.maven.extension.dependency\:propertyMgmt1\:1.0
diff --git a/src/it/basic-version-properties/pom.xml b/src/it/basic-version-properties/pom.xml
new file mode 100644
index 0000000..b739369
--- /dev/null
+++ b/src/it/basic-version-properties/pom.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-version-propertie
+ 1.0-SNAPSHOT
+
+ Test setting version properties for each overridden dependency
+
+
+ UTF-8
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/basic-version-properties/postbuild.groovy b/src/it/basic-version-properties/postbuild.groovy
new file mode 100644
index 0000000..08fa8a6
--- /dev/null
+++ b/src/it/basic-version-properties/postbuild.groovy
@@ -0,0 +1,11 @@
+
+import java.util.Properties
+
+Properties versionProps = new Properties()
+File itDirectory = new File("target/it/basic-version-properties")
+
+new File(itDirectory, "target/classes/versions.properties").withReader { reader ->
+ versionProps.load( reader )
+}
+assert( "4.1".equals( versionProps.getProperty( "theJunitVersion" ) ) )
+
diff --git a/src/it/basic-version-properties/src/main/java/test/HelloWorldwithJUnit.java b/src/it/basic-version-properties/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/basic-version-properties/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/basic-version-properties/src/main/resources/versions.properties b/src/it/basic-version-properties/src/main/resources/versions.properties
new file mode 100644
index 0000000..2b5090a
--- /dev/null
+++ b/src/it/basic-version-properties/src/main/resources/versions.properties
@@ -0,0 +1,2 @@
+# Test that the value of the versions properties comes through correctly
+theJunitVersion=${version:junit:junit}
diff --git a/src/it/basic-version-properties/test.properties b/src/it/basic-version-properties/test.properties
new file mode 100644
index 0000000..626fc91
--- /dev/null
+++ b/src/it/basic-version-properties/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+dependencyManagement=org.jboss.maven.extension.dependency\:depMgmt1\:1.0
diff --git a/src/it/configured-version-properties/pom.xml b/src/it/configured-version-properties/pom.xml
new file mode 100644
index 0000000..b739369
--- /dev/null
+++ b/src/it/configured-version-properties/pom.xml
@@ -0,0 +1,53 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ basic-version-propertie
+ 1.0-SNAPSHOT
+
+ Test setting version properties for each overridden dependency
+
+
+ UTF-8
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/configured-version-properties/postbuild.groovy b/src/it/configured-version-properties/postbuild.groovy
new file mode 100644
index 0000000..f42782e
--- /dev/null
+++ b/src/it/configured-version-properties/postbuild.groovy
@@ -0,0 +1,11 @@
+
+import java.util.Properties
+
+Properties versionProps = new Properties()
+File itDirectory = new File("target/it/configured-version-properties")
+
+new File(itDirectory, "target/classes/versions.properties").withReader { reader ->
+ versionProps.load( reader )
+}
+assert( "4.1".equals( versionProps.getProperty( "theJunitVersion" ) ) )
+
diff --git a/src/it/configured-version-properties/src/main/java/test/HelloWorldwithJUnit.java b/src/it/configured-version-properties/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/configured-version-properties/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/configured-version-properties/src/main/resources/versions.properties b/src/it/configured-version-properties/src/main/resources/versions.properties
new file mode 100644
index 0000000..0ba5c9c
--- /dev/null
+++ b/src/it/configured-version-properties/src/main/resources/versions.properties
@@ -0,0 +1,2 @@
+# Test that the value of the versions properties comes through correctly
+theJunitVersion=${myversion_junit-junit_versionSuffix}
diff --git a/src/it/configured-version-properties/test.properties b/src/it/configured-version-properties/test.properties
new file mode 100644
index 0000000..9c03c5b
--- /dev/null
+++ b/src/it/configured-version-properties/test.properties
@@ -0,0 +1,7 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+dependencyManagement=org.jboss.maven.extension.dependency\:depMgmt1\:1.0
+versionPropertyPrefix=myversion_
+versionPropertyGASeparator=-
+versionPropertySuffix=_versionSuffix
\ No newline at end of file
diff --git a/src/it/basic-remote-dependency-management/pom.xml b/src/it/remote-dependency-management-basic/pom.xml
similarity index 100%
rename from src/it/basic-remote-dependency-management/pom.xml
rename to src/it/remote-dependency-management-basic/pom.xml
diff --git a/src/it/remote-dependency-management-basic/src/main/java/test/HelloWorldwithJUnit.java b/src/it/remote-dependency-management-basic/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/remote-dependency-management-basic/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/remote-dependency-management-basic/test.properties b/src/it/remote-dependency-management-basic/test.properties
new file mode 100644
index 0000000..626fc91
--- /dev/null
+++ b/src/it/remote-dependency-management-basic/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+dependencyManagement=org.jboss.maven.extension.dependency\:depMgmt1\:1.0
diff --git a/src/it/remote-dependency-management-multiple/pom.xml b/src/it/remote-dependency-management-multiple/pom.xml
new file mode 100644
index 0000000..1a02516
--- /dev/null
+++ b/src/it/remote-dependency-management-multiple/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ remote-dependency-management-multiple
+ 1.0-SNAPSHOT
+
+ Test override dependency version using command line property with remote pom
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/remote-dependency-management-multiple/src/main/java/test/HelloWorldwithJUnit.java b/src/it/remote-dependency-management-multiple/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/remote-dependency-management-multiple/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/remote-dependency-management-multiple/test.properties b/src/it/remote-dependency-management-multiple/test.properties
new file mode 100644
index 0000000..6366a32
--- /dev/null
+++ b/src/it/remote-dependency-management-multiple/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+dependencyManagement=org.jboss.maven.extension.dependency\:depMgmt1\:1.0,org.jboss.maven.extension.dependency\:depMgmt2\:1.0
diff --git a/src/it/remote-dependency-management-null/invoker.properties b/src/it/remote-dependency-management-null/invoker.properties
new file mode 100644
index 0000000..517a82d
--- /dev/null
+++ b/src/it/remote-dependency-management-null/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.buildResult = failure
\ No newline at end of file
diff --git a/src/it/remote-dependency-management-null/pom.xml b/src/it/remote-dependency-management-null/pom.xml
new file mode 100644
index 0000000..431c962
--- /dev/null
+++ b/src/it/remote-dependency-management-null/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ remote-dependency-management-override-null
+ 1.0-SNAPSHOT
+
+ Test override dependency version using remote BOM with no dep mgmt does not fail
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 3.8.2
+
+
+
+
diff --git a/src/it/remote-dependency-management-null/src/main/java/test/HelloWorldwithJUnit.java b/src/it/remote-dependency-management-null/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..e7eefa9
--- /dev/null
+++ b/src/it/remote-dependency-management-null/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,15 @@
+package test;
+
+
+import junit.swingui.TestRunner;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+
+ // Just a dummy call to verify that we can compile again JUnit 3
+ new TestRunner ();
+ }
+}
diff --git a/src/it/remote-dependency-management-null/test.properties b/src/it/remote-dependency-management-null/test.properties
new file mode 100644
index 0000000..f75ed27
--- /dev/null
+++ b/src/it/remote-dependency-management-null/test.properties
@@ -0,0 +1,4 @@
+
+# Override the version of JUnit
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+dependencyManagement=org.jboss.maven.extension.dependency\:depMgmt3\:1.0
diff --git a/src/it/remote-plugin-management-override/pom.xml b/src/it/remote-plugin-management-basic/pom.xml
similarity index 100%
rename from src/it/remote-plugin-management-override/pom.xml
rename to src/it/remote-plugin-management-basic/pom.xml
diff --git a/src/it/remote-plugin-management-basic/src/main/java/test/HelloWorldwithJUnit.java b/src/it/remote-plugin-management-basic/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/remote-plugin-management-basic/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/remote-plugin-management-override/test.properties b/src/it/remote-plugin-management-basic/test.properties
similarity index 65%
rename from src/it/remote-plugin-management-override/test.properties
rename to src/it/remote-plugin-management-basic/test.properties
index f079f4c..0ddf9f2 100644
--- a/src/it/remote-plugin-management-override/test.properties
+++ b/src/it/remote-plugin-management-basic/test.properties
@@ -1,4 +1,4 @@
# Override the version of maven compiler plugin
# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
-pluginManagement=org.jboss\:jboss-parent\:10
+pluginManagement=org.jboss.maven.extension.dependency\:pluginMgmt1\:1.0
diff --git a/src/it/remote-plugin-management-multiple/pom.xml b/src/it/remote-plugin-management-multiple/pom.xml
new file mode 100644
index 0000000..5924418
--- /dev/null
+++ b/src/it/remote-plugin-management-multiple/pom.xml
@@ -0,0 +1,56 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ remote-plugin-management-multiple
+ 1.0-SNAPSHOT
+
+ Test override plugin version using command line property
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+ 4.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 99-bad
+
+
+
+
+
+
diff --git a/src/it/remote-plugin-management-multiple/src/main/java/test/HelloWorldwithJUnit.java b/src/it/remote-plugin-management-multiple/src/main/java/test/HelloWorldwithJUnit.java
new file mode 100644
index 0000000..0d905f2
--- /dev/null
+++ b/src/it/remote-plugin-management-multiple/src/main/java/test/HelloWorldwithJUnit.java
@@ -0,0 +1,17 @@
+package test;
+
+import org.junit.Test;
+
+public class HelloWorldwithJUnit
+{
+ public static void main (String [] args)
+ {
+ System.out.println("hello");
+ }
+
+ @Test
+ public void test()
+ {
+ // Just a dummy method to verify that we can compile again JUnit 4
+ }
+}
diff --git a/src/it/remote-plugin-management-multiple/test.properties b/src/it/remote-plugin-management-multiple/test.properties
new file mode 100644
index 0000000..641ba5b
--- /dev/null
+++ b/src/it/remote-plugin-management-multiple/test.properties
@@ -0,0 +1,5 @@
+
+# Override the version of maven compiler plugin
+# The colon needs to be escaped to prevent the invoker plugin from misinterpreting it
+pluginManagement=org.jboss.maven.extension.dependency\:pluginMgmt1\:1.0,org.jboss.maven.extension.dependency\:pluginMgmt2\:1.0
+
diff --git a/src/it/setup/depMgmt1/invoker.properties b/src/it/setup/depMgmt1/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/depMgmt1/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/depMgmt1/pom.xml b/src/it/setup/depMgmt1/pom.xml
new file mode 100644
index 0000000..5288092
--- /dev/null
+++ b/src/it/setup/depMgmt1/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ depMgmt1
+ 1.0
+
+ Dependency Management POM to use with integration tests
+
+
+ UTF-8
+
+
+
+
+
+ junit
+ junit
+ 4.1
+
+
+
+
+
diff --git a/src/it/setup/depMgmt2/invoker.properties b/src/it/setup/depMgmt2/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/depMgmt2/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/depMgmt2/pom.xml b/src/it/setup/depMgmt2/pom.xml
new file mode 100644
index 0000000..5bc17ab
--- /dev/null
+++ b/src/it/setup/depMgmt2/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ depMgmt2
+ 1.0
+
+ Dependency Management POM to use with integration tests
+
+
+ UTF-8
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+
+
+
+
+
diff --git a/src/it/setup/depMgmt3/invoker.properties b/src/it/setup/depMgmt3/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/depMgmt3/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/depMgmt3/pom.xml b/src/it/setup/depMgmt3/pom.xml
new file mode 100644
index 0000000..0fb1fb9
--- /dev/null
+++ b/src/it/setup/depMgmt3/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ depMgmt3
+ 1.0
+
+ Null Dependency Management POM to use with integration tests
+
+
+ UTF-8
+
+
+
diff --git a/src/it/setup/pluginMgmt1/invoker.properties b/src/it/setup/pluginMgmt1/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/pluginMgmt1/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/pluginMgmt1/pom.xml b/src/it/setup/pluginMgmt1/pom.xml
new file mode 100644
index 0000000..565c6e9
--- /dev/null
+++ b/src/it/setup/pluginMgmt1/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ pluginMgmt1
+ 1.0
+
+ Plugin Management POM to use with integration tests
+
+
+ UTF-8
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+
+
+
+
+
diff --git a/src/it/setup/pluginMgmt2/invoker.properties b/src/it/setup/pluginMgmt2/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/pluginMgmt2/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/pluginMgmt2/pom.xml b/src/it/setup/pluginMgmt2/pom.xml
new file mode 100644
index 0000000..4bc3251
--- /dev/null
+++ b/src/it/setup/pluginMgmt2/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ pluginMgmt2
+ 1.0
+
+ Plugin Management POM to use with integration tests
+
+
+ UTF-8
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.1
+
+
+
+
+
+
diff --git a/src/it/setup/propertyMgmt1/invoker.properties b/src/it/setup/propertyMgmt1/invoker.properties
new file mode 100644
index 0000000..a3f6302
--- /dev/null
+++ b/src/it/setup/propertyMgmt1/invoker.properties
@@ -0,0 +1,2 @@
+# Goals specific to current project
+invoker.goals = clean install
\ No newline at end of file
diff --git a/src/it/setup/propertyMgmt1/pom.xml b/src/it/setup/propertyMgmt1/pom.xml
new file mode 100644
index 0000000..cad3f1b
--- /dev/null
+++ b/src/it/setup/propertyMgmt1/pom.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ 4.0.0
+
+ org.jboss.maven.extension.dependency
+ propertyMgmt1
+ 1.0
+
+ Dependency Management POM to use with integration tests
+
+
+ UTF-8
+ 4.1
+
+
+
diff --git a/src/main/java/org/jboss/maven/extension/dependency/DependencyManagementLifecycleParticipant.java b/src/main/java/org/jboss/maven/extension/dependency/DependencyManagementLifecycleParticipant.java
new file mode 100644
index 0000000..6adcb9a
--- /dev/null
+++ b/src/main/java/org/jboss/maven/extension/dependency/DependencyManagementLifecycleParticipant.java
@@ -0,0 +1,191 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.AbstractMavenLifecycleParticipant;
+import org.apache.maven.MavenExecutionException;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.building.ModelBuilder;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.util.IOUtil;
+import org.jboss.maven.extension.dependency.metainf.EffectivePomGenerator;
+import org.jboss.maven.extension.dependency.metainf.MetaInfWriter;
+import org.jboss.maven.extension.dependency.modelmodifier.ModelModifier;
+import org.jboss.maven.extension.dependency.modelmodifier.SessionModifier;
+import org.jboss.maven.extension.dependency.modelmodifier.propertyoverride.PropertyMappingOverrider;
+import org.jboss.maven.extension.dependency.modelmodifier.versionoverride.DepVersionOverrider;
+import org.jboss.maven.extension.dependency.modelmodifier.versionoverride.PluginVersionOverrider;
+import org.jboss.maven.extension.dependency.resolver.EffectiveModelBuilder;
+import org.jboss.maven.extension.dependency.util.Log;
+import org.sonatype.aether.impl.ArtifactResolver;
+
+/**
+ * Main executor. Operates at the point defined by superclass as "afterProjectsRead", which is "after all MavenProject
+ * instances have been created". This should allow access to the model(s) after they are built, but before they are
+ * used.
+ */
+@Component( role = AbstractMavenLifecycleParticipant.class, hint = "dependencymanagement" )
+public class DependencyManagementLifecycleParticipant
+ extends AbstractMavenLifecycleParticipant
+{
+ @Requirement
+ private Logger logger;
+
+ private final List afterProjectsReadModifierList = new ArrayList();
+
+ private final List afterSessionStartModifierList = new ArrayList();
+
+ @Requirement
+ private ArtifactResolver resolver;
+
+ @Requirement
+ private ModelBuilder modelBuilder;
+
+ private int sessionChangeCount = 0;
+
+ /**
+ * Load the build modifiers at instantiation time
+ */
+ public DependencyManagementLifecycleParticipant()
+ {
+ // Logger is not available yet
+ System.out.println( "[INFO] Init Maven Dependency Management Extension " + loadProjectVersion() );
+
+ afterProjectsReadModifierList.add( new DepVersionOverrider() );
+ afterProjectsReadModifierList.add( new PluginVersionOverrider() );
+
+ afterSessionStartModifierList.add( new PropertyMappingOverrider() );
+
+ }
+
+ /**
+ * Get the version of the current project from the properties file
+ *
+ * @return The version of this project
+ */
+ private String loadProjectVersion()
+ {
+ InputStream in = null;
+ Properties props = new Properties();
+ try
+ {
+ in = getClass().getResourceAsStream( "project.properties" );
+ props.load( in );
+ }
+ catch ( IOException e )
+ {
+ // Ignore the error if we can't get the version.
+ }
+ finally
+ {
+ IOUtil.close( in );
+ }
+ String version = props.getProperty( "project.version" );
+ if (version == null)
+ {
+ version = "";
+ }
+ return version;
+ }
+
+ @Override
+ public void afterSessionStart( MavenSession session )
+ throws MavenExecutionException
+ {
+ Log.setLog( logger );
+
+ try
+ {
+ EffectiveModelBuilder.init( session, resolver, modelBuilder );
+ }
+ catch ( ComponentLookupException e )
+ {
+ logger.error( "EffectiveModelBuilder init could not look up plexus component: " + e );
+ }
+ catch ( PlexusContainerException e )
+ {
+ logger.error( "EffectiveModelBuilder init produced a plexus container error: " + e );
+ }
+ for ( SessionModifier currModifier : afterSessionStartModifierList )
+ {
+ boolean modelChanged = currModifier.updateSession( session );
+ if ( modelChanged )
+ {
+ sessionChangeCount++;
+ }
+ }
+ }
+
+ @Override
+ public void afterProjectsRead( MavenSession session )
+ throws MavenExecutionException
+ {
+ // The dependency management overrider needs to know which projects
+ // are in the reactor, and therefore should not be overridden.
+ StringBuilder reactorProjects = new StringBuilder();
+ for ( MavenProject project : session.getProjects() )
+ {
+ reactorProjects.append( project.getGroupId() + ":" + project.getArtifactId() + "," );
+ }
+ System.setProperty( "reactorProjectGAs", reactorProjects.toString() );
+
+ // Apply model modifiers to the projects' models
+ for ( MavenProject project : session.getProjects() )
+ {
+ logger.debug( "Checking project '" + project.getId() + "'" );
+ int modelChangeCount = 0;
+
+ Model currModel = project.getModel();
+
+ // Run the modifiers against the built model
+ for ( ModelModifier currModifier : afterProjectsReadModifierList )
+ {
+ boolean modelChanged = currModifier.updateModel( currModel );
+ if ( modelChanged )
+ {
+ modelChangeCount++;
+ }
+ }
+
+ // If something changed, then it will be useful to output extra info
+ if ( sessionChangeCount >=1 || modelChangeCount >= 1 )
+ {
+ logger.debug( "Session/Model changed at least once, writing informational files" );
+ try
+ {
+ MetaInfWriter.writeResource( currModel, new EffectivePomGenerator() );
+ }
+ catch ( IOException e )
+ {
+ logger.error( "Could not write the effective POM of model '" + currModel.getId() + "' due to " + e );
+ }
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/ModifyModelLifecycleParticipant.java b/src/main/java/org/jboss/maven/extension/dependency/ModifyModelLifecycleParticipant.java
deleted file mode 100644
index 2701038..0000000
--- a/src/main/java/org/jboss/maven/extension/dependency/ModifyModelLifecycleParticipant.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.jboss.maven.extension.dependency;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.AbstractMavenLifecycleParticipant;
-import org.apache.maven.MavenExecutionException;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.building.ModelBuilder;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.PlexusContainerException;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.logging.Logger;
-import org.jboss.maven.extension.dependency.metainf.MetaInfWriter;
-import org.jboss.maven.extension.dependency.metainf.generator.EffectivePomGenerator;
-import org.jboss.maven.extension.dependency.modelmodifier.ModelModifier;
-import org.jboss.maven.extension.dependency.modelmodifier.versionoverride.DepVersionOverrider;
-import org.jboss.maven.extension.dependency.modelmodifier.versionoverride.PluginVersionOverrider;
-import org.jboss.maven.extension.dependency.resolver.EffectiveModelBuilder;
-import org.jboss.maven.extension.dependency.util.log.Logging;
-import org.sonatype.aether.impl.ArtifactResolver;
-
-/**
- * Main executor. Operates at the point defined by superclass as "afterProjectsRead", which is "after all MavenProject
- * instances have been created". This should allow access to the model(s) after they are built, but before they are
- * used.
- */
-@Component( role = AbstractMavenLifecycleParticipant.class, hint = "modifymodel" )
-public class ModifyModelLifecycleParticipant
- extends AbstractMavenLifecycleParticipant
-{
- private static final Logger logger = Logging.getLogger();
-
- private final List buildModifierList = new ArrayList();
-
- @Requirement
- private ArtifactResolver resolver;
-
- @Requirement
- private ModelBuilder modelBuilder;
-
- /**
- * Load the build modifiers at instantiation time
- */
- public ModifyModelLifecycleParticipant()
- {
- logger.debug( "New ModifyModelLifecycleParticipant contructed" );
-
- buildModifierList.add( new DepVersionOverrider() );
- buildModifierList.add( new PluginVersionOverrider() );
-
- }
-
- @Override
- public void afterProjectsRead( MavenSession session )
- throws MavenExecutionException
- {
-
- try
- {
- EffectiveModelBuilder.init( session, resolver, modelBuilder );
- }
- catch ( ComponentLookupException e )
- {
- logger.fatalError( "EffectiveModelBuilder init could not look up plexus component: " + e );
- }
- catch ( PlexusContainerException e )
- {
- logger.fatalError( "EffectiveModelBuilder init produced a plexus container error: " + e );
- }
-
- // Apply model modifiers to the projects' models
- for ( MavenProject project : session.getProjects() )
- {
- logger.debug( "Checking project '" + project.getId() + "'" );
-
- int modelChangeCount = 0;
- Model currModel = project.getModel();
-
- // Run the modifiers against the built model
- for ( ModelModifier currModifier : buildModifierList )
- {
- boolean modelChanged = currModifier.updateModel( currModel );
- if ( modelChanged )
- {
- modelChangeCount++;
- }
- }
-
- // Iff something changed, then it will be useful to output extra info
- if ( modelChangeCount >= 1 )
- {
- logger.debug( "Model changed at least once, writing informational files" );
- try
- {
- MetaInfWriter.writeResource( currModel, new EffectivePomGenerator() );
- }
- catch ( IOException e )
- {
- logger.error( "Could not write the effective POM of model '" + currModel.getId() + "' due to " + e );
- Logging.logAllCauses( logger, e.getCause() );
- }
- }
- }
-
- }
-}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/EffectivePomGenerator.java b/src/main/java/org/jboss/maven/extension/dependency/metainf/EffectivePomGenerator.java
similarity index 75%
rename from src/main/java/org/jboss/maven/extension/dependency/metainf/generator/EffectivePomGenerator.java
rename to src/main/java/org/jboss/maven/extension/dependency/metainf/EffectivePomGenerator.java
index cae08e0..c15e4b2 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/EffectivePomGenerator.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/metainf/EffectivePomGenerator.java
@@ -1,4 +1,19 @@
-package org.jboss.maven.extension.dependency.metainf.generator;
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.metainf;
import java.io.IOException;
import java.io.StringWriter;
diff --git a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/MetaInfGenerator.java b/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfGenerator.java
similarity index 58%
rename from src/main/java/org/jboss/maven/extension/dependency/metainf/generator/MetaInfGenerator.java
rename to src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfGenerator.java
index 8752edf..8d3488a 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/MetaInfGenerator.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfGenerator.java
@@ -1,4 +1,19 @@
-package org.jboss.maven.extension.dependency.metainf.generator;
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.metainf;
import java.io.IOException;
diff --git a/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfWriter.java b/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfWriter.java
index 0ebd35c..3cb161e 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfWriter.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/metainf/MetaInfWriter.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.metainf;
import java.io.File;
@@ -8,16 +23,13 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.Resource;
import org.codehaus.plexus.logging.Logger;
-import org.jboss.maven.extension.dependency.metainf.generator.MetaInfGenerator;
-import org.jboss.maven.extension.dependency.util.log.Logging;
+import org.jboss.maven.extension.dependency.util.Log;
/**
* This class writes out metainf resources to be included with the jar at META-INF/maven/group/project/
*/
public class MetaInfWriter
{
- private static Logger logger = Logging.getLogger();
-
/**
* A unique name to use for a prefix in temp output
*/
@@ -76,7 +88,7 @@ public static void writeResource( Model model, MetaInfGenerator generator )
model.getBuild().addResource( newResource );
// Done
- logger.debug( desc + " written and included for '" + projectGroupID + ":" + projectArtifactID + "'" );
+ Log.getLog().debug( desc + " written and included for '" + projectGroupID + ":" + projectArtifactID + "'" );
}
/**
diff --git a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/OverridePropertiesGenerator.java b/src/main/java/org/jboss/maven/extension/dependency/metainf/OverridePropertiesGenerator.java
similarity index 64%
rename from src/main/java/org/jboss/maven/extension/dependency/metainf/generator/OverridePropertiesGenerator.java
rename to src/main/java/org/jboss/maven/extension/dependency/metainf/OverridePropertiesGenerator.java
index 514fa1d..410404a 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/metainf/generator/OverridePropertiesGenerator.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/metainf/OverridePropertiesGenerator.java
@@ -1,4 +1,19 @@
-package org.jboss.maven.extension.dependency.metainf.generator;
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.metainf;
import java.io.IOException;
import java.util.Map;
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/ModelModifier.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/ModelModifier.java
index 09de857..9051dfd 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/ModelModifier.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/ModelModifier.java
@@ -1,5 +1,21 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.modelmodifier;
+import org.apache.maven.MavenExecutionException;
import org.apache.maven.model.Model;
/**
@@ -9,15 +25,15 @@ public interface ModelModifier
{
/**
* Possibly updates a model in some way (may do nothing).
- *
+ *
* @param model the Model to be modified
- * @return true iff the model changed
+ * @return true if the model changed
*/
- public boolean updateModel( Model model );
+ public boolean updateModel( Model model ) throws MavenExecutionException;
/**
* Get simple name of this modifier
- *
+ *
* @return Simple name of this modifier
*/
public String getName();
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/SessionModifier.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/SessionModifier.java
new file mode 100644
index 0000000..e55551e
--- /dev/null
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/SessionModifier.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.modelmodifier;
+
+import org.apache.maven.execution.MavenSession;
+
+/**
+ * Interface for classes that modify a session in some way
+ */
+public interface SessionModifier
+{
+ /**
+ * Possibly updates a session in some way (may do nothing).
+ *
+ * @param session the Session to be modified
+ * @return true if the session changed
+ */
+ public boolean updateSession( MavenSession session );
+
+ /**
+ * Get simple name of this modifier
+ *
+ * @return Simple name of this modifier
+ */
+ public String getName();
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/propertyoverride/PropertyMappingOverrider.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/propertyoverride/PropertyMappingOverrider.java
new file mode 100644
index 0000000..fd1c170
--- /dev/null
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/propertyoverride/PropertyMappingOverrider.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.modelmodifier.propertyoverride;
+
+import java.util.Properties;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.building.ModelBuildingException;
+import org.jboss.maven.extension.dependency.modelmodifier.SessionModifier;
+import org.jboss.maven.extension.dependency.resolver.EffectiveModelBuilder;
+import org.jboss.maven.extension.dependency.util.Log;
+import org.jboss.maven.extension.dependency.util.MavenUtil;
+import org.sonatype.aether.resolution.ArtifactDescriptorException;
+import org.sonatype.aether.resolution.ArtifactResolutionException;
+
+/**
+ * Overrides properties in a model
+ */
+public class PropertyMappingOverrider
+ implements SessionModifier
+{
+ /**
+ * A short description of the thing being overridden
+ */
+ private static final String OVERRIDE_NAME = "property";
+
+ /**
+ * The name of the property which contains the GAV of the remote pom from which to retrieve property mapping
+ * information.
+ * ex: -DpropertyManagement:org.foo:bar-property-mgmt:1.0
+ */
+ private static final String PROPERTY_MANAGEMENT_POM_PROPERTY = "propertyManagement";
+
+ /**
+ * Cache for override properties. Null until getVersionOverrides() is called.
+ */
+ private Properties propertyMappingOverrides;
+
+ @Override
+ public boolean updateSession( MavenSession model )
+ {
+ Properties versionOverrides = getPropertyOverrides();
+
+ if ( versionOverrides.size() == 0 )
+ {
+ return false;
+ }
+ model.getUserProperties().putAll(versionOverrides);
+
+ if (Log.getLog().isDebugEnabled())
+ {
+ StringBuffer sb = new StringBuffer("Got property overrides ");
+ for (String s : versionOverrides.stringPropertyNames())
+ {
+ sb.append("\n\t" + s + " = " + versionOverrides.getProperty(s));
+ }
+ Log.getLog().debug(sb.toString());
+ }
+
+ // Assuming the Model changed since overrides were given
+ return true;
+ }
+
+ @Override
+ public String getName()
+ {
+ return OVERRIDE_NAME;
+ }
+
+ /**
+ * Get the set of versions which will be used to override local property versions.
+ */
+ private Properties getPropertyOverrides()
+ {
+ if ( propertyMappingOverrides == null )
+ {
+ propertyMappingOverrides = new Properties();
+
+ Properties remotePropertyOverrides = loadRemotePropertyMappingOverrides();
+ propertyMappingOverrides.putAll( remotePropertyOverrides );
+ }
+ return propertyMappingOverrides;
+ }
+
+ /**
+ * Get property mappings from a remote POM
+ *
+ * @return Map between the GA of the plugin and the version of the plugin. If the system property is not set,
+ * returns an empty map.
+ */
+ private static Properties loadRemotePropertyMappingOverrides()
+ {
+ Properties systemProperties = System.getProperties();
+ String pluginMgmtCSV = systemProperties.getProperty( PROPERTY_MANAGEMENT_POM_PROPERTY );
+
+ Properties versionOverrides = new Properties();
+
+ if ( pluginMgmtCSV == null )
+ {
+ return versionOverrides;
+ }
+
+ String[] pluginMgmtPomGAVs = pluginMgmtCSV.split( "," );
+
+ // Iterate in reverse order so that the first GAV in the list overwrites the last
+ for ( int i = ( pluginMgmtPomGAVs.length - 1 ); i > -1; --i )
+ {
+ String nextGAV = pluginMgmtPomGAVs[i];
+
+ if ( !MavenUtil.validGav( nextGAV ) )
+ {
+ Log.getLog().warn( "Skipping invalid remote plugin management GAV: " + nextGAV );
+ continue;
+ }
+ try
+ {
+ EffectiveModelBuilder resolver = EffectiveModelBuilder.getInstance();
+ versionOverrides.putAll( resolver.getRemotePropertyMappingOverrides( nextGAV ) );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ Log.getLog().warn( "Unable to resolve remote pom: " + e );
+ e.printStackTrace();
+ }
+ catch ( ArtifactDescriptorException e )
+ {
+ Log.getLog().warn( "Unable to resolve remote pom: " + e );
+ }
+ catch ( ModelBuildingException e )
+ {
+ Log.getLog().warn( "Unable to resolve remote pom: " + e );
+ }
+ }
+ return versionOverrides;
+ }
+}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/AbstractVersionOverrider.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/AbstractVersionOverrider.java
index fe02e7d..35102a2 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/AbstractVersionOverrider.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/AbstractVersionOverrider.java
@@ -1,14 +1,28 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.modelmodifier.versionoverride;
import java.io.IOException;
import java.util.Map;
import org.apache.maven.model.Model;
-import org.codehaus.plexus.logging.Logger;
import org.jboss.maven.extension.dependency.metainf.MetaInfWriter;
-import org.jboss.maven.extension.dependency.metainf.generator.OverridePropertiesGenerator;
+import org.jboss.maven.extension.dependency.metainf.OverridePropertiesGenerator;
import org.jboss.maven.extension.dependency.modelmodifier.ModelModifier;
-import org.jboss.maven.extension.dependency.util.log.Logging;
+import org.jboss.maven.extension.dependency.util.Log;
/**
* Abstract class that provides fields and methods common to classes that need to override versions by groupID and
@@ -17,15 +31,6 @@
public abstract class AbstractVersionOverrider
implements ModelModifier
{
- /**
- * Logging abstraction
- */
- private static final Logger logger = Logging.getLogger();
-
- protected static Logger getLog()
- {
- return logger;
- }
/**
* The character used to separate groupId:arifactId:version
@@ -47,8 +52,8 @@ protected static void writeOverrideMap( Model model, String overrideName, Map
- * ex: -DaddNewDeps=true
+ * The name of the property that specifies whether or not to override transitive dependencies in the build. This
+ * causes non-matching dependencies to be added to the dependency management section of the pom. Default is true.
+ * ex: -overrideTransitive=true
*/
- private static final String ADD_NON_MATCHING = "addNewDeps";
+ private static final String OVERRIDE_TRANSITIVE = "overrideTransitive";
/**
* The name of the property which contains the GAV of the remote pom from which to retrieve dependency management
@@ -49,11 +71,16 @@ public class DepVersionOverrider
*/
private Map dependencyVersionOverrides;
+ /**
+ * The set of projects currently in the reactor. The versions of these projects should not be overridden.
+ */
+ private Set reactorProjects;
+
/**
* Modify model's dependency management and direct dependencies.
*/
@Override
- public boolean updateModel( Model model )
+ public boolean updateModel( Model model ) throws MavenExecutionException
{
Map versionOverrides = getVersionOverrides();
if ( versionOverrides.size() == 0 )
@@ -61,19 +88,28 @@ public boolean updateModel( Model model )
return false;
}
+ versionOverrides = removeReactorGAs( versionOverrides );
+
+ String projectGA = model.getGroupId() + ":" + model.getArtifactId();
+
+ versionOverrides = applyModuleVersionOverrides( projectGA, versionOverrides );
+
+ // Add/override a property to the build for each override
+ addVersionOverrideProperties( versionOverrides, model.getProperties() );
+
// If the model doesn't have any Dependency Management set by default, create one for it
DependencyManagement dependencyManagement = model.getDependencyManagement();
if ( dependencyManagement == null )
{
dependencyManagement = new DependencyManagement();
model.setDependencyManagement( dependencyManagement );
- getLog().debug( "Created new Dependency Management for model" );
+ Log.getLog().debug( "Added for current project" );
}
- // Apply overrides to Dependency Management
+ // Apply overrides to project dependency management
List dependencies = dependencyManagement.getDependencies();
Map nonMatchingVersionOverrides = applyOverrides( dependencies, versionOverrides );
- if ( addNewDeps() )
+ if ( overrideTransitive() )
{
// Add dependencies to Dependency Management which did not match any existing dependency
for ( String groupIdArtifactId : nonMatchingVersionOverrides.keySet() )
@@ -88,16 +124,16 @@ public boolean updateModel( Model model )
newDependency.setVersion( artifactVersion );
dependencyManagement.getDependencies().add( newDependency );
- getLog().debug( "New dependency added to Dependency Management: " + groupIdArtifactId + "="
- + artifactVersion );
+ Log.getLog().debug( "New entry added to - " + groupIdArtifactId + ":" +
+ artifactVersion );
}
}
else
{
- getLog().debug( "Non-matching dependencies ignored." );
+ Log.getLog().debug( "Non-matching dependencies ignored." );
}
- // Apply overrides to project dependencies
+ // Apply overrides to project direct dependencies
List projectDependencies = model.getDependencies();
applyOverrides( projectDependencies, versionOverrides );
@@ -108,27 +144,42 @@ public boolean updateModel( Model model )
return true;
}
+ private Set getReactorProjects()
+ {
+ if ( reactorProjects == null || reactorProjects.size() == 0 )
+ {
+ String[] reactorProjectGAs = System.getProperty( "reactorProjectGAs" ).split( "," );
+ reactorProjects = new HashSet( Arrays.asList( reactorProjectGAs ) );
+ }
+ return reactorProjects;
+ }
+
@Override
public String getName()
{
return OVERRIDE_NAME;
}
- private boolean addNewDeps()
+ /**
+ * Whether to override unmanaged transitive dependencies in the build. Has the effect of adding (or not) new entries
+ * to dependency management when no matching dependency is found in the pom. Defaults to true.
+ *
+ * @return
+ */
+ private boolean overrideTransitive()
{
- Properties systemProperties = System.getProperties();
- String addNonMatching = systemProperties.getProperty( ADD_NON_MATCHING );
- if ( addNonMatching != null && addNonMatching.equals( "false" ) )
- {
- return false;
- }
- return true;
+ String overrideTransitive = System.getProperties().getProperty( OVERRIDE_TRANSITIVE, "true" );
+ return overrideTransitive.equals( "true" );
}
/**
- * Get the set of versions which will be used to override local dependency versions.
+ * Get the set of versions which will be used to override local dependency versions. This is the full set of version
+ * overrides from system properties and remote poms.
+ *
+ * The format of the key is "groupId:artifactId[@moduleGroupId:moduleArtifactId]"
+ * The value is the version string
*/
- private Map getVersionOverrides()
+ private Map getVersionOverrides() throws MavenExecutionException
{
if ( dependencyVersionOverrides == null )
{
@@ -140,69 +191,212 @@ private Map getVersionOverrides()
Map propDepOverrides =
VersionPropertyReader.getPropertiesByPrefix( DEPENDENCY_VERSION_OVERRIDE_PREFIX );
dependencyVersionOverrides.putAll( propDepOverrides );
+
}
return dependencyVersionOverrides;
}
+ /**
+ * Remove version overrides which refer to projects in the current reactor.
+ * Projects in the reactor include things like inter-module dependencies
+ * which should never be overridden.
+ *
+ * @param versionOverrides
+ * @return A new Map with the reactor GAs removed.
+ */
+ private Map removeReactorGAs( Map versionOverrides )
+ {
+ Map reducedVersionOverrides = new HashMap( versionOverrides );
+ Set reactorProjects = getReactorProjects();
+ for ( String reactorGA : reactorProjects )
+ {
+ reducedVersionOverrides.remove( reactorGA );
+ }
+ return reducedVersionOverrides;
+ }
+
+ /**
+ * Remove module overrides which do not apply to the current module. Searches the full list of version overrides
+ * for any keys which contain the '@' symbol. Removes these from the version overrides list, and add them back
+ * without the '@' symbol only if they apply to the current module.
+ *
+ * @param versionOverides The full list of version overrides, both global and module specific
+ * @return The map of global and module specific overrides which apply to the given module
+ */
+ private Map applyModuleVersionOverrides( String projectGA, Map versionOverrides )
+ {
+ Map moduleVersionOverrides = new HashMap( versionOverrides );
+ for ( String currentKey : versionOverrides.keySet() )
+ {
+ if ( currentKey.contains( "@" ) )
+ {
+ moduleVersionOverrides.remove( currentKey );
+ String[] artifactAndModule = currentKey.split( "@" );
+ String artifactGA = artifactAndModule[0];
+ String moduleGA = artifactAndModule[1];
+ if ( moduleGA.equals( projectGA ) )
+ {
+ if ( versionOverrides.get( currentKey) != null && versionOverrides.get( currentKey).length() > 0)
+ {
+ moduleVersionOverrides.put( artifactGA, versionOverrides.get( currentKey ) );
+ }
+ else
+ {
+ moduleVersionOverrides.remove(artifactGA);
+ Log.getLog().debug("Ignoring module dependency override for " + moduleGA);
+ }
+ }
+ }
+ }
+ return moduleVersionOverrides;
+ }
+
+ /***
+ * Add properties to the build which match the version overrides.
+ * The property names are in the format
+ */
+ private void addVersionOverrideProperties( Map overrides, Properties props )
+ {
+ String propPrefix = getVersionPropertyPrefix();
+ String gaSeparator = getGASeparator();
+ String propSuffix = getVersionPropertySuffix();
+
+ for (String currentGA : overrides.keySet() )
+ {
+ String versionPropName = propPrefix + currentGA.replace( ":", gaSeparator ) + propSuffix;
+ props.setProperty( versionPropName, overrides.get( currentGA ) );
+ }
+ }
+
+ /**
+ * Get the prefix that should be used for version property names
+ * @return The prefix set in the system properties or the defult DEPENDENCY_VERSION_OVERRIDE_PREFIX
+ */
+ private String getVersionPropertyPrefix()
+ {
+ return System.getProperty( "versionPropertyPrefix", DEPENDENCY_VERSION_OVERRIDE_PREFIX);
+ }
+
+ /**
+ * Get the groupId/artifactId separator
+ * @return The separator set in the system properties, or ":" by default
+ */
+ private String getGASeparator()
+ {
+ return System.getProperty( "versionPropertyGASeparator", ":" );
+ }
+
+ /**
+ * Get the suffix that should be used for version property names
+ * @return The suffix set in the system properties or the default empty string
+ */
+ private String getVersionPropertySuffix()
+ {
+ return System.getProperty( "versionPropertySuffix", "");
+ }
+
/**
* Apply a set of version overrides to a list of dependencies. Return a set of the overrides which were not applied.
- *
+ *
* @param dependencies The list of dependencies
* @param overrides The map of dependency version overrides
* @return The map of overrides that were not matched in the dependencies
*/
private static Map applyOverrides( List dependencies, Map overrides )
+ {
+ Set excludes = new HashSet();
+ return applyOverrides( dependencies, overrides, excludes );
+ }
+
+ /**
+ * Apply a set of version overrides to a list of dependencies. Return a set of the overrides which were not applied.
+ *
+ * @param dependencies The list of dependencies
+ * @param overrides The map of dependency version overrides
+ * @param excludes A set of GAs to ignore when overridding dep versions
+ * @return The map of overrides that were not matched in the dependencies
+ */
+ private static Map applyOverrides( List dependencies, Map overrides,
+ Set excludes )
{
// Duplicate the override map so unused overrides can be easily recorded
- Map nonMatchingVersionOverrides = new HashMap();
- nonMatchingVersionOverrides.putAll( overrides );
+ Map unmatchedVersionOverrides = new HashMap();
+ unmatchedVersionOverrides.putAll( overrides );
// Apply matching overrides to dependencies
for ( Dependency dependency : dependencies )
{
String groupIdArtifactId = dependency.getGroupId() + GAV_SEPERATOR + dependency.getArtifactId();
- if ( overrides.containsKey( groupIdArtifactId ) )
+ if ( overrides.containsKey( groupIdArtifactId ) && !excludes.contains( groupIdArtifactId ) )
{
- String artifactVersion = overrides.get( groupIdArtifactId );
- dependency.setVersion( artifactVersion );
- getLog().debug( "Altered dependency: " + groupIdArtifactId + "=" + artifactVersion );
- nonMatchingVersionOverrides.remove( groupIdArtifactId );
+ String oldVersion = dependency.getVersion();
+ String overrideVersion = overrides.get( groupIdArtifactId );
+
+ if (overrideVersion == null || overrideVersion.length() == 0)
+ {
+ Log.getLog().warn("Unable to align to an empty version for " + groupIdArtifactId + "; ignoring");
+ }
+ else
+ {
+ dependency.setVersion( overrideVersion );
+ Log.getLog().debug( "Altered dependency " + groupIdArtifactId + " " + oldVersion + "->" +
+ overrideVersion );
+ unmatchedVersionOverrides.remove( groupIdArtifactId );
+ }
}
}
- return nonMatchingVersionOverrides;
+ return unmatchedVersionOverrides;
}
/**
* Get dependency management version properties from a remote POM
- *
- * @return Map between the GA of the dependency and the version of the dependency.
+ *
+ * @return Map between the GA of the dependency and the version of the dependency. If the property is not set,
+ * returns an empty map
*/
- private static Map loadRemoteDepVersionOverrides()
+ private static Map loadRemoteDepVersionOverrides() throws MavenExecutionException
{
Properties systemProperties = System.getProperties();
- String depMgmtPomGAV = systemProperties.getProperty( DEPENDENCY_MANAGEMENT_POM_PROPERTY );
+ String depMgmtPomCSV = systemProperties.getProperty( DEPENDENCY_MANAGEMENT_POM_PROPERTY );
Map versionOverrides = new HashMap( 0 );
- if ( depMgmtPomGAV != null )
+ if ( depMgmtPomCSV == null )
{
+ return versionOverrides;
+ }
+
+ String[] depMgmtPomGAVs = depMgmtPomCSV.split( "," );
+
+ // Iterate in reverse order so that the first GAV in the list overwrites the last
+ for ( int i = ( depMgmtPomGAVs.length - 1 ); i > -1; --i )
+ {
+ String nextGAV = depMgmtPomGAVs[i];
+ if ( !MavenUtil.validGav( nextGAV ) )
+ {
+ Log.getLog().warn( "Skipping invalid dependency management GAV: " + nextGAV );
+ continue;
+ }
try
{
EffectiveModelBuilder resolver = EffectiveModelBuilder.getInstance();
- versionOverrides = resolver.getRemoteDependencyVersionOverrides( depMgmtPomGAV );
+ versionOverrides.putAll( resolver.getRemoteDependencyVersionOverrides( nextGAV ) );
}
catch ( ArtifactResolutionException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
catch ( ArtifactDescriptorException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
catch ( ModelBuildingException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/PluginVersionOverrider.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/PluginVersionOverrider.java
index b90e3ae..a865054 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/PluginVersionOverrider.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/PluginVersionOverrider.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.modelmodifier.versionoverride;
import java.util.HashMap;
@@ -5,11 +20,14 @@
import java.util.Map;
import java.util.Properties;
+import org.apache.maven.MavenExecutionException;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.building.ModelBuildingException;
import org.jboss.maven.extension.dependency.resolver.EffectiveModelBuilder;
+import org.jboss.maven.extension.dependency.util.Log;
+import org.jboss.maven.extension.dependency.util.MavenUtil;
import org.jboss.maven.extension.dependency.util.VersionPropertyReader;
import org.sonatype.aether.resolution.ArtifactDescriptorException;
import org.sonatype.aether.resolution.ArtifactResolutionException;
@@ -44,7 +62,7 @@ public class PluginVersionOverrider
private Map pluginVersionOverrides;
@Override
- public boolean updateModel( Model model )
+ public boolean updateModel( Model model ) throws MavenExecutionException
{
Map versionOverrides = getVersionOverrides();
if ( versionOverrides.size() == 0 )
@@ -58,7 +76,7 @@ public boolean updateModel( Model model )
{
pluginManagement = new PluginManagement();
model.getBuild().setPluginManagement( pluginManagement );
- getLog().debug( "Created new Plugin Management for model" );
+ Log.getLog().debug( "Created new Plugin Management for model" );
}
// Override plugin management versions
@@ -84,14 +102,14 @@ public String getName()
/**
* Get the set of versions which will be used to override local plugin versions.
*/
- private Map getVersionOverrides()
+ private Map getVersionOverrides() throws MavenExecutionException
{
if ( pluginVersionOverrides == null )
{
pluginVersionOverrides = new HashMap();
- Map remoteDepOverrides = loadRemotePluginVersionOverrides();
- pluginVersionOverrides.putAll( remoteDepOverrides );
+ Map remotePluginOverrides = loadRemotePluginVersionOverrides();
+ pluginVersionOverrides.putAll( remotePluginOverrides );
Map propPluginOverrides =
VersionPropertyReader.getPropertiesByPrefix( PLUGIN_VERSION_OVERRIDE_PREFIX );
@@ -115,7 +133,7 @@ private static void applyOverrides( List plugins, Map pl
{
String overrideVersion = pluginVersionOverrides.get( groupIdArtifactId );
plugin.setVersion( overrideVersion );
- getLog().debug( "Altered plugin: " + groupIdArtifactId + "=" + overrideVersion );
+ Log.getLog().debug( "Altered plugin: " + groupIdArtifactId + "=" + overrideVersion );
}
}
}
@@ -123,36 +141,54 @@ private static void applyOverrides( List plugins, Map pl
/**
* Get plugin management version properties from a remote POM
*
- * @return Map between the GA of the plugin and the version of the plugin.
+ * @return Map between the GA of the plugin and the version of the plugin. If the system property is not set,
+ * returns an empty map.
*/
- private static Map loadRemotePluginVersionOverrides()
+ private static Map loadRemotePluginVersionOverrides() throws MavenExecutionException
{
Properties systemProperties = System.getProperties();
- String pluginMgmtPomGAV = systemProperties.getProperty( PLUGIN_MANAGEMENT_POM_PROPERTY );
+ String pluginMgmtCSV = systemProperties.getProperty( PLUGIN_MANAGEMENT_POM_PROPERTY );
Map versionOverrides = new HashMap( 0 );
- if ( pluginMgmtPomGAV != null )
+ if ( pluginMgmtCSV == null )
+ {
+ return versionOverrides;
+ }
+
+ String[] pluginMgmtPomGAVs = pluginMgmtCSV.split( "," );
+
+ // Iterate in reverse order so that the first GAV in the list overwrites the last
+ for ( int i = ( pluginMgmtPomGAVs.length - 1 ); i > -1; --i )
{
+ String nextGAV = pluginMgmtPomGAVs[i];
+
+ if ( !MavenUtil.validGav( nextGAV ) )
+ {
+ Log.getLog().warn( "Skipping invalid plugin management GAV: " + nextGAV );
+ continue;
+ }
try
{
EffectiveModelBuilder resolver = EffectiveModelBuilder.getInstance();
- versionOverrides = resolver.getRemotePluginVersionOverrides( pluginMgmtPomGAV );
+ versionOverrides.putAll( resolver.getRemotePluginVersionOverrides( nextGAV ) );
}
catch ( ArtifactResolutionException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
catch ( ArtifactDescriptorException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
catch ( ModelBuildingException e )
{
- getLog().warn( "Unable to resolve remote pom: " + e );
+ Log.getLog().error( "Unable to resolve remote pom: " + e );
+ throw new MavenExecutionException("Unable to resolve remote pom", e);
}
}
-
return versionOverrides;
}
}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/VersionOverrideInfo.java b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/VersionOverrideInfo.java
index 6000c7c..f07a853 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/VersionOverrideInfo.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/modelmodifier/versionoverride/VersionOverrideInfo.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.modelmodifier.versionoverride;
public class VersionOverrideInfo
diff --git a/src/main/java/org/jboss/maven/extension/dependency/resolver/BasicModelResolver.java b/src/main/java/org/jboss/maven/extension/dependency/resolver/BasicModelResolver.java
index 9abd49f..7ba9e06 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/resolver/BasicModelResolver.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/resolver/BasicModelResolver.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.resolver;
import java.io.File;
@@ -23,9 +38,7 @@
import org.sonatype.aether.util.artifact.DefaultArtifact;
/**
- * Basic implementation of ModelResolver to resolve pom files from
- * a remote repository.
- *
+ * Basic implementation of ModelResolver to resolve pom files from a remote repository.
*/
public class BasicModelResolver
implements ModelResolver
@@ -41,9 +54,8 @@ public class BasicModelResolver
private List repositories;
- public BasicModelResolver( RepositorySystemSession session,
- ArtifactResolver resolver, RemoteRepositoryManager remoteRepositoryManager,
- List repositories )
+ public BasicModelResolver( RepositorySystemSession session, ArtifactResolver resolver,
+ RemoteRepositoryManager remoteRepositoryManager, List repositories )
{
this.session = session;
this.resolver = resolver;
diff --git a/src/main/java/org/jboss/maven/extension/dependency/resolver/EffectiveModelBuilder.java b/src/main/java/org/jboss/maven/extension/dependency/resolver/EffectiveModelBuilder.java
index 3e9f46e..6ec47d7 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/resolver/EffectiveModelBuilder.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/resolver/EffectiveModelBuilder.java
@@ -1,25 +1,44 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.resolver;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.building.DefaultModelBuildingRequest;
+import org.apache.maven.model.building.DefaultModelProblem;
import org.apache.maven.model.building.ModelBuilder;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingResult;
+import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.resolution.ModelResolver;
import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.logging.Logger;
-import org.jboss.maven.extension.dependency.util.log.Logging;
+import org.jboss.maven.extension.dependency.util.Log;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.artifact.Artifact;
@@ -42,8 +61,6 @@
public class EffectiveModelBuilder
{
- private static final Logger logger = Logging.getLogger();
-
private static EffectiveModelBuilder instance;
private MavenSession session;
@@ -54,18 +71,47 @@ public class EffectiveModelBuilder
private ModelBuilder modelBuilder;
+ /**
+ * Repositories for downloading remote poms
+ */
private List repositories;
- public List getRepositories()
+ /**
+ * Get list of remote repositories from which to download artifacts
+ *
+ * @return list of repositories
+ */
+ private List getRepositories()
{
+ if ( repositories == null )
+ {
+ repositories = new ArrayList();
+ }
+
return repositories;
}
+ /**
+ * Set the list of remote repositories from which to download dependency management poms.
+ *
+ * @param repositories
+ */
public void setRepositories( List repositories )
{
this.repositories = repositories;
}
+ /**
+ * Set the list of remote repositories from which to download dependency management poms.
+ *
+ * @param repository
+ */
+ public void addRepository( ArtifactRepository repository )
+ {
+ RemoteRepository remoteRepo = new RemoteRepository( repository.getId(), "default", repository.getUrl() );
+ getRepositories().add( remoteRepo );
+ }
+
/**
* Private constructor for singleton
*/
@@ -82,11 +128,31 @@ public static void init( MavenSession session, ArtifactResolver resolver, ModelB
instance.repositorySystem = newRepositorySystem();
instance.resolver = resolver;
instance.modelBuilder = modelBuilder;
+ initRepositories( session.getRequest().getRemoteRepositories() );
+ }
+
+ /**
+ * Initialize the set of repositories from which to download remote artifacts
+ *
+ * @param repositories
+ */
+ private static void initRepositories( List repositories )
+ {
+ if ( repositories == null || repositories.size() == 0 )
+ {
+ // Set default repository list to include Maven central
+ String remoteRepoUrl = "http://repo.maven.apache.org/maven2";
+ instance.getRepositories().add( new RemoteRepository( "central", "default", remoteRepoUrl ) );
+ }
+ for ( ArtifactRepository artifactRepository : repositories )
+ {
+ instance.addRepository( artifactRepository );
+ }
}
/**
* Return the instance. Will return "null" until init() has been called.
- *
+ *
* @return the initialized instance or null if it hasn't been initialized yet
*/
public static EffectiveModelBuilder getInstance()
@@ -99,19 +165,27 @@ public Map getRemoteDependencyVersionOverrides( String gav )
{
Map versionOverrides = new HashMap();
- System.out.println( "resolving gav: " + gav );
+ Log.getLog().debug( "Resolving dependency management GAV: " + gav );
Artifact artifact = resolvePom( gav );
ModelResolver modelResolver = this.newModelResolver();
Model effectiveModel = buildModel( artifact.getFile(), modelResolver );
- System.out.println( "Built model for project: " + effectiveModel.getName() );
+ Log.getLog().debug( "Built model for project: " + effectiveModel.getName() );
+
+ if ( effectiveModel.getDependencyManagement() == null )
+ {
+ ModelProblem dmp = new DefaultModelProblem(
+ "Attempting to align to a BOM that does not have a dependencyManagement section",
+ null, null, -1, -1, null );
+ throw new ModelBuildingException( effectiveModel, effectiveModel.getId(), Collections.singletonList( dmp ) );
+ }
for ( org.apache.maven.model.Dependency dep : effectiveModel.getDependencyManagement().getDependencies() )
{
String groupIdArtifactId = dep.getGroupId() + ":" + dep.getArtifactId();
versionOverrides.put( groupIdArtifactId, dep.getVersion() );
- System.out.println( "Added version override for: " + groupIdArtifactId + ":" + dep.getVersion() );
+ Log.getLog().debug( "Added version override for: " + groupIdArtifactId + ":" + dep.getVersion() );
}
return versionOverrides;
@@ -134,11 +208,30 @@ public Map getRemoteDependencyVersionOverridesOld( String gav )
return versionOverrides;
}
+
+ public Properties getRemotePropertyMappingOverrides( String gav )
+ throws ArtifactResolutionException, ArtifactDescriptorException, ModelBuildingException
+ {
+ Log.getLog().debug( "Resolving remote property mapping POM: " + gav );
+
+ Artifact artifact = resolvePom( gav );
+
+ ModelResolver modelResolver = this.newModelResolver();
+
+ Model effectiveModel = buildModel( artifact.getFile(), modelResolver );
+
+ Properties versionOverrides = effectiveModel.getProperties();
+
+ Log.getLog().debug( "Returning override of " + versionOverrides);
+
+ return versionOverrides;
+ }
+
public Map getRemotePluginVersionOverrides( String gav )
throws ArtifactResolutionException, ArtifactDescriptorException, ModelBuildingException
{
- logger.debug( "Resolving remote POM: " + gav );
+ Log.getLog().debug( "Resolving remote plugin management POM: " + gav );
Artifact artifact = resolvePom( gav );
@@ -164,7 +257,7 @@ public ArtifactDescriptorResult resolveRemoteArtifactDescriptor( String gav )
throws ArtifactResolutionException, ArtifactDescriptorException
{
- logger.debug( "Resolving remote POM: " + gav );
+ Log.getLog().debug( "Resolving remote POM: " + gav );
RepositorySystemSession repoSession = session.getRepositorySession();
@@ -172,41 +265,22 @@ public ArtifactDescriptorResult resolveRemoteArtifactDescriptor( String gav )
ArtifactDescriptorRequest descRequest = new ArtifactDescriptorRequest();
descRequest.setArtifact( artifact );
- descRequest.setRepositories( getRemoteRepositories() );
+ descRequest.setRepositories( getRepositories() );
ArtifactDescriptorResult descResult = repositorySystem.readArtifactDescriptor( repoSession, descRequest );
for ( Dependency dep : descResult.getManagedDependencies() )
{
- logger.info( "Remote managed dep: " + dep );
+ Log.getLog().info( "Remote managed dep: " + dep );
}
- System.out.println( artifact + " resolved to " + artifact.getFile() );
+ Log.getLog().debug( artifact + " resolved to " + artifact.getFile() );
return descResult;
}
- /**
- * Get list of remote repositories from which to download artifacts
- *
- * @return list of repositories
- */
- private List getRemoteRepositories()
- {
- if ( repositories == null )
- {
- // Set default repository list to include Maven central
- repositories = new ArrayList();
-
- String remoteRepoUrl = "http://repo1.maven.org/maven2/";
- repositories.add( new RemoteRepository( "central", "default", remoteRepoUrl ) );
- }
-
- return repositories;
- }
-
/**
* Build the effective model for the given pom file
- *
+ *
* @param pomFile
* @return effective pom model
* @throws ModelBuildingException
@@ -226,7 +300,7 @@ private Model buildModel( File pomFile, ModelResolver modelResolver )
/**
* Get the default repository system from the current plexus container
- *
+ *
* @return RepositorySystem
* @throws ComponentLookupException
* @throws PlexusContainerException
@@ -239,8 +313,8 @@ private static RepositorySystem newRepositorySystem()
/**
* Resolve the pom file for a given GAV
- *
- * @param gav
+ *
+ * @param gav must be in the format groupId:artifactId:version
* @return The resolved pom artifact
* @throws ArtifactResolutionException
*/
@@ -261,7 +335,7 @@ private Artifact resolvePom( String gav )
/**
* Resolve artifact from the remote repository
- *
+ *
* @param artifact
* @return
* @throws ArtifactResolutionException
@@ -271,7 +345,7 @@ private Artifact resolveArtifact( Artifact artifact )
{
ArtifactRequest request = new ArtifactRequest();
request.setArtifact( artifact );
- request.setRepositories( getRemoteRepositories() );
+ request.setRepositories( getRepositories() );
RepositorySystemSession repositorySession = session.getRepositorySession();
ArtifactResult result = resolver.resolveArtifact( repositorySession, request );
@@ -282,7 +356,7 @@ private ModelResolver newModelResolver()
{
RemoteRepositoryManager repoMgr = new DefaultRemoteRepositoryManager();
ModelResolver modelResolver =
- new BasicModelResolver( session.getRepositorySession(), resolver, repoMgr, getRemoteRepositories() );
+ new BasicModelResolver( session.getRepositorySession(), resolver, repoMgr, getRepositories() );
return modelResolver;
}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/util/Log.java b/src/main/java/org/jboss/maven/extension/dependency/util/Log.java
new file mode 100644
index 0000000..6af2b92
--- /dev/null
+++ b/src/main/java/org/jboss/maven/extension/dependency/util/Log.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.util;
+
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+
+/**
+ * Provides a way for classes in the local packages to perform central logging
+ */
+public class Log
+{
+ private static Logger logger;
+
+ /**
+ * Yields the central logger object.
+ *
+ * @return A Logger object, never null.
+ */
+ public static Logger getLog()
+ {
+ // First access creates the logger (on-demand)
+ if ( logger == null )
+ {
+ logger = new ConsoleLogger( Logger.LEVEL_INFO, "Plexus Console Logger" );
+ }
+ return logger;
+ }
+
+ /**
+ * Sets the central logger object.
+ */
+ public static void setLog(Logger logger)
+ {
+ Log.logger = logger;
+ }
+
+ /**
+ * Recursively log all causes in a Throwable chain
+ *
+ * @param cause Will be null in the base case
+ */
+ public static void logAllCauses( Throwable cause )
+ {
+ if ( cause == null )
+ {
+ return;
+ }
+ getLog().error( "Cause: " + cause );
+ logAllCauses( cause.getCause() );
+ }
+}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/util/MavenUtil.java b/src/main/java/org/jboss/maven/extension/dependency/util/MavenUtil.java
new file mode 100644
index 0000000..d247c00
--- /dev/null
+++ b/src/main/java/org/jboss/maven/extension/dependency/util/MavenUtil.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.maven.extension.dependency.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * Basic implementation of org.sonatype.aether.artifact.Artifact
+ */
+public class MavenUtil
+{
+
+ /**
+ * Regex pattern for parsing a Maven GAV
+ */
+ public static final Pattern gavPattern = Pattern.compile( "\\s*([\\w\\-_.]+):([\\w\\-_.]+):(\\d[\\w\\-_.]+)\\s*" );
+
+ public static boolean validGav(String gav)
+ {
+ Matcher matcher = gavPattern.matcher( gav );
+ return matcher.matches();
+ }
+
+}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/util/VersionPropertyReader.java b/src/main/java/org/jboss/maven/extension/dependency/util/VersionPropertyReader.java
index 7fb84d7..30c5239 100644
--- a/src/main/java/org/jboss/maven/extension/dependency/util/VersionPropertyReader.java
+++ b/src/main/java/org/jboss/maven/extension/dependency/util/VersionPropertyReader.java
@@ -1,3 +1,18 @@
+/**
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.jboss.maven.extension.dependency.util;
import java.util.HashMap;
diff --git a/src/main/java/org/jboss/maven/extension/dependency/util/log/Logging.java b/src/main/java/org/jboss/maven/extension/dependency/util/log/Logging.java
deleted file mode 100644
index df72e1a..0000000
--- a/src/main/java/org/jboss/maven/extension/dependency/util/log/Logging.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.jboss.maven.extension.dependency.util.log;
-
-import org.codehaus.plexus.logging.Logger;
-
-/**
- * Provides a way for classes in the local packages to perform central logging
- */
-public class Logging
-{
- private static Logger logger;
-
- /**
- * Yields the central logger object.
- *
- * @return A Logger object, never null.
- */
- public static Logger getLogger()
- {
- // First access creates the logger (on-demand)
- if ( logger == null )
- {
- logger = new StdoutLogger( Logger.LEVEL_DEBUG );
- }
- return logger;
- }
-
- /**
- * Recursively log all causes in a Throwable chain
- *
- * @param cause Will be null in the base case
- */
- public static void logAllCauses( Logger logger, Throwable cause )
- {
- if ( cause == null )
- {
- return;
- }
- logger.error( "Cause: " + cause );
- logAllCauses( logger, cause.getCause() );
- }
-}
diff --git a/src/main/java/org/jboss/maven/extension/dependency/util/log/StdoutLogger.java b/src/main/java/org/jboss/maven/extension/dependency/util/log/StdoutLogger.java
deleted file mode 100644
index 8867b16..0000000
--- a/src/main/java/org/jboss/maven/extension/dependency/util/log/StdoutLogger.java
+++ /dev/null
@@ -1,166 +0,0 @@
-package org.jboss.maven.extension.dependency.util.log;
-
-import org.codehaus.plexus.logging.Logger;
-
-/**
- * Haven't been successful so far hooking into the real log system, this class should hopefully just be a placeholder.
- */
-public class StdoutLogger
- implements Logger
-{
- private static String DEBUG_TICKER = "[DEBUG] ";
-
- private static String INFO_TICKER = "[INFO] ";
-
- private static String WARN_TICKER = "[WARNING] ";
-
- private static String ERROR_TICKER = "[ERROR] ";
-
- private static String FATAL_ERROR_TICKER = "[FATAL] ";
-
- private int threshold;
-
- public StdoutLogger()
- {
- this( LEVEL_DEBUG );
- }
-
- public StdoutLogger( int threshold )
- {
- setThreshold( threshold );
- }
-
- public void debug( String message )
- {
- if ( isDebugEnabled() )
- {
- System.out.println( DEBUG_TICKER + message );
- }
- }
-
- public void debug( String message, Throwable throwable )
- {
- if ( isDebugEnabled() )
- {
- System.out.println( DEBUG_TICKER + message );
- throwable.printStackTrace();
- }
- }
-
- public boolean isDebugEnabled()
- {
- return threshold != LEVEL_DISABLED && threshold <= LEVEL_DEBUG;
- }
-
- public void info( String message )
- {
- if ( isInfoEnabled() )
- {
- System.out.println( INFO_TICKER + message );
- }
- }
-
- public void info( String message, Throwable throwable )
- {
- if ( isInfoEnabled() )
- {
- System.out.println( INFO_TICKER + message );
- throwable.printStackTrace();
- }
- }
-
- public boolean isInfoEnabled()
- {
- return threshold != LEVEL_DISABLED && threshold <= LEVEL_INFO;
- }
-
- public void warn( String message )
- {
- if ( isWarnEnabled() )
- {
- System.out.println( WARN_TICKER + message );
- }
- }
-
- public void warn( String message, Throwable throwable )
- {
- if ( isWarnEnabled() )
- {
- System.out.println( WARN_TICKER + message );
- throwable.printStackTrace();
- }
- }
-
- public boolean isWarnEnabled()
- {
- return threshold != LEVEL_DISABLED && threshold <= LEVEL_WARN;
- }
-
- public void error( String message )
- {
- if ( isErrorEnabled() )
- {
- System.out.println( ERROR_TICKER + message );
- }
- }
-
- public void error( String message, Throwable throwable )
- {
- if ( isErrorEnabled() )
- {
- System.out.println( ERROR_TICKER + message );
- throwable.printStackTrace();
- }
- }
-
- public boolean isErrorEnabled()
- {
- return threshold != LEVEL_DISABLED && threshold <= LEVEL_ERROR;
- }
-
- public void fatalError( String message )
- {
- if ( isFatalErrorEnabled() )
- {
- System.out.println( FATAL_ERROR_TICKER + message );
- }
- }
-
- public void fatalError( String message, Throwable throwable )
- {
- if ( isFatalErrorEnabled() )
- {
- System.out.println( FATAL_ERROR_TICKER + message );
- throwable.printStackTrace();
- }
- }
-
- public boolean isFatalErrorEnabled()
- {
- return threshold != LEVEL_DISABLED && threshold <= LEVEL_FATAL;
- }
-
- public int getThreshold()
- {
- return threshold;
- }
-
- public void setThreshold( int threshold )
- {
- if (threshold < LEVEL_DEBUG || threshold > LEVEL_DISABLED) {
- return;
- }
- this.threshold = threshold;
- }
-
- public Logger getChildLogger( String name )
- {
- return null;
- }
-
- public String getName()
- {
- return null;
- }
-
-}
diff --git a/src/main/resources/org/jboss/maven/extension/dependency/project.properties b/src/main/resources/org/jboss/maven/extension/dependency/project.properties
new file mode 100644
index 0000000..f7663fb
--- /dev/null
+++ b/src/main/resources/org/jboss/maven/extension/dependency/project.properties
@@ -0,0 +1,4 @@
+# Basic properties describing the project
+
+project.name = ${project.name}
+project.version = ${project.version}