[pkg-java] r15740 - in tags/maven-debian-helper: . 1.5 1.5/debian 1.5/maven-build-nodocs 1.5/maven-debian-helper 1.5/maven-debian-plugin 1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin 1.5/maven-packager-utils 1.5/maven-packager-utils/src/main/java/org/debian/maven/packager 1.5/maven-packager-utils/src/main/resources 1.5/maven-packager-utils/src/test/java/org/debian/maven/packager 1.5/maven-packager-utils/src/test/resources 1.5/maven-packager-utils/src/test/resources/repository/org/codehaus/plexus
Ludovic Claude
ludovicc-guest at alioth.debian.org
Tue Jan 24 23:09:55 UTC 2012
Author: ludovicc-guest
Date: 2012-01-24 23:09:55 +0000 (Tue, 24 Jan 2012)
New Revision: 15740
Added:
tags/maven-debian-helper/1.5/
tags/maven-debian-helper/1.5/debian/changelog
tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java
tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.doc-base.api.multi.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.install.multi.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.result.poms
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.rules
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.substvars
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/repository/org/codehaus/plexus/plexus-components/
Removed:
tags/maven-debian-helper/1.5/debian/changelog
tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java
tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms
Modified:
tags/maven-debian-helper/1.5/maven-build-nodocs/pom.xml
tags/maven-debian-helper/1.5/maven-debian-helper/pom.xml
tags/maven-debian-helper/1.5/maven-debian-plugin/pom.xml
tags/maven-debian-helper/1.5/maven-packager-utils/pom.xml
tags/maven-debian-helper/1.5/pom.xml
Log:
[svn-buildpackage] Tagging maven-debian-helper 1.5
Deleted: tags/maven-debian-helper/1.5/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/debian/changelog 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,324 +0,0 @@
-maven-debian-helper (1.5) UNRELEASED; urgency=low
-
- [ Ludovic Claude ]
- * Install jars in /usr/share/java (Closes: #636660)
- * Now requires Java 1.5 or better to compile and run.
- * Remove velocity.log after running mh_make (Closes: #641261)
- * SysInstallMojo: read classifier and java-lib parameters.
- * mh_make: upgrade Standard-Version (Closes: #641302)
- * mh_make: clean up Debian emails of the form My Name<my.name at provider.com>
- (Closes: #638788)
- * mh_make: fix description in generated maven.rules (Closes: #639637)
- * Fix failing tests in DependenciesSolverTest
- * Run unit tests during the build,
- * d/control: add B-D on libcommons-io-java as it's used by the junit tests.
- * Generate package-doc.poms for Ant builds
-
- [ Damien Raude-Morvan ]
- * maven-packager-utils/src/main/resources/build.xml.vm: package-module ant
- macro is always needed (at least for root module).
- * Follow-up for #589635: avoid creating a file called mvn-build during
- the build.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Sun, 08 Jan 2012 14:26:21 +0100
-
-maven-debian-helper (1.4.5) unstable; urgency=low
-
- * SysInstallMojo: Support "finalName" attribute to override
- expected artifact (conform to Maven standards).
- * SysInstallMojo: Read usj-name, usj-version and no-usj-versionless.
- Closes: #629621.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Thu, 01 Sep 2011 22:52:29 +0200
-
-maven-debian-helper (1.4.4) unstable; urgency=low
-
- [ Ludovic Claude ]
- * Move apt-file, devscripts, subversion from Recommends: to Suggests: as
- they are only required when mh_make is used
- * mh_make: rescan the Maven repository after the user installs a
- required package.
-
- [ Damien Raude-Morvan ]
- * Upload to unstable (Closes: #637656).
- * mh_make: Update debian/copyright template for latest DEP-5 format.
- * mh_resolve_dependencies: Don't use mvn directly but call to
- DependenciesSolver main (so packages can have a main pom
- in other directory than root).
- * DependenciesSolver: Add new parameters :
- - --non-explore: doesn't explore directories for pom.xml
- - --base-directory: path to root directory of package
- * maven.mk: Send base-directory and non-explore parameters when calling
- mh_resolve_dependencies.
- * Bump Standards-Version to 3.9.2: no changes needed.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Sat, 20 Aug 2011 16:25:50 +0200
-
-maven-debian-helper (1.4.3) unstable; urgency=low
-
- * DependenciesSolver: Don't use Properties.store() method since
- it escape some chars (like " >\=") from variables.
- Replace it with simple FileWriter. Closes: #628272.
- * SysInstallMojo: Send "--keep-elements" flag to POMCleaner if its
- set in <pkg>.poms file. Thanks to James Page <james.page at canonical.com>.
- Closes: #613364
- * mh_resolve_dependencies: Always launch Maven in offline mode
- with --offline option (as already done on mh_make). Closes: #629356
- * SysInstallDocMojo, SysInstallMojo: Drop initProperties method and only rely
- on Maven mojo attributes injection of "debianPackage" and "destPackage".
- Closes: #628693.
- * mh_resolve_dependencies: New --javadoc param, send from maven.mk CDBS file
- to automatically compute Javadoc dependencies when there is some *-doc
- package. Closes: #628703.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Thu, 09 Jun 2011 00:11:08 +0200
-
-maven-debian-helper (1.4.2) unstable; urgency=low
-
- * mh_resolve_dependencies: Handle --verbose option has described in
- documentation (it was previously just ignored).
- * DependenciesSolver: In case we didn't found anything for "jar" type,
- just check for a "bundle" type inside repository
-
- -- Damien Raude-Morvan <drazzib at debian.org> Sat, 14 May 2011 22:59:17 +0200
-
-maven-debian-helper (1.4.1) unstable; urgency=low
-
- * Upload to unstable.
-
- -- Torsten Werner <twerner at debian.org> Wed, 09 Feb 2011 21:42:36 +0100
-
-maven-debian-helper (1.4) experimental; urgency=low
-
- * d/control: Add Recommends on devscripts (which provides licensecheck)
- * mh_make:
- - Improve generated copyright
- - Fix generated rules for a build using ant
- - When ignoring dependencies, don't fail the build
- - When ant is used as the build tool, generate the build.xml file
- required for multi projects.
- - use licensecheck as an additional source of information for licenses
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Fri, 12 Nov 2010 12:26:37 +0100
-
-maven-debian-helper (1.3) experimental; urgency=low
-
- * ${maven:Depends} and similar substitution vars: add
- version constraints when possible
- * Use dpkg to resolve the dependent packages in ${maven:DocDepends}
- (Closes: #588114)
- * Use dpkg to search for the documentation package (Closes: #588114)
- * mh_make: suggest installing missing dependencies which are not ignored
- during the build
- * add property debian.hasPackageVersion property, if true in the
- repository POM then other packages depending on a POM with this property on
- will have an addition version constraint generated in ${maven:Depends}
- * mh_make: detect when debian.hasPackageVersion can be used, ask for the
- upstream version of the package for confirmation.
- * d/control: add Recommends: on subversion as it's used by mh_make,
- add Build-Depends on libmaven-plugin-tools-java and junit
- * d/build.xml: fix build when previous versions of this package are
- not already installed on the system.
- * d/rules: use debian/.mh instead of debian/tmp as temp directory to better
- comply with Debian policy.
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Wed, 29 Sep 2010 00:17:34 +0200
-
-maven-debian-helper (1.2) unstable; urgency=low
-
- [ Ludovic Claude ]
- * debian/control: Update Standards-Version to 3.9.1, no changes
- * mh_make: fix issue when no-parent option is needed. Thanks Torsten
- for the report (Closes: #591513)
- * mh_make: assist with the rules to transform the versions
- * mh_make: use existing package.poms files if any
- * maven.mk: all rules in maven.ignoreRules are also used during the
- clean phase, so there is no need to duplicate them in
- maven.cleanIgnoreRules also.
-
- [ Damien Raude-Morvan ]
- * DependenciesSolver: Fix ClassCastException when using mh_make.
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Thu, 16 Sep 2010 23:28:02 +0200
-
-maven-debian-helper (1.1) unstable; urgency=low
-
- * debian/control: Update Standards-Version to 3.9.0, no changes
- * Fix compilation issues with gcj
- * mh_make:
- - update generated control to use Standards-Version 3.9.0
- - improve useability and recognize more plugins and extensions
- - read existing maven rules in debian folder, don't ask twice the
- same questions.
- * Support installing build artifacts in different packages with the
- --package option in the <package>.poms file
- * Add mvn-build to phony rules to avoid creating a file called
- mvn-build during the build (Closes: #589635)
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Mon, 28 Jun 2010 23:10:50 +0200
-
-maven-debian-helper (1.0) unstable; urgency=low
-
- * debian/control:
- - replace Depends: on openjdk-6-jre | java2-runtime by default-jdk
- - remove Conflits: on old maven-debian-helper as there is already
- a version constraint for a new version of this package.
- * mh_make:
- - supports checking out code from the svn of dev.java.net
- - use upstream copyright when available for debian/* files
- - update Standards version, generate with source 3.0 (quilt) package
- format
- - mh_make --from-svn: improve package name proposal for URLs
- containing /tags/
- - ask to ignore missing dependencies
- * maven.mk:
- - add before-mvn-build:: and after-mvn-build:: targets
- to be able to insert custom actions before and after running the Maven
- build
- - add DEB_MAVEN_INSTALL_TO_USJ variable. Set this variable to false to
- prevent maven.mk to install the jars in /usr/share/java. This
- variable defaults to true.
- - add call to mh_clean to remove temporary files
- * Add -Duse.maven.repo.local option to maven-debian-plugin:install
- and install-doc to give the option to deploy artifacts on the
- local (and temporary) Maven repository used by the Debian build
- Typical use-case: bootstrapping the build of a project with
- some artifacts of the project pre-built and installed in the tmp repo
- before the normal build is executed. See the antlr3 package for an example
- * SysInstallMojo: clean the target directory before an installation if the
- directory is a symlink that was created by copy-repo.sh
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Sun, 16 May 2010 14:42:29 +0200
-
-maven-debian-helper (0.12) unstable; urgency=low
-
- * SysInstallDocMojo: Fix methods override to install -javadoc JAR flavors.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Mon, 05 Apr 2010 23:46:22 +0200
-
-maven-debian-helper (0.11) unstable; urgency=low
-
- * SysInstallMojo: Read generated pom.properties after POMCleaner
- calls to allow changing groupId and artifactId inside maven.rules
- (trying to mimic mh_installpom/mh_installjar behavior)
- * Switch to 3.0 (native) source format
-
- -- Damien Raude-Morvan <drazzib at debian.org> Mon, 05 Apr 2010 21:48:23 +0200
-
-maven-debian-helper (0.10) unstable; urgency=low
-
- * Add --non-interactive option to mh_lspoms and use it
- in maven.mk to avoid asking questions during a build
- (Closes: #574399)
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Wed, 24 Mar 2010 23:48:29 +0100
-
-maven-debian-helper (0.9) unstable; urgency=low
-
- * maven-vars.mk: Fix detection of DEB_DOC_PACKAGE
- Only exclude first exact match from dh_listpackages result
- instead of all packages which contains main package name.
- * maven.mk: Pass DEB_DOC_PACKAGE when invoke DEB_MAVEN_DOC_TARGET.
-
- -- Damien Raude-Morvan <drazzib at debian.org> Mon, 01 Mar 2010 21:22:34 +0100
-
-maven-debian-helper (0.8) unstable; urgency=low
-
- * mh_make falls back on EMAIL when DEBEMAIL is not set
- * mh_make handles better multi projects
- * mh_make generates projects following the Debian 3.8.3 policy
- * Documentation improvements
- * maven.mk: unpatch the poms in cleanbuilddir, to have a good
- clean sequence when maven.mk is used with a patch system -
- clean target -> mvn clean -> rm tmp files -> unpatch pom files
- -> unpatch files with patch system
- * Read rules from the Maven repository to force the version of
- Maven plugins to be the same as in the repository
- * maven.mk removes some elements from the POM files when their
- use is against the Debian policy (<repositories> as they
- imply downloading artifacts from the Internet,
- <distributionManagement> as it implies publishing on the net
- or in a location not controlled by Debian) or when they are
- not needed and risk pulling out unwanted dependencies
- (<reports> which is not used if a documentation package is
- not generated)
- * maven.mk adds a patch to Maven to disable using the
- maven-site-plugin when no documentation package is generated.
- This helps to reduce the amount of build dependencies
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Mon, 04 Jan 2010 23:13:29 +0100
-
-maven-debian-helper (0.7) unstable; urgency=low
-
- [Ludovic Claude]
- * Make the package more version agnostic. Versions are discovered
- at runtime
- * mh_make has a new option, --from-svn, to download automatically
- the sources from a SVN repository and generate the Debian packaging
- for the project.
- * Add apt-file to Recommends: as it's used by mh_lspoms
- (Closes: #542511)
-
- [Michael Koch]
- * Add Recommends: apt-file to maven-debian-helper (Closes: #542511).
- * Build-Depends on debhelper (>= 7).
- * Added myself to Uploaders.
- * Updated Standards-Version to 3.8.3.
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Thu, 17 Dec 2009 20:09:00 +0100
-
-maven-debian-helper (0.6) unstable; urgency=low
-
- * Update everything to version 0.6 because 2 scripts have still been at
- version 0.4. We should make the package more version agnostic.
-
- -- Torsten Werner <twerner at debian.org> Sun, 16 Aug 2009 15:18:57 +0200
-
-maven-debian-helper (0.5) unstable; urgency=low
-
- * Update Standards-Version to 3.8.2
- * Follow the new convention for Javadoc:
- javadoc in /usr/share/doc/package/api even if it's in package-doc
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Sun, 02 Aug 2009 11:42:31 +0100
-
-maven-debian-helper (0.4) experimental; urgency=low
-
- [Ludovic Claude]
- * Add myself to Uploaders
- * Use maven-ant-helper for the build instead of recursively building
- this package with itself (which required an ugly bootstrap script)
- * Integrate the cdbs helper with maven-repo-helper, this unifies the
- way the Maven repository is used, and simplifies the job of the
- packager as maven-repo-helper takes care of most POM patching work.
- * Use default-jdk for the build
- * Change section to java, update Standards-Version to 3.8.1
- * Generate Javadoc API automatically.
- * Add mh_make tool to generate Debian packaging automatically from
- a Maven project.
-
- [Torsten Werner]
- * Implement pom faking.
-
- -- Ludovic Claude <ludovic.claude at laposte.net> Tue, 14 Jul 2009 20:17:16 +0100
-
-maven-debian-helper (0.3) unstable; urgency=low
-
- * Implement better exception handling.
- * Create our own maven repository during build time.
- * Set version for non plugins to '[$version]' instead of '$version' only.
-
- -- Torsten Werner <twerner at debian.org> Sun, 25 Jan 2009 23:16:20 +0100
-
-maven-debian-helper (0.2) unstable; urgency=low
-
- * Rename the bootstrap script.
- * Add a manpage for mvn-debian.
-
- -- Torsten Werner <twerner at debian.org> Sat, 17 Jan 2009 12:13:35 +0100
-
-maven-debian-helper (0.1) unstable; urgency=low
-
- * Initial release. (Closes: #508511)
-
- -- Torsten Werner <twerner at debian.org> Mon, 05 Jan 2009 11:47:25 +0100
Copied: tags/maven-debian-helper/1.5/debian/changelog (from rev 15739, trunk/maven-debian-helper/debian/changelog)
===================================================================
--- tags/maven-debian-helper/1.5/debian/changelog (rev 0)
+++ tags/maven-debian-helper/1.5/debian/changelog 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,332 @@
+maven-debian-helper (1.5) unstable; urgency=low
+
+ [ Ludovic Claude ]
+ * Install jars in /usr/share/java (Closes: #636660)
+ * Now requires Java 1.5 or better to compile and run.
+ * Remove velocity.log after running mh_make (Closes: #641261)
+ * SysInstallMojo: read classifier and java-lib parameters.
+ * mh_make: upgrade Standard-Version (Closes: #641302)
+ * mh_make: clean up Debian emails of the form My Name<my.name at provider.com>
+ (Closes: #638788)
+ * mh_make: fix description in generated maven.rules (Closes: #639637)
+ * mh_make: add support to generate and install Javadoc on multi projects
+ during an Ant build.
+ * Fix failing tests in DependenciesSolverTest
+ * Run unit tests during the build,
+ * d/control: add B-D on libcommons-io-java as it's used by the junit tests.
+ * Generate package-doc.poms for Ant builds
+ * mh_make: fix resolution of versionless dependencies and missing
+ parent POMs (Closes: #639316)
+ * mh_make: Don't include document packages in the dependency search
+ (Closes: #656235)
+ * Fix installation of javadoc jar (Closes: #656311)
+ * Fix installation of artifacts using a classifier
+
+ [ Damien Raude-Morvan ]
+ * maven-packager-utils/src/main/resources/build.xml.vm: package-module ant
+ macro is always needed (at least for root module).
+ * Follow-up for #589635: avoid creating a file called mvn-build during
+ the build.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Tue, 24 Jan 2012 23:55:22 +0100
+
+maven-debian-helper (1.4.5) unstable; urgency=low
+
+ * SysInstallMojo: Support "finalName" attribute to override
+ expected artifact (conform to Maven standards).
+ * SysInstallMojo: Read usj-name, usj-version and no-usj-versionless.
+ Closes: #629621.
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Thu, 01 Sep 2011 22:52:29 +0200
+
+maven-debian-helper (1.4.4) unstable; urgency=low
+
+ [ Ludovic Claude ]
+ * Move apt-file, devscripts, subversion from Recommends: to Suggests: as
+ they are only required when mh_make is used
+ * mh_make: rescan the Maven repository after the user installs a
+ required package.
+
+ [ Damien Raude-Morvan ]
+ * Upload to unstable (Closes: #637656).
+ * mh_make: Update debian/copyright template for latest DEP-5 format.
+ * mh_resolve_dependencies: Don't use mvn directly but call to
+ DependenciesSolver main (so packages can have a main pom
+ in other directory than root).
+ * DependenciesSolver: Add new parameters :
+ - --non-explore: doesn't explore directories for pom.xml
+ - --base-directory: path to root directory of package
+ * maven.mk: Send base-directory and non-explore parameters when calling
+ mh_resolve_dependencies.
+ * Bump Standards-Version to 3.9.2: no changes needed.
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Sat, 20 Aug 2011 16:25:50 +0200
+
+maven-debian-helper (1.4.3) unstable; urgency=low
+
+ * DependenciesSolver: Don't use Properties.store() method since
+ it escape some chars (like " >\=") from variables.
+ Replace it with simple FileWriter. Closes: #628272.
+ * SysInstallMojo: Send "--keep-elements" flag to POMCleaner if its
+ set in <pkg>.poms file. Thanks to James Page <james.page at canonical.com>.
+ Closes: #613364
+ * mh_resolve_dependencies: Always launch Maven in offline mode
+ with --offline option (as already done on mh_make). Closes: #629356
+ * SysInstallDocMojo, SysInstallMojo: Drop initProperties method and only rely
+ on Maven mojo attributes injection of "debianPackage" and "destPackage".
+ Closes: #628693.
+ * mh_resolve_dependencies: New --javadoc param, send from maven.mk CDBS file
+ to automatically compute Javadoc dependencies when there is some *-doc
+ package. Closes: #628703.
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Thu, 09 Jun 2011 00:11:08 +0200
+
+maven-debian-helper (1.4.2) unstable; urgency=low
+
+ * mh_resolve_dependencies: Handle --verbose option has described in
+ documentation (it was previously just ignored).
+ * DependenciesSolver: In case we didn't found anything for "jar" type,
+ just check for a "bundle" type inside repository
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Sat, 14 May 2011 22:59:17 +0200
+
+maven-debian-helper (1.4.1) unstable; urgency=low
+
+ * Upload to unstable.
+
+ -- Torsten Werner <twerner at debian.org> Wed, 09 Feb 2011 21:42:36 +0100
+
+maven-debian-helper (1.4) experimental; urgency=low
+
+ * d/control: Add Recommends on devscripts (which provides licensecheck)
+ * mh_make:
+ - Improve generated copyright
+ - Fix generated rules for a build using ant
+ - When ignoring dependencies, don't fail the build
+ - When ant is used as the build tool, generate the build.xml file
+ required for multi projects.
+ - use licensecheck as an additional source of information for licenses
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Fri, 12 Nov 2010 12:26:37 +0100
+
+maven-debian-helper (1.3) experimental; urgency=low
+
+ * ${maven:Depends} and similar substitution vars: add
+ version constraints when possible
+ * Use dpkg to resolve the dependent packages in ${maven:DocDepends}
+ (Closes: #588114)
+ * Use dpkg to search for the documentation package (Closes: #588114)
+ * mh_make: suggest installing missing dependencies which are not ignored
+ during the build
+ * add property debian.hasPackageVersion property, if true in the
+ repository POM then other packages depending on a POM with this property on
+ will have an addition version constraint generated in ${maven:Depends}
+ * mh_make: detect when debian.hasPackageVersion can be used, ask for the
+ upstream version of the package for confirmation.
+ * d/control: add Recommends: on subversion as it's used by mh_make,
+ add Build-Depends on libmaven-plugin-tools-java and junit
+ * d/build.xml: fix build when previous versions of this package are
+ not already installed on the system.
+ * d/rules: use debian/.mh instead of debian/tmp as temp directory to better
+ comply with Debian policy.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Wed, 29 Sep 2010 00:17:34 +0200
+
+maven-debian-helper (1.2) unstable; urgency=low
+
+ [ Ludovic Claude ]
+ * debian/control: Update Standards-Version to 3.9.1, no changes
+ * mh_make: fix issue when no-parent option is needed. Thanks Torsten
+ for the report (Closes: #591513)
+ * mh_make: assist with the rules to transform the versions
+ * mh_make: use existing package.poms files if any
+ * maven.mk: all rules in maven.ignoreRules are also used during the
+ clean phase, so there is no need to duplicate them in
+ maven.cleanIgnoreRules also.
+
+ [ Damien Raude-Morvan ]
+ * DependenciesSolver: Fix ClassCastException when using mh_make.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Thu, 16 Sep 2010 23:28:02 +0200
+
+maven-debian-helper (1.1) unstable; urgency=low
+
+ * debian/control: Update Standards-Version to 3.9.0, no changes
+ * Fix compilation issues with gcj
+ * mh_make:
+ - update generated control to use Standards-Version 3.9.0
+ - improve useability and recognize more plugins and extensions
+ - read existing maven rules in debian folder, don't ask twice the
+ same questions.
+ * Support installing build artifacts in different packages with the
+ --package option in the <package>.poms file
+ * Add mvn-build to phony rules to avoid creating a file called
+ mvn-build during the build (Closes: #589635)
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Mon, 28 Jun 2010 23:10:50 +0200
+
+maven-debian-helper (1.0) unstable; urgency=low
+
+ * debian/control:
+ - replace Depends: on openjdk-6-jre | java2-runtime by default-jdk
+ - remove Conflits: on old maven-debian-helper as there is already
+ a version constraint for a new version of this package.
+ * mh_make:
+ - supports checking out code from the svn of dev.java.net
+ - use upstream copyright when available for debian/* files
+ - update Standards version, generate with source 3.0 (quilt) package
+ format
+ - mh_make --from-svn: improve package name proposal for URLs
+ containing /tags/
+ - ask to ignore missing dependencies
+ * maven.mk:
+ - add before-mvn-build:: and after-mvn-build:: targets
+ to be able to insert custom actions before and after running the Maven
+ build
+ - add DEB_MAVEN_INSTALL_TO_USJ variable. Set this variable to false to
+ prevent maven.mk to install the jars in /usr/share/java. This
+ variable defaults to true.
+ - add call to mh_clean to remove temporary files
+ * Add -Duse.maven.repo.local option to maven-debian-plugin:install
+ and install-doc to give the option to deploy artifacts on the
+ local (and temporary) Maven repository used by the Debian build
+ Typical use-case: bootstrapping the build of a project with
+ some artifacts of the project pre-built and installed in the tmp repo
+ before the normal build is executed. See the antlr3 package for an example
+ * SysInstallMojo: clean the target directory before an installation if the
+ directory is a symlink that was created by copy-repo.sh
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Sun, 16 May 2010 14:42:29 +0200
+
+maven-debian-helper (0.12) unstable; urgency=low
+
+ * SysInstallDocMojo: Fix methods override to install -javadoc JAR flavors.
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Mon, 05 Apr 2010 23:46:22 +0200
+
+maven-debian-helper (0.11) unstable; urgency=low
+
+ * SysInstallMojo: Read generated pom.properties after POMCleaner
+ calls to allow changing groupId and artifactId inside maven.rules
+ (trying to mimic mh_installpom/mh_installjar behavior)
+ * Switch to 3.0 (native) source format
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Mon, 05 Apr 2010 21:48:23 +0200
+
+maven-debian-helper (0.10) unstable; urgency=low
+
+ * Add --non-interactive option to mh_lspoms and use it
+ in maven.mk to avoid asking questions during a build
+ (Closes: #574399)
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Wed, 24 Mar 2010 23:48:29 +0100
+
+maven-debian-helper (0.9) unstable; urgency=low
+
+ * maven-vars.mk: Fix detection of DEB_DOC_PACKAGE
+ Only exclude first exact match from dh_listpackages result
+ instead of all packages which contains main package name.
+ * maven.mk: Pass DEB_DOC_PACKAGE when invoke DEB_MAVEN_DOC_TARGET.
+
+ -- Damien Raude-Morvan <drazzib at debian.org> Mon, 01 Mar 2010 21:22:34 +0100
+
+maven-debian-helper (0.8) unstable; urgency=low
+
+ * mh_make falls back on EMAIL when DEBEMAIL is not set
+ * mh_make handles better multi projects
+ * mh_make generates projects following the Debian 3.8.3 policy
+ * Documentation improvements
+ * maven.mk: unpatch the poms in cleanbuilddir, to have a good
+ clean sequence when maven.mk is used with a patch system -
+ clean target -> mvn clean -> rm tmp files -> unpatch pom files
+ -> unpatch files with patch system
+ * Read rules from the Maven repository to force the version of
+ Maven plugins to be the same as in the repository
+ * maven.mk removes some elements from the POM files when their
+ use is against the Debian policy (<repositories> as they
+ imply downloading artifacts from the Internet,
+ <distributionManagement> as it implies publishing on the net
+ or in a location not controlled by Debian) or when they are
+ not needed and risk pulling out unwanted dependencies
+ (<reports> which is not used if a documentation package is
+ not generated)
+ * maven.mk adds a patch to Maven to disable using the
+ maven-site-plugin when no documentation package is generated.
+ This helps to reduce the amount of build dependencies
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Mon, 04 Jan 2010 23:13:29 +0100
+
+maven-debian-helper (0.7) unstable; urgency=low
+
+ [Ludovic Claude]
+ * Make the package more version agnostic. Versions are discovered
+ at runtime
+ * mh_make has a new option, --from-svn, to download automatically
+ the sources from a SVN repository and generate the Debian packaging
+ for the project.
+ * Add apt-file to Recommends: as it's used by mh_lspoms
+ (Closes: #542511)
+
+ [Michael Koch]
+ * Add Recommends: apt-file to maven-debian-helper (Closes: #542511).
+ * Build-Depends on debhelper (>= 7).
+ * Added myself to Uploaders.
+ * Updated Standards-Version to 3.8.3.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Thu, 17 Dec 2009 20:09:00 +0100
+
+maven-debian-helper (0.6) unstable; urgency=low
+
+ * Update everything to version 0.6 because 2 scripts have still been at
+ version 0.4. We should make the package more version agnostic.
+
+ -- Torsten Werner <twerner at debian.org> Sun, 16 Aug 2009 15:18:57 +0200
+
+maven-debian-helper (0.5) unstable; urgency=low
+
+ * Update Standards-Version to 3.8.2
+ * Follow the new convention for Javadoc:
+ javadoc in /usr/share/doc/package/api even if it's in package-doc
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Sun, 02 Aug 2009 11:42:31 +0100
+
+maven-debian-helper (0.4) experimental; urgency=low
+
+ [Ludovic Claude]
+ * Add myself to Uploaders
+ * Use maven-ant-helper for the build instead of recursively building
+ this package with itself (which required an ugly bootstrap script)
+ * Integrate the cdbs helper with maven-repo-helper, this unifies the
+ way the Maven repository is used, and simplifies the job of the
+ packager as maven-repo-helper takes care of most POM patching work.
+ * Use default-jdk for the build
+ * Change section to java, update Standards-Version to 3.8.1
+ * Generate Javadoc API automatically.
+ * Add mh_make tool to generate Debian packaging automatically from
+ a Maven project.
+
+ [Torsten Werner]
+ * Implement pom faking.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Tue, 14 Jul 2009 20:17:16 +0100
+
+maven-debian-helper (0.3) unstable; urgency=low
+
+ * Implement better exception handling.
+ * Create our own maven repository during build time.
+ * Set version for non plugins to '[$version]' instead of '$version' only.
+
+ -- Torsten Werner <twerner at debian.org> Sun, 25 Jan 2009 23:16:20 +0100
+
+maven-debian-helper (0.2) unstable; urgency=low
+
+ * Rename the bootstrap script.
+ * Add a manpage for mvn-debian.
+
+ -- Torsten Werner <twerner at debian.org> Sat, 17 Jan 2009 12:13:35 +0100
+
+maven-debian-helper (0.1) unstable; urgency=low
+
+ * Initial release. (Closes: #508511)
+
+ -- Torsten Werner <twerner at debian.org> Mon, 05 Jan 2009 11:47:25 +0100
Modified: tags/maven-debian-helper/1.5/maven-build-nodocs/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-build-nodocs/pom.xml 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-build-nodocs/pom.xml 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,20 +1,22 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-debian</artifactId>
- <version>1.5</version>
- </parent>
-
- <artifactId>maven-build-nodocs</artifactId>
- <packaging>jar</packaging>
- <name>build with no docs patch for Maven</name>
-
- <description>
- Patch to prevent Maven from calling maven-site-plugin when
- we run a build that does not need to produce any documentation
- </description>
-
-</project>
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-build-nodocs</artifactId>
+ <version>1.5</version>
+ <packaging>jar</packaging>
+ <parent>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian</artifactId>
+ <version>1.5</version>
+ </parent>
+ <properties>
+ <debian.hasPackageVersion/>
+ <debian.originalVersion>1.5</debian.originalVersion>
+ <debian.package>maven-debian-helper</debian.package>
+ </properties>
+
+ <name>build with no docs patch for Maven</name>
+ <description>Patch to prevent Maven from calling maven-site-plugin when
+ we run a build that does not need to produce any documentation</description>
+</project>
\ No newline at end of file
Modified: tags/maven-debian-helper/1.5/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/pom.xml 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-debian-helper/pom.xml 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,21 +1,26 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-debian</artifactId>
- <version>1.5</version>
- </parent>
-
- <artifactId>maven-debian-helper</artifactId>
- <packaging>jar</packaging>
- <name>wrapper for maven's main function</name>
-
- <dependencies>
- <dependency>
- <groupId>classworlds</groupId>
- <artifactId>classworlds</artifactId>
- </dependency>
- </dependencies>
-</project>
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian-helper</artifactId>
+ <version>1.5</version>
+ <packaging>jar</packaging>
+ <parent>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian</artifactId>
+ <version>1.5</version>
+ </parent>
+ <properties>
+ <debian.hasPackageVersion/>
+ <debian.originalVersion>1.5</debian.originalVersion>
+ <debian.package>maven-debian-helper</debian.package>
+ </properties>
+
+ <name>wrapper for maven's main function</name>
+ <dependencies>
+ <dependency>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Modified: tags/maven-debian-helper/1.5/maven-debian-plugin/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/pom.xml 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-debian-plugin/pom.xml 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,22 +1,26 @@
<?xml version='1.0' encoding='UTF-8'?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>maven-debian</artifactId>
- <groupId>org.debian.maven</groupId>
- <version>1.5</version>
- </parent>
-
- <artifactId>maven-debian-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <name>Maven Debian Plugin</name>
-
- <dependencies>
- <dependency>
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-repo-helper</artifactId>
- </dependency>
- </dependencies>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian-plugin</artifactId>
+ <version>1.5</version>
+ <packaging>maven-plugin</packaging>
+ <parent>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian</artifactId>
+ <version>1.5</version>
+ </parent>
+ <properties>
+ <debian.hasPackageVersion/>
+ <debian.originalVersion>1.5</debian.originalVersion>
+ <debian.package>maven-debian-helper</debian.package>
+ </properties>
+
+ <name>Maven Debian Plugin</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-repo-helper</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,40 +0,0 @@
-package org.debian.maven.plugin;
-
-import java.io.IOException;
-
-/*
- * Copyright 2009 Torsten Werner, Ludovic Claude.
- *
- * 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.
- */
-
-/**
- * Install the javadoc jar.
- *
- * @author Ludovic Claude
- * @goal sysinstall-doc
- */
-public class SysInstallDocMojo extends SysInstallMojo {
-
- {
- setClassifier("javadoc");
- }
-
- /**
- * do the actual work
- */
- protected void runMojo() throws IOException {
- copyJar();
- }
-
-}
Copied: tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java (from rev 15734, trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java)
===================================================================
--- tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java (rev 0)
+++ tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallDocMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,44 @@
+package org.debian.maven.plugin;
+
+import java.io.IOException;
+
+/*
+ * Copyright 2009 Torsten Werner, Ludovic Claude.
+ *
+ * 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.
+ */
+
+/**
+ * Install the javadoc jar.
+ *
+ * @author Ludovic Claude
+ * @goal sysinstall-doc
+ */
+public class SysInstallDocMojo extends SysInstallMojo {
+
+ {
+ setClassifier("javadoc");
+ }
+
+ protected String jarName() {
+ return getArtifactId() + "-" + getVersion() + "-javadoc.jar";
+ }
+
+ /**
+ * do the actual work
+ */
+ protected void runMojo() throws IOException {
+ copyJar();
+ }
+
+}
Deleted: tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,629 +0,0 @@
-package org.debian.maven.plugin;
-
-/*
- * Copyright 2009 Torsten Werner, Ludovic Claude.
- *
- * 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.
- */
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.codehaus.plexus.util.FileUtils;
-import org.debian.maven.repo.ListOfPOMs;
-import org.debian.maven.repo.POMCleaner;
-
-/**
- * Install pom and jar files into the /usr/share/hierarchy
- *
- * @goal sysinstall
- */
-public class SysInstallMojo extends AbstractMojo {
-
- // ----------------------------------------------------------------------
- // Mojo parameters
- // ----------------------------------------------------------------------
-
- /**
- * groupId
- *
- * @parameter expression="${project.groupId}"
- * @required
- * @readonly
- */
- private String groupId;
-
- /**
- * artifactId
- *
- * @parameter expression="${project.artifactId}"
- * @required
- * @readonly
- */
- private String artifactId;
-
- /**
- * destGroupId
- *
- * @parameter expression="${project.groupId}"
- * @required
- */
- private String destGroupId;
-
- /**
- * destArtifactId
- *
- * @parameter expression="${project.artifactId}"
- * @required
- */
- private String destArtifactId;
-
- /**
- * version
- *
- * @parameter expression="${project.version}"
- * @required
- * @readonly
- */
- private String version;
-
- /**
- * debianVersion
- *
- * @parameter
- */
- private String debianVersion;
-
- /**
- * directory where the current pom.xml can be found
- *
- * @parameter expression="${basedir}"
- * @required
- * @readonly
- */
- private File basedir;
-
- /**
- * directory of the jar file
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
- */
- private String jarDir;
-
- /**
- * finalname of the artifact
- *
- * @parameter expression="${project.build.finalName}"
- * @required
- * @readonly
- */
- private String finalName;
-
- /**
- * Debian directory
- *
- * @parameter expression="${debian.dir}"
- */
- private File debianDir;
-
- /**
- * Debian package (send from commande line)
- *
- * @parameter expression="${debian.package}"
- */
- private String debianPackage;
-
- /**
- * Debian package destination (set by xxx.poms file).
- * By defaul, equals to <code>debianPackage</code> attribute.
- *
- * @parameter expression="${debian.package}"
- */
- private String destPackage;
-
- /**
- * @parameter expression="${maven.rules}" default-value="maven.rules"
- * @required
- */
- private String mavenRules;
-
- /**
- * root directory of the Maven repository
- *
- * @parameter expression="${basedir}"
- * @readonly
- */
- private File repoDir;
-
- /**
- * Install the jar to /usr/share/java if true. Default is true
- *
- * @parameter expression="${install.to.usj}" default-value="true"
- */
- private boolean installToUsj = true;
-
- /**
- * Basename of the JAR inside /usr/share/java
- */
- private String usjName;
-
- /**
- * Version of the JAR install /usr/share/java
- */
- private String usjVersion;
-
- /**
- * If true, disable installation of version-less JAR into /usr/share/java
- */
- private boolean noUsjVersionless;
-
- private String classifier;
-
- // ----------------------------------------------------------------------
- // Public methods
- // ----------------------------------------------------------------------
-
- public void execute() throws MojoExecutionException {
- try {
- runMojo();
- }
- catch (IOException e) {
- getLog().error("execution failed", e);
- throw new MojoExecutionException("IOException catched");
- }
- }
-
- // ----------------------------------------------------------------------
- // Private methods
- // ----------------------------------------------------------------------
-
- protected String getArtifactId() {
- return artifactId;
- }
-
- protected String getDestArtifactId() {
- return destArtifactId;
- }
-
- protected String getVersion() {
- return version;
- }
-
- protected String getDebianVersion() {
- return debianVersion;
- }
-
- protected File getDebianDir() {
- return debianDir;
- }
-
- protected String getDebianPackage() {
- return debianPackage;
- }
-
- protected String getDestPackage() {
- return destPackage;
- }
-
- public String getClassifier() {
- return classifier;
- }
-
- public void setClassifier(String classifier) {
- this.classifier = classifier;
- }
-
- /**
- * optional destination prefix, empty by default
- */
- protected String packagePath() {
- return "";
- }
-
- /**
- * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
- */
- protected final String repoPath() {
- return "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
- }
-
- /**
- * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
- */
- protected final String destRepoPath() {
- return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + version + "/";
- }
-
- /**
- * returns e.g. /org/debian/maven/maven-debian-plugin/debian/
- */
- protected final String debianRepoPath() {
- return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + debianVersion + "/";
- }
-
- /**
- * absolute path to destination dir
- */
- protected String fullRepoPath() {
- return packagePath() + "/usr/share/maven-repo" + destRepoPath();
- }
-
- /**
- * absolute path to destination dir
- */
- protected String debianFullRepoPath() {
- return packagePath() + "/usr/share/maven-repo" + debianRepoPath();
- }
-
- protected String pomName() {
- return artifactId + "-" + version + ".pom";
- }
-
- protected String destPomName() {
- return destArtifactId + "-" + version + ".pom";
- }
-
- protected String debianPomName() {
- return destArtifactId + "-" + debianVersion + ".pom";
- }
-
- private String pomSrcPath() {
- return basedir.getAbsolutePath() + "/pom.xml";
- }
-
- private String cleanedPomSrcPath() {
- return basedir.getAbsolutePath() + "/target/pom.xml";
- }
-
- private String cleanedPomPropertiesSrcPath() {
- return basedir.getAbsolutePath() + "/target/pom.properties";
- }
-
- private String debianPomSrcPath() {
- return basedir.getAbsolutePath() + "/target/pom.debian.xml";
- }
-
- private String debianPomPropertiesSrcPath() {
- return basedir.getAbsolutePath() + "/target/pom.debian.properties";
- }
-
- private String pomDestPath() {
- return fullRepoPath() + destPomName();
- }
-
- private String debianPomDestPath() {
- return debianFullRepoPath() + debianPomName();
- }
-
- protected String jarName() {
- String jarName = "";
- if (finalName != null && finalName.length() > 0) {
- jarName += finalName;
- } else {
- jarName += artifactId + "-" + version;
- }
- return jarName + ".jar";
- }
-
- protected String destJarName() {
- if (classifier != null) {
- return destArtifactId + "-" + version + "-" + classifier + ".jar";
- }
- return destArtifactId + "-" + version + ".jar";
- }
-
- protected String debianJarName() {
- if (classifier != null) {
- return destArtifactId + "-" + debianVersion + "-" + classifier + ".jar";
- }
- return destArtifactId + "-" + debianVersion + ".jar";
- }
-
- protected final String fullJarName() {
- return jarDir + "/" + jarName();
- }
-
- protected final String jarDestPath() {
- return fullRepoPath() + destJarName();
- }
-
- protected final String jarDestRelPath() {
- return "../" + version + "/" + destJarName();
- }
-
- protected final String debianJarDestPath() {
- return debianFullRepoPath() + debianJarName();
- }
-
- /**
- * jar file name without version number
- */
- protected final String compatName() {
- return destArtifactId + ".jar";
- }
-
- protected final String compatSharePath() {
- return packagePath() + "/usr/share/java/";
- }
-
- /**
- * Example: /usr/share/java/xml-apis.jar
- */
- protected String fullCompatPath() {
- return compatSharePath() + destUsjJarName();
- }
-
- /**
- * Example: /usr/share/java/xml-apis-1.3.04.jar
- */
- protected String versionedFullCompatPath() {
- return compatSharePath() + destUsjVersionnedJarName();
- }
-
- /**
- * Compute version-less filename for installation into /usr/share/java
- */
- private String destUsjJarName() {
- String usjJarName = "";
- if (usjName != null && usjName.length() > 0) {
- usjJarName += usjName;
- } else {
- usjJarName += destArtifactId;
- }
-
- return usjJarName + ".jar";
- }
-
- /**
- * Compute versionned filename for installation into /usr/share/java
- */
- private String destUsjVersionnedJarName() {
- String usjJarName = "";
- if (usjName != null && usjName.length() > 0) {
- usjJarName += usjName;
- } else {
- usjJarName += destArtifactId;
- }
-
- if (usjVersion != null && usjVersion.length() > 0) {
- usjJarName += "-" + usjVersion;
- } else {
- usjJarName += "-" + version;
- }
-
- return usjJarName + ".jar";
- }
-
- /**
- * command for creating the relative symlink
- */
- private String[] linkCommand(String source, String dest) {
- String[] command = {"ln", "-s", source, dest};
- return command;
- }
-
- private void mkdir(String path) throws IOException {
- File destinationDirectory = new File(path);
- if (destinationDirectory.isDirectory()) {
- return;
- }
- if (!destinationDirectory.mkdirs()) {
- throw new IOException("cannot create destination directory " + path);
- }
- }
-
- private void run(String[] command) throws IOException {
- Runtime.getRuntime().exec(command, null);
- }
-
- /**
- * if a jar exists: copy it to the Maven repository
- */
- protected void copyJar() throws IOException {
- File jarFile = new File(fullJarName());
- if (jarFile.exists()) {
- FileUtils.copyFile(jarFile, new File(jarDestPath()));
- if (debianVersion != null && !debianVersion.equals(version)) {
- mkdir(debianFullRepoPath());
- run(linkCommand(jarDestRelPath(), debianJarDestPath()));
- }
- }
- }
-
- /**
- * if a jar exists: copy it to the compat share dir
- */
- private void copyJarToUsj() throws IOException {
- File jarFile = new File(fullJarName());
- if (jarFile.exists()) {
- System.out.println("Install jar for " + artifactId + " into /usr/share/java");
- mkdir(compatSharePath());
- FileUtils.copyFile(jarFile, new File(jarDestPath()));
- if (noUsjVersionless) {
- FileUtils.copyFile(jarFile, new File(versionedFullCompatPath()));
- } else {
- FileUtils.copyFile(jarFile, new File(fullCompatPath()));
- run(linkCommand(destUsjJarName(), versionedFullCompatPath()));
- }
- }
- }
-
- /**
- * if a jar exists: symlink it from the compat share dir to its targets in the Maven repository
- */
- private void symlinkJar() throws IOException {
- File jarFile = new File(fullJarName());
- if (jarFile.exists()) {
- mkdir(fullRepoPath());
- String targetPath = "";
-
- if (noUsjVersionless) {
- targetPath = versionedFullCompatPath();
- } else {
- targetPath = fullCompatPath();
- }
-
- run(linkCommand(DirectoryUtils.relativePath(fullRepoPath(), targetPath), jarDestPath()));
- if (debianVersion != null && !debianVersion.equals(version)) {
- mkdir(debianFullRepoPath());
- run(linkCommand(DirectoryUtils.relativePath(debianFullRepoPath(), targetPath), debianJarDestPath()));
- }
- }
- }
-
- /**
- * clean the pom.xml
- */
- private void cleanPom() {
- File pomOptionsFile = new File(debianDir, debianPackage + ".poms");
- ListOfPOMs listOfPOMs = new ListOfPOMs(pomOptionsFile);
-
- // Use the saved pom before cleaning as it was untouched by the transform operation
- String pomPath = pomSrcPath() + ".save";
- File pomFile = new File(pomPath);
- String originalPomPath = pomSrcPath();
- File originalPom = new File(originalPomPath);
- if (!pomFile.exists()) {
- pomFile = originalPom;
- pomPath = originalPomPath;
- }
-
- String relativePomPath = originalPom.getAbsolutePath();
- relativePomPath = relativePomPath.substring(debianDir.getParentFile().getAbsolutePath().length() + 1);
-
- ListOfPOMs.POMOptions pomOption = listOfPOMs.getPOMOptions(relativePomPath);
-
- if (pomOption != null && pomOption.isIgnore()) {
- throw new RuntimeException("POM file " + pomFile + " should be ignored");
- }
-
- if (pomOption != null) {
- if (pomOption.getDestPackage() != null) {
- destPackage = pomOption.getDestPackage();
- }
-
- // handle usj-name
- if (pomOption.getUsjName() != null) {
- usjName = pomOption.getUsjName();
- }
-
- // handle usj-version
- if (pomOption.getUsjVersion() != null) {
- usjVersion = pomOption.getUsjVersion();
- }
-
- // handle no-usj-versionless
- noUsjVersionless = pomOption.isNoUsjVersionless();
-
- // handle classifier
- if (pomOption.getClassifier() != null) {
- classifier = pomOption.getClassifier();
- }
-
- installToUsj = pomOption.isJavaLib();
- }
-
- List params = new ArrayList();
- params.add("--keep-pom-version");
-
- params.add("--package=" + destPackage);
- String mavenRulesPath = new File(debianDir, mavenRules).getAbsolutePath();
- params.add("--rules=" + mavenRulesPath);
-
- System.out.println("Cleaning pom file: " + pomFile + " with options:");
- System.out.println("\t--keep-pom-version --package=" + destPackage);
- System.out.println("\t--rules=" + mavenRulesPath);
-
- // add optional --no-parent option
- if (pomOption != null && pomOption.isNoParent()) {
- params.add("--no-parent");
- System.out.println("\t--no-parent");
- }
-
- // add options --keep-elements option
- if (pomOption != null && pomOption.getKeepElements() != null) {
- params.add("--keep-elements=" + pomOption.getKeepElements());
- System.out.println("\t--keep-elements=" + pomOption.getKeepElements());
- }
-
- params.add(pomFile.getAbsolutePath());
- params.add(cleanedPomSrcPath());
- params.add(cleanedPomPropertiesSrcPath());
-
- POMCleaner.main((String[]) params.toArray(new String[params.size()]));
-
- Properties pomProperties = new Properties();
- try {
- pomProperties.load(new FileReader(cleanedPomPropertiesSrcPath()));
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- destGroupId = pomProperties.getProperty("groupId");
- destArtifactId = pomProperties.getProperty("artifactId");
- debianVersion = pomProperties.getProperty("debianVersion");
-
- if (debianVersion != null && !debianVersion.equals(version)) {
- params.remove(0);
- params.remove(params.size() - 1);
- params.remove(params.size() - 1);
- params.add(debianPomSrcPath());
- params.add(debianPomPropertiesSrcPath());
-
- POMCleaner.main((String[]) params.toArray(new String[params.size()]));
- }
- }
-
- /**
- * copy the pom.xml
- */
- protected void copyPom() throws IOException {
- FileUtils.copyFile(new File(cleanedPomSrcPath()), new File(pomDestPath()));
- if (debianVersion != null && !debianVersion.equals(version)) {
- FileUtils.copyFile(new File(debianPomSrcPath()), new File(debianPomDestPath()));
- }
- }
-
- /**
- * Prepare the destination directories: remove the directory symlinks that were created
- * by copy-repo.sh if they exist as they point to a directory owned by root and that cannot
- * be modified.
- */
- protected void prepareDestDirs() {
- // Simply try to delete the path. If it's a symlink, it will work, otherwise delete() returns false
- new File(fullRepoPath()).delete();
- new File(debianFullRepoPath()).delete();
- }
-
- /**
- * do the actual work
- */
- protected void runMojo() throws IOException {
- cleanPom();
- prepareDestDirs();
- copyPom();
- if (installToUsj) {
- copyJarToUsj();
- symlinkJar();
- } else {
- copyJar();
- }
- }
-}
Copied: tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java (from rev 15739, trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java)
===================================================================
--- tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java (rev 0)
+++ tags/maven-debian-helper/1.5/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,633 @@
+package org.debian.maven.plugin;
+
+/*
+ * Copyright 2009 Torsten Werner, Ludovic Claude.
+ *
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
+import org.debian.maven.repo.ListOfPOMs;
+import org.debian.maven.repo.POMCleaner;
+
+/**
+ * Install pom and jar files into the /usr/share/hierarchy
+ *
+ * @goal sysinstall
+ */
+public class SysInstallMojo extends AbstractMojo {
+
+ // ----------------------------------------------------------------------
+ // Mojo parameters
+ // ----------------------------------------------------------------------
+
+ /**
+ * groupId
+ *
+ * @parameter expression="${project.groupId}"
+ * @required
+ * @readonly
+ */
+ private String groupId;
+
+ /**
+ * artifactId
+ *
+ * @parameter expression="${project.artifactId}"
+ * @required
+ * @readonly
+ */
+ private String artifactId;
+
+ /**
+ * destGroupId
+ *
+ * @parameter expression="${project.groupId}"
+ * @required
+ */
+ private String destGroupId;
+
+ /**
+ * destArtifactId
+ *
+ * @parameter expression="${project.artifactId}"
+ * @required
+ */
+ private String destArtifactId;
+
+ /**
+ * version
+ *
+ * @parameter expression="${project.version}"
+ * @required
+ * @readonly
+ */
+ private String version;
+
+ /**
+ * debianVersion
+ *
+ * @parameter
+ */
+ private String debianVersion;
+
+ /**
+ * directory where the current pom.xml can be found
+ *
+ * @parameter expression="${basedir}"
+ * @required
+ * @readonly
+ */
+ private File basedir;
+
+ /**
+ * directory of the jar file
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ private String jarDir;
+
+ /**
+ * finalname of the artifact
+ *
+ * @parameter expression="${project.build.finalName}"
+ * @required
+ * @readonly
+ */
+ private String finalName;
+
+ /**
+ * Debian directory
+ *
+ * @parameter expression="${debian.dir}"
+ */
+ private File debianDir;
+
+ /**
+ * Debian package (send from commande line)
+ *
+ * @parameter expression="${debian.package}"
+ */
+ private String debianPackage;
+
+ /**
+ * Debian package destination (set by xxx.poms file).
+ * By defaul, equals to <code>debianPackage</code> attribute.
+ *
+ * @parameter expression="${debian.package}"
+ */
+ private String destPackage;
+
+ /**
+ * @parameter expression="${maven.rules}" default-value="maven.rules"
+ * @required
+ */
+ private String mavenRules;
+
+ /**
+ * root directory of the Maven repository
+ *
+ * @parameter expression="${basedir}"
+ * @readonly
+ */
+ private File repoDir;
+
+ /**
+ * Install the jar to /usr/share/java if true. Default is true
+ *
+ * @parameter expression="${install.to.usj}" default-value="true"
+ */
+ private boolean installToUsj = true;
+
+ /**
+ * Basename of the JAR inside /usr/share/java
+ */
+ private String usjName;
+
+ /**
+ * Version of the JAR install /usr/share/java
+ */
+ private String usjVersion;
+
+ /**
+ * If true, disable installation of version-less JAR into /usr/share/java
+ */
+ private boolean noUsjVersionless;
+
+ private String classifier;
+
+ // ----------------------------------------------------------------------
+ // Public methods
+ // ----------------------------------------------------------------------
+
+ public void execute() throws MojoExecutionException {
+ try {
+ runMojo();
+ }
+ catch (IOException e) {
+ getLog().error("execution failed", e);
+ throw new MojoExecutionException("IOException catched");
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
+ protected String getArtifactId() {
+ return artifactId;
+ }
+
+ protected String getDestArtifactId() {
+ return destArtifactId;
+ }
+
+ protected String getVersion() {
+ return version;
+ }
+
+ protected String getDebianVersion() {
+ return debianVersion;
+ }
+
+ protected File getDebianDir() {
+ return debianDir;
+ }
+
+ protected String getDebianPackage() {
+ return debianPackage;
+ }
+
+ protected String getDestPackage() {
+ return destPackage;
+ }
+
+ public String getClassifier() {
+ return classifier;
+ }
+
+ public void setClassifier(String classifier) {
+ this.classifier = classifier;
+ }
+
+ /**
+ * optional destination prefix, empty by default
+ */
+ protected String packagePath() {
+ return "";
+ }
+
+ /**
+ * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
+ */
+ protected final String repoPath() {
+ return "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
+ }
+
+ /**
+ * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
+ */
+ protected final String destRepoPath() {
+ return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + version + "/";
+ }
+
+ /**
+ * returns e.g. /org/debian/maven/maven-debian-plugin/debian/
+ */
+ protected final String debianRepoPath() {
+ return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + debianVersion + "/";
+ }
+
+ /**
+ * absolute path to destination dir
+ */
+ protected String fullRepoPath() {
+ return packagePath() + "/usr/share/maven-repo" + destRepoPath();
+ }
+
+ /**
+ * absolute path to destination dir
+ */
+ protected String debianFullRepoPath() {
+ return packagePath() + "/usr/share/maven-repo" + debianRepoPath();
+ }
+
+ protected String pomName() {
+ return artifactId + "-" + version + ".pom";
+ }
+
+ protected String destPomName() {
+ return destArtifactId + "-" + version + ".pom";
+ }
+
+ protected String debianPomName() {
+ return destArtifactId + "-" + debianVersion + ".pom";
+ }
+
+ private String pomSrcPath() {
+ return basedir.getAbsolutePath() + "/pom.xml";
+ }
+
+ private String cleanedPomSrcPath() {
+ return basedir.getAbsolutePath() + "/target/pom.xml";
+ }
+
+ private String cleanedPomPropertiesSrcPath() {
+ return basedir.getAbsolutePath() + "/target/pom.properties";
+ }
+
+ private String debianPomSrcPath() {
+ return basedir.getAbsolutePath() + "/target/pom.debian.xml";
+ }
+
+ private String debianPomPropertiesSrcPath() {
+ return basedir.getAbsolutePath() + "/target/pom.debian.properties";
+ }
+
+ private String pomDestPath() {
+ return fullRepoPath() + destPomName();
+ }
+
+ private String debianPomDestPath() {
+ return debianFullRepoPath() + debianPomName();
+ }
+
+ protected String jarName() {
+ String jarName;
+ if (finalName != null && finalName.length() > 0) {
+ jarName = finalName;
+ } else {
+ jarName = artifactId + "-" + version;
+ }
+ if (classifier != null) {
+ jarName += "-" + classifier;
+ }
+ return jarName + ".jar";
+ }
+
+ protected String destJarName() {
+ if (classifier != null) {
+ return destArtifactId + "-" + version + "-" + classifier + ".jar";
+ }
+ return destArtifactId + "-" + version + ".jar";
+ }
+
+ protected String debianJarName() {
+ if (classifier != null) {
+ return destArtifactId + "-" + debianVersion + "-" + classifier + ".jar";
+ }
+ return destArtifactId + "-" + debianVersion + ".jar";
+ }
+
+ protected final String fullJarName() {
+ return jarDir + "/" + jarName();
+ }
+
+ protected final String jarDestPath() {
+ return fullRepoPath() + destJarName();
+ }
+
+ protected final String jarDestRelPath() {
+ return "../" + version + "/" + destJarName();
+ }
+
+ protected final String debianJarDestPath() {
+ return debianFullRepoPath() + debianJarName();
+ }
+
+ /**
+ * jar file name without version number
+ */
+ protected final String compatName() {
+ return destArtifactId + ".jar";
+ }
+
+ protected final String compatSharePath() {
+ return packagePath() + "/usr/share/java/";
+ }
+
+ /**
+ * Example: /usr/share/java/xml-apis.jar
+ */
+ protected String fullCompatPath() {
+ return compatSharePath() + destUsjJarName();
+ }
+
+ /**
+ * Example: /usr/share/java/xml-apis-1.3.04.jar
+ */
+ protected String versionedFullCompatPath() {
+ return compatSharePath() + destUsjVersionnedJarName();
+ }
+
+ /**
+ * Compute version-less filename for installation into /usr/share/java
+ */
+ private String destUsjJarName() {
+ String usjJarName = "";
+ if (usjName != null && usjName.length() > 0) {
+ usjJarName += usjName;
+ } else {
+ usjJarName += destArtifactId;
+ }
+
+ return usjJarName + ".jar";
+ }
+
+ /**
+ * Compute versionned filename for installation into /usr/share/java
+ */
+ private String destUsjVersionnedJarName() {
+ String usjJarName = "";
+ if (usjName != null && usjName.length() > 0) {
+ usjJarName += usjName;
+ } else {
+ usjJarName += destArtifactId;
+ }
+
+ if (usjVersion != null && usjVersion.length() > 0) {
+ usjJarName += "-" + usjVersion;
+ } else {
+ usjJarName += "-" + version;
+ }
+
+ return usjJarName + ".jar";
+ }
+
+ /**
+ * command for creating the relative symlink
+ */
+ private String[] linkCommand(String source, String dest) {
+ String[] command = {"ln", "-s", source, dest};
+ return command;
+ }
+
+ private void mkdir(String path) throws IOException {
+ File destinationDirectory = new File(path);
+ if (destinationDirectory.isDirectory()) {
+ return;
+ }
+ if (!destinationDirectory.mkdirs()) {
+ throw new IOException("cannot create destination directory " + path);
+ }
+ }
+
+ private void run(String[] command) throws IOException {
+ Runtime.getRuntime().exec(command, null);
+ }
+
+ /**
+ * if a jar exists: copy it to the Maven repository
+ */
+ protected void copyJar() throws IOException {
+ File jarFile = new File(fullJarName());
+ if (jarFile.exists()) {
+ System.out.println("Install jar file into Maven repo: " + jarFile.getAbsolutePath());
+ FileUtils.copyFile(jarFile, new File(jarDestPath()));
+ if (debianVersion != null && !debianVersion.equals(version)) {
+ mkdir(debianFullRepoPath());
+ run(linkCommand(jarDestRelPath(), debianJarDestPath()));
+ }
+ }
+ }
+
+ /**
+ * if a jar exists: copy it to the compat share dir
+ */
+ private void copyJarToUsj() throws IOException {
+ File jarFile = new File(fullJarName());
+ if (jarFile.exists()) {
+ System.out.println("Install jar for " + artifactId + " into /usr/share/java");
+ mkdir(compatSharePath());
+ FileUtils.copyFile(jarFile, new File(jarDestPath()));
+ if (noUsjVersionless) {
+ FileUtils.copyFile(jarFile, new File(versionedFullCompatPath()));
+ } else {
+ FileUtils.copyFile(jarFile, new File(fullCompatPath()));
+ run(linkCommand(destUsjJarName(), versionedFullCompatPath()));
+ }
+ }
+ }
+
+ /**
+ * if a jar exists: symlink it from the compat share dir to its targets in the Maven repository
+ */
+ private void symlinkJar() throws IOException {
+ File jarFile = new File(fullJarName());
+ if (jarFile.exists()) {
+ mkdir(fullRepoPath());
+ String targetPath = "";
+
+ if (noUsjVersionless) {
+ targetPath = versionedFullCompatPath();
+ } else {
+ targetPath = fullCompatPath();
+ }
+
+ run(linkCommand(DirectoryUtils.relativePath(fullRepoPath(), targetPath), jarDestPath()));
+ if (debianVersion != null && !debianVersion.equals(version)) {
+ mkdir(debianFullRepoPath());
+ run(linkCommand(DirectoryUtils.relativePath(debianFullRepoPath(), targetPath), debianJarDestPath()));
+ }
+ }
+ }
+
+ /**
+ * clean the pom.xml
+ */
+ private void cleanPom() {
+ File pomOptionsFile = new File(debianDir, debianPackage + ".poms");
+ ListOfPOMs listOfPOMs = new ListOfPOMs(pomOptionsFile);
+
+ // Use the saved pom before cleaning as it was untouched by the transform operation
+ String pomPath = pomSrcPath() + ".save";
+ File pomFile = new File(pomPath);
+ String originalPomPath = pomSrcPath();
+ File originalPom = new File(originalPomPath);
+ if (!pomFile.exists()) {
+ pomFile = originalPom;
+ pomPath = originalPomPath;
+ }
+
+ String relativePomPath = originalPom.getAbsolutePath();
+ relativePomPath = relativePomPath.substring(debianDir.getParentFile().getAbsolutePath().length() + 1);
+
+ ListOfPOMs.POMOptions pomOption = listOfPOMs.getPOMOptions(relativePomPath);
+
+ if (pomOption != null && pomOption.isIgnore()) {
+ throw new RuntimeException("POM file " + pomFile + " should be ignored");
+ }
+
+ if (pomOption != null) {
+ if (pomOption.getDestPackage() != null) {
+ destPackage = pomOption.getDestPackage();
+ }
+
+ // handle usj-name
+ if (pomOption.getUsjName() != null) {
+ usjName = pomOption.getUsjName();
+ }
+
+ // handle usj-version
+ if (pomOption.getUsjVersion() != null) {
+ usjVersion = pomOption.getUsjVersion();
+ }
+
+ // handle no-usj-versionless
+ noUsjVersionless = pomOption.isNoUsjVersionless();
+
+ // handle classifier
+ if (pomOption.getClassifier() != null) {
+ classifier = pomOption.getClassifier();
+ }
+
+ installToUsj = pomOption.isJavaLib();
+ }
+
+ List params = new ArrayList();
+ params.add("--keep-pom-version");
+
+ params.add("--package=" + destPackage);
+ String mavenRulesPath = new File(debianDir, mavenRules).getAbsolutePath();
+ params.add("--rules=" + mavenRulesPath);
+
+ System.out.println("Cleaning pom file: " + pomFile + " with options:");
+ System.out.println("\t--keep-pom-version --package=" + destPackage);
+ System.out.println("\t--rules=" + mavenRulesPath);
+
+ // add optional --no-parent option
+ if (pomOption != null && pomOption.isNoParent()) {
+ params.add("--no-parent");
+ System.out.println("\t--no-parent");
+ }
+
+ // add options --keep-elements option
+ if (pomOption != null && pomOption.getKeepElements() != null) {
+ params.add("--keep-elements=" + pomOption.getKeepElements());
+ System.out.println("\t--keep-elements=" + pomOption.getKeepElements());
+ }
+
+ params.add(pomFile.getAbsolutePath());
+ params.add(cleanedPomSrcPath());
+ params.add(cleanedPomPropertiesSrcPath());
+
+ POMCleaner.main((String[]) params.toArray(new String[params.size()]));
+
+ Properties pomProperties = new Properties();
+ try {
+ pomProperties.load(new FileReader(cleanedPomPropertiesSrcPath()));
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ destGroupId = pomProperties.getProperty("groupId");
+ destArtifactId = pomProperties.getProperty("artifactId");
+ debianVersion = pomProperties.getProperty("debianVersion");
+
+ if (debianVersion != null && !debianVersion.equals(version)) {
+ params.remove(0);
+ params.remove(params.size() - 1);
+ params.remove(params.size() - 1);
+ params.add(debianPomSrcPath());
+ params.add(debianPomPropertiesSrcPath());
+
+ POMCleaner.main((String[]) params.toArray(new String[params.size()]));
+ }
+ }
+
+ /**
+ * copy the pom.xml
+ */
+ protected void copyPom() throws IOException {
+ FileUtils.copyFile(new File(cleanedPomSrcPath()), new File(pomDestPath()));
+ if (debianVersion != null && !debianVersion.equals(version)) {
+ FileUtils.copyFile(new File(debianPomSrcPath()), new File(debianPomDestPath()));
+ }
+ }
+
+ /**
+ * Prepare the destination directories: remove the directory symlinks that were created
+ * by copy-repo.sh if they exist as they point to a directory owned by root and that cannot
+ * be modified.
+ */
+ protected void prepareDestDirs() {
+ // Simply try to delete the path. If it's a symlink, it will work, otherwise delete() returns false
+ new File(fullRepoPath()).delete();
+ new File(debianFullRepoPath()).delete();
+ }
+
+ /**
+ * do the actual work
+ */
+ protected void runMojo() throws IOException {
+ cleanPom();
+ prepareDestDirs();
+ copyPom();
+ if (installToUsj) {
+ copyJarToUsj();
+ symlinkJar();
+ } else {
+ copyJar();
+ }
+ }
+}
Modified: tags/maven-debian-helper/1.5/maven-packager-utils/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/pom.xml 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/pom.xml 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,48 +1,42 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>maven-debian</artifactId>
- <groupId>org.debian.maven</groupId>
- <version>1.5</version>
- </parent>
-
- <artifactId>maven-packager-utils</artifactId>
- <packaging>maven-plugin</packaging>
- <name>Maven Packager Utilities</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- </dependency>
- <dependency>
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-repo-helper</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-packager-utils</artifactId>
+ <version>1.5</version>
+ <packaging>maven-plugin</packaging>
+ <parent>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian</artifactId>
+ <version>1.5</version>
+ </parent>
+ <properties>
+ <debian.hasPackageVersion/>
+ <debian.originalVersion>1.5</debian.originalVersion>
+ <debian.package>maven-debian-helper</debian.package>
+ </properties>
+
+ <name>Maven Packager Utilities</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-repo-helper</artifactId>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,1604 +0,0 @@
-package org.debian.maven.packager;
-
-/*
- * Copyright 2009 Ludovic Claude.
- * Copyright 2011 Damien Raude-Morvan.
- *
- * 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.
- */
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.debian.maven.repo.Dependency;
-import org.debian.maven.repo.DependencyNotFoundException;
-import org.debian.maven.repo.DependencyRule;
-import org.debian.maven.repo.DependencyRuleSet;
-import org.debian.maven.repo.ListOfPOMs;
-import org.debian.maven.repo.POMHandler;
-import org.debian.maven.repo.POMInfo;
-import org.debian.maven.repo.POMTransformer;
-import org.debian.maven.repo.Repository;
-import org.debian.maven.repo.Rule;
-
-/**
- * Analyze the Maven dependencies and extract the Maven rules to use
- * as well as the list of dependent packages.
- *
- * @author Ludovic Claude
- */
-public class DependenciesSolver {
-
- private static final Logger log = Logger.getLogger(DependenciesSolver.class.getName());
-
- // Plugins not useful for the build or whose use is against the
- // Debian policy
- private static final String[][] PLUGINS_TO_IGNORE = {
- {"org.apache.maven.plugins", "maven-archetype-plugin"},
- {"org.apache.maven.plugins", "changelog-maven-plugin"},
- {"org.apache.maven.plugins", "maven-deploy-plugin"},
- {"org.apache.maven.plugins", "maven-release-plugin"},
- {"org.apache.maven.plugins", "maven-repository-plugin"},
- {"org.apache.maven.plugins", "maven-scm-plugin"},
- {"org.apache.maven.plugins", "maven-stage-plugin"},
- {"org.apache.maven.plugins", "maven-eclipse-plugin"},
- {"org.apache.maven.plugins", "maven-idea-plugin"},
- {"org.apache.maven.plugins", "maven-source-plugin"},
- {"org.codehaus.mojo", "changelog-maven-plugin"},
- {"org.codehaus.mojo", "netbeans-freeform-maven-plugin"},
- {"org.codehaus.mojo", "nbm-maven-plugin"},
- {"org.codehaus.mojo", "ideauidesigner-maven-plugin"},
- {"org.codehaus.mojo", "scmchangelog-maven-plugin"},};
- private static final String[][] PLUGINS_THAT_CAN_BE_IGNORED = {
- {"org.apache.maven.plugins", "maven-ant-plugin"},
- {"org.apache.maven.plugins", "maven-assembly-plugin"},
- {"org.apache.maven.plugins", "maven-enforcer-plugin"},
- {"org.apache.maven.plugins", "maven-gpg-plugin"},
- {"org.apache.rat", "apache-rat-plugin"},
- {"org.codehaus.mojo", "buildnumber-maven-plugin"},
- {"org.apache.maven.plugins", "maven-verifier-plugin"},
- {"org.codehaus.mojo", "findbugs-maven-plugin"},
- {"org.codehaus.mojo", "fitnesse-maven-plugin"},
- {"org.codehaus.mojo", "selenium-maven-plugin"},
- {"org.codehaus.mojo", "dbunit-maven-plugin"},
- {"org.codehaus.mojo", "failsafe-maven-plugin"},
- {"org.codehaus.mojo", "shitty-maven-plugin"},};
- private static final String[][] DOC_PLUGINS = {
- {"org.apache.maven.plugins", "maven-changelog-plugin"},
- {"org.apache.maven.plugins", "maven-changes-plugin"},
- {"org.apache.maven.plugins", "maven-checkstyle-plugin"},
- {"org.apache.maven.plugins", "maven-clover-plugin"},
- {"org.apache.maven.plugins", "maven-docck-plugin"},
- {"org.apache.maven.plugins", "maven-javadoc-plugin"},
- {"org.apache.maven.plugins", "maven-jxr-plugin"},
- {"org.apache.maven.plugins", "maven-pmd-plugin"},
- {"org.apache.maven.plugins", "maven-project-info-reports-plugin"},
- {"org.apache.maven.plugins", "maven-surefire-report-plugin"},
- {"org.apache.maven.plugins", "maven-pdf-plugin"},
- {"org.apache.maven.plugins", "maven-site-plugin"},
- {"org.codehaus.mojo", "changes-maven-plugin"},
- {"org.codehaus.mojo", "clirr-maven-plugin"},
- {"org.codehaus.mojo", "cobertura-maven-plugin"},
- {"org.codehaus.mojo", "taglist-maven-plugin"},
- {"org.codehaus.mojo", "dita-maven-plugin"},
- {"org.codehaus.mojo", "docbook-maven-plugin"},
- {"org.codehaus.mojo", "javancss-maven-plugin"},
- {"org.codehaus.mojo", "jdepend-maven-plugin"},
- {"org.codehaus.mojo", "jxr-maven-plugin"},
- {"org.codehaus.mojo", "dashboard-maven-plugin"},
- {"org.codehaus.mojo", "emma-maven-plugin"},
- {"org.codehaus.mojo", "sonar-maven-plugin"},
- {"org.codehaus.mojo", "surefire-report-maven-plugin"},
- {"org.jboss.maven.plugins", "maven-jdocbook-plugin"},
- };
- private static final String[][] TEST_PLUGINS = {
- {"org.apache.maven.plugins", "maven-failsafe-plugin"},
- {"org.apache.maven.plugins", "maven-surefire-plugin"},
- {"org.apache.maven.plugins", "maven-verifier-plugin"},
- {"org.codehaus.mojo", "findbugs-maven-plugin"},
- {"org.codehaus.mojo", "fitnesse-maven-plugin"},
- {"org.codehaus.mojo", "selenium-maven-plugin"},
- {"org.codehaus.mojo", "dbunit-maven-plugin"},
- {"org.codehaus.mojo", "failsafe-maven-plugin"},
- {"org.codehaus.mojo", "shitty-maven-plugin"},};
- private static final String[][] EXTENSIONS_TO_IGNORE = {
- {"org.apache.maven.wagon", "wagon-ssh"},
- {"org.apache.maven.wagon", "wagon-ssh-external"},
- {"org.apache.maven.wagon", "wagon-ftp"},
- {"org.apache.maven.wagon", "wagon-http"},
- {"org.apache.maven.wagon", "wagon-http-lightweight"},
- {"org.apache.maven.wagon", "wagon-scm"},
- {"org.apache.maven.wagon", "wagon-webdav"},
- {"org.apache.maven.wagon", "wagon-webdav-jackrabbit"},
- {"org.jvnet.wagon-svn", "wagon-svn"},
- };
-
- protected File baseDir;
- protected POMTransformer pomTransformer = new POMTransformer();
- protected File outputDirectory;
- protected String packageName;
- protected String packageType;
- private String packageVersion;
- protected File mavenRepo = new File("/usr/share/maven-repo");
- protected boolean exploreProjects;
- private Repository repository;
- private List<String> issues = new ArrayList<String>();
- private List<Dependency> projectPoms = new ArrayList<Dependency>();
- private List<ToResolve> toResolve = new ArrayList<ToResolve>();
- private Set<Dependency> knownProjectDependencies = new TreeSet<Dependency>();
- private Set<Dependency> ignoredDependencies = new TreeSet<Dependency>();
- private Set<Dependency> notIgnoredDependencies = new TreeSet<Dependency>();
- private Set<String> compileDepends = new TreeSet<String>();
- private Set<String> testDepends = new TreeSet<String>();
- private Set<String> runtimeDepends = new TreeSet<String>();
- private Set<String> optionalDepends = new TreeSet<String>();
- private DependencyRuleSet cleanIgnoreRules = new DependencyRuleSet("Ignore rules to be applied during the Maven clean phase",
- new File("debian/maven.cleanIgnoreRules"));
- private boolean offline;
- private boolean runTests;
- private boolean generateJavadoc;
- private boolean interactive = true;
- private boolean askedToFilterModules = false;
- private boolean filterModules = false;
- private boolean verbose = false;
- private Map<String, POMInfo> pomInfoCache = new HashMap<String, POMInfo>();
- // Keep the previous selected rule for a given version
- private Map<String, Rule> versionToRules = new HashMap<String, Rule>();
- // Keep the list of known files and their package
- private Map<File, String> filesInPackages = new HashMap<File, String>();
- // Keep the list of packages and dependencies
- private Map<String, Dependency> versionedPackagesAndDependencies = new HashMap<String, Dependency>();
- private List<Rule> defaultRules = new ArrayList<Rule>();
-
- public DependenciesSolver() {
- pomTransformer.setVerbose(true);
- pomTransformer.setFixVersions(false);
- pomTransformer.getRules().setWarnRulesFileNotFound(false);
- pomTransformer.getRules().setDescription(readResource("maven.rules.description"));
- pomTransformer.getIgnoreRules().setDescription(readResource("maven.ignoreRules.description"));
- pomTransformer.getIgnoreRules().setWarnRulesFileNotFound(false);
- pomTransformer.getPublishedRules().setDescription(readResource("maven.publishedRules.description"));
- pomTransformer.getPublishedRules().setWarnRulesFileNotFound(false);
- cleanIgnoreRules.setDescription(readResource("maven.cleanIgnoreRules.description"));
- cleanIgnoreRules.setWarnRulesFileNotFound(false);
- cleanIgnoreRules.setVerbose(true);
- cleanIgnoreRules.setDontDuplicate(pomTransformer.getIgnoreRules());
-
- Rule toDebianRule = new Rule("s/.*/debian/");
- toDebianRule.setDescription("Change the version to the symbolic 'debian' version");
- Rule keepVersionRule = new Rule("*");
- keepVersionRule.setDescription("Keep the version");
- Rule customRule = new Rule("CUSTOM");
- customRule.setDescription("Custom rule");
- defaultRules.add(toDebianRule);
- defaultRules.add(keepVersionRule);
- defaultRules.add(customRule);
- }
-
- private static String readResource(String resource) {
- StringBuffer sb = new StringBuffer();
- try {
- InputStream is = DependenciesSolver.class.getResourceAsStream("/" + resource);
- LineNumberReader r = new LineNumberReader(new InputStreamReader(is));
- String line;
- while ((line = r.readLine()) != null) {
- sb.append(line);
- sb.append("\n");
- }
- r.close();
- } catch (IOException e) {
- log.log(Level.SEVERE, "Cannot read resource " + resource, e);
- }
- return sb.toString();
- }
-
- public boolean isRunTests() {
- return runTests;
- }
-
- public void setRunTests(boolean b) {
- this.runTests = b;
- }
-
- public void setOffline(boolean offline) {
- this.offline = offline;
- }
-
- public boolean isGenerateJavadoc() {
- return generateJavadoc;
- }
-
- public void setGenerateJavadoc(boolean b) {
- this.generateJavadoc = b;
- }
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- private boolean containsPlugin(String[][] pluginDefinitions, Dependency plugin) {
- for (String[] pluginDefinition : pluginDefinitions) {
- if (!plugin.getGroupId().equals(pluginDefinition[0])) {
- continue;
- }
- if (plugin.getArtifactId().equals(pluginDefinition[1])) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isDocumentationOrReportPlugin(Dependency dependency) {
- return containsPlugin(DOC_PLUGINS, dependency);
- }
-
- private boolean isTestPlugin(Dependency dependency) {
- return containsPlugin(TEST_PLUGINS, dependency);
- }
-
- private boolean isDefaultMavenPlugin(Dependency dependency) {
- if (getRepository() != null && getRepository().getSuperPOM() != null) {
- for (Dependency defaultPlugin : getRepository().getSuperPOM().getPluginManagement()) {
- if (defaultPlugin.equalsIgnoreVersion(dependency)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private boolean canIgnorePlugin(Dependency dependency) {
- return containsPlugin(PLUGINS_TO_IGNORE, dependency);
- }
-
- private boolean canIgnoreExtension(Dependency dependency) {
- return containsPlugin(EXTENSIONS_TO_IGNORE, dependency);
- }
-
- private boolean canBeIgnoredPlugin(Dependency dependency) {
- return containsPlugin(PLUGINS_THAT_CAN_BE_IGNORED, dependency);
- }
-
- private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message) {
- return askIgnoreDependency(sourcePomLoc, dependency, message, true);
- }
-
- private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message, boolean defaultToIgnore) {
- if (!interactive || notIgnoredDependencies.contains(dependency)) {
- return false;
- }
- System.out.println();
- System.out.println("In " + sourcePomLoc + ":");
- System.out.println(message);
- System.out.println(" " + dependency);
- if (defaultToIgnore) {
- System.out.print("[y]/n > ");
- } else {
- System.out.print("y/[n] > ");
- }
- String s = readLine().toLowerCase();
- boolean ignore = defaultToIgnore ? !s.startsWith("n") : s.startsWith("y");
- if (!ignore) {
- notIgnoredDependencies.add(dependency);
- }
- return ignore;
- }
-
- public boolean isInteractive() {
- return interactive;
- }
-
- public void setInteractive(boolean interactive) {
- this.interactive = interactive;
- }
-
- POMTransformer getPomTransformer() {
- return pomTransformer;
- }
-
- public ListOfPOMs getListOfPOMs() {
- return pomTransformer.getListOfPOMs();
- }
-
- private class ToResolve {
-
- private final File sourcePom;
- private final String listType;
- private final boolean buildTime;
- private final boolean mavenExtension;
- private final boolean management;
-
- private ToResolve(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
- this.sourcePom = sourcePom;
- this.listType = listType;
- this.buildTime = buildTime;
- this.mavenExtension = mavenExtension;
- this.management = management;
- }
-
- public void resolve() {
- try {
- resolveDependencies(sourcePom, listType, buildTime, mavenExtension, management);
- } catch (Exception e) {
- log.log(Level.SEVERE, "Cannot resolve dependencies in " + sourcePom + ": " + e.getMessage());
- }
- }
- }
-
- public File getBaseDir() {
- return baseDir;
- }
-
- public void saveListOfPoms() {
- pomTransformer.getListOfPOMs().save();
- }
-
- public void saveMavenRules() {
- pomTransformer.getRules().save();
- }
-
- public void saveMavenPublishedRules() {
- pomTransformer.getPublishedRules().save();
- }
-
- public void saveMavenIgnoreRules() {
- pomTransformer.getIgnoreRules().save();
- }
-
- public void saveMavenCleanIgnoreRules() {
- cleanIgnoreRules.save();
- }
-
- public void saveSubstvars() {
- File dependencies = new File(outputDirectory, packageName + ".substvars");
- Properties depVars = new Properties();
- if (dependencies.exists()) {
- try {
- depVars.load(new FileReader(dependencies));
- } catch (IOException ex) {
- log.log(Level.SEVERE, "Error while reading file " + dependencies, ex);
- }
- }
- depVars.put("maven.CompileDepends", toString(compileDepends));
- depVars.put("maven.TestDepends", toString(testDepends));
- depVars.put("maven.Depends", toString(runtimeDepends));
- depVars.put("maven.OptionalDepends", toString(optionalDepends));
- if (generateJavadoc) {
- System.out.println("Checking dependencies for documentation packages...");
- Set<String> docRuntimeDepends = new TreeSet<String>();
- docRuntimeDepends.add("default-jdk-doc");
- for (String dependency : runtimeDepends) {
- Dependency runtimeDependency = versionedPackagesAndDependencies.get(dependency);
- if (dependency.indexOf(' ') > 0) {
- dependency = dependency.substring(0, dependency.indexOf(' '));
- }
- if (runtimeDependency != null && "pom".equals(runtimeDependency.getType())) {
- continue;
- }
- String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
- if (docPkg != null) {
- docRuntimeDepends.add(docPkg);
- }
- }
- Set<String> docOptionalDepends = new TreeSet<String>();
- for (String dependency : optionalDepends) {
- Dependency optionalDependency = versionedPackagesAndDependencies.get(dependency);
- if (dependency.indexOf(' ') > 0) {
- dependency = dependency.substring(0, dependency.indexOf(' '));
- }
- if (optionalDependency != null && "pom".equals(optionalDependency.getType())) {
- continue;
- }
- String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
- if (docPkg != null) {
- docOptionalDepends.add(docPkg);
- }
- }
- depVars.put("maven.DocDepends", toString(docRuntimeDepends));
- depVars.put("maven.DocOptionalDepends", toString(docOptionalDepends));
- }
- if (packageVersion != null) {
- depVars.put("maven.UpstreamPackageVersion", packageVersion);
- }
- // Write everything to debian/substvars
- try {
- FileWriter fstream = new FileWriter(dependencies);
- BufferedWriter out = new BufferedWriter(fstream);
- out.write("#List of dependencies for " + packageName + ", generated for use by debian/control");
- out.write("\n");
- Set<String> propertiesNames = depVars.stringPropertyNames();
- if (propertiesNames != null) {
- for (String propName : propertiesNames) {
- StringBuffer sb = new StringBuffer();
- sb.append(propName);
- sb.append("=");
- sb.append(depVars.get(propName));
- sb.append("\n");
- out.write(sb.toString());
- }
- }
- out.close();
- } catch (IOException ex) {
- log.log(Level.SEVERE, "Error while saving file " + dependencies, ex);
- }
- }
-
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
- if (pomTransformer.getListOfPOMs() != null) {
- pomTransformer.getListOfPOMs().setBaseDir(baseDir);
- }
- }
-
- public void setListOfPoms(File listOfPoms) {
- if (pomTransformer.getListOfPOMs() == null) {
- pomTransformer.setListOfPOMs(new ListOfPOMs(listOfPoms));
- } else {
- pomTransformer.getListOfPOMs().setListOfPOMsFile(listOfPoms);
- }
- pomTransformer.getListOfPOMs().setBaseDir(baseDir);
- }
-
- public boolean isExploreProjects() {
- return exploreProjects;
- }
-
- public void setExploreProjects(boolean exploreProjects) {
- this.exploreProjects = exploreProjects;
- }
-
- public File getMavenRepo() {
- return mavenRepo;
- }
-
- public void setMavenRepo(File mavenRepo) {
- this.mavenRepo = mavenRepo;
- }
-
- public File getOutputDirectory() {
- return outputDirectory;
- }
-
- public void setOutputDirectory(File outputDirectory) {
- this.outputDirectory = outputDirectory;
- File rulesFile = new File(outputDirectory, "maven.rules");
- if (rulesFile.exists() && verbose) {
- System.out.println("Use existing rules:");
- }
- pomTransformer.getRules().setRulesFile(rulesFile);
-
- File ignoreRulesFile = new File(outputDirectory, "maven.ignoreRules");
- if (ignoreRulesFile.exists() && verbose) {
- System.out.println();
- System.out.println("Use existing ignore rules:");
- }
- pomTransformer.getIgnoreRules().setRulesFile(ignoreRulesFile);
-
- File publishedRulesFile = new File(outputDirectory, "maven.publishedRules");
- if (publishedRulesFile.exists() && verbose) {
- System.out.println();
- System.out.println("Use existing published rules:");
- }
- pomTransformer.getPublishedRules().setRulesFile(publishedRulesFile);
-
- File cleanIgnoreRules = new File(outputDirectory, "maven.cleanIgnoreRules");
- if (cleanIgnoreRules.exists() && verbose) {
- System.out.println();
- System.out.println("Use existing clean ignore rules:");
- }
- this.cleanIgnoreRules.setRulesFile(cleanIgnoreRules);
-
- if (verbose) {
- System.out.println();
- }
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public String getPackageType() {
- return packageType;
- }
-
- public void setPackageType(String packageType) {
- this.packageType = packageType;
- }
-
- public List<String> getIssues() {
- return issues;
- }
-
- private Repository getRepository() {
- if (repository == null && mavenRepo != null) {
- repository = new Repository(mavenRepo);
- repository.scan();
- }
- return repository;
- }
-
- public void solveDependencies() {
- pomTransformer.setRepository(getRepository());
- pomTransformer.usePluginVersionsFromRepository();
-
- File f = outputDirectory;
- if (!f.exists()) {
- f.mkdirs();
- }
-
- if (exploreProjects) {
- File pom;
- if (pomTransformer.getListOfPOMs().getPomOptions().isEmpty()) {
- pom = new File(baseDir, "pom.xml");
- if (pom.exists()) {
- pomTransformer.getListOfPOMs().addPOM("pom.xml");
- } else {
- pom = new File(baseDir, "debian/pom.xml");
- if (pom.exists()) {
- pomTransformer.getListOfPOMs().addPOM("debian/pom.xml");
- } else {
- System.err.println("Cannot find the POM file");
- return;
- }
- }
- } else {
- pom = new File(baseDir, pomTransformer.getListOfPOMs().getFirstPOM());
- }
- resolveDependencies(pom);
- } else {
- pomTransformer.getListOfPOMs().foreachPoms(new POMHandler() {
-
- public void handlePOM(File pomFile, boolean noParent, boolean hasPackageVersion) throws Exception {
- resolveDependencies(pomFile);
- }
-
- public void ignorePOM(File pomFile) throws Exception {
- }
- });
- }
-
- resolveDependenciesNow();
-
- if (!issues.isEmpty()) {
- System.err.println("ERROR:");
- for (String issue : issues) {
- System.err.println(issue);
- }
- System.err.println("--------");
- }
- }
-
- private void resolveDependencies(File projectPom) {
-
- if (getPOMOptions(projectPom) != null && getPOMOptions(projectPom).isIgnore()) {
- return;
- }
-
- String pomRelPath = projectPom.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
- System.out.println("Analysing " + pomRelPath + "...");
-
- try {
- POMInfo pom = getPOM(projectPom);
- pom.setProperties(new HashMap<String, String>());
- pom.getProperties().put("debian.package", getPackageName());
-
- if (getPOMOptions(projectPom).isNoParent()) {
- pom.setParent(null);
- } else if (pom.getParent() != null && !pom.getParent().isSuperPom()) {
- boolean oldNoParent = getPOMOptions(projectPom).isNoParent();
- // Don't mark the parent dependency as 'build time' dependency because once installed,
- // the POM for this project will always need the parent POM to be available
- Dependency parent = resolveDependency(pom.getParent(), projectPom, false, false, false, true);
- // The user may have set or unset the --no-parent option, if so we update the POM to include or not the
- // parent according to the user's choice
- if (getPOMOptions(projectPom).isNoParent() != oldNoParent) {
- resetPOM(projectPom);
- pom = getPOM(projectPom);
- }
- pom.setParent(parent);
- // If the parent is found, search the parent POM and update current POM
- if (parent != null) {
- POMInfo parentPOM = getRepository().searchMatchingPOM(parent);
- pom.setParentPOM(parentPOM);
- }
- }
-
- getRepository().registerPom(projectPom, pom);
- // Also register automatically the test jar which may accompany the current jar and be
- // used in another module of the same project
- if ("jar".equals(pom.getThisPom().getType())) {
- POMInfo testPom = (POMInfo) pom.clone();
- testPom.getThisPom().setType("test-jar");
- getRepository().registerPom(projectPom, testPom);
- }
-
- knownProjectDependencies.add(pom.getThisPom());
-
- if (interactive && packageVersion == null) {
- System.out.println("Enter the upstream version for the package. If you press <Enter> it will default to " + pom.getOriginalVersion());
- System.out.print("> ");
- String v = readLine();
- if (v.isEmpty()) {
- v = pom.getOriginalVersion();
- }
- packageVersion = v;
- }
-
- if (pom.getOriginalVersion().equals(packageVersion)) {
- pom.getProperties().put("debian.hasPackageVersion", "true");
- getPOMOptions(projectPom).setHasPackageVersion(true);
- }
-
- if (filterModules) {
- System.out.println("Include the module " + pomRelPath + " ?");
- System.out.print("[y]/n > ");
- String s = readLine().toLowerCase();
- boolean includeModule = !s.startsWith("n");
- if (!includeModule) {
- getPOMOptions(projectPom).setIgnore(true);
- String type = "*";
- if (pom.getThisPom().getType() != null) {
- type = pom.getThisPom().getType();
- }
- String rule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
- + " " + type + " *";
- pomTransformer.getIgnoreRules().add(new DependencyRule(rule));
- return;
- }
- }
-
- projectPoms.add(pom.getThisPom());
-
- // Previous rule from another run
- boolean explicitlyMentionedInRules = false;
- for (DependencyRule previousRule : pomTransformer.getRules().findMatchingRules(pom.getThisPom())) {
- if (!previousRule.equals(DependencyRule.TO_DEBIAN_VERSION_RULE) &&
- !previousRule.equals(DependencyRule.MAVEN_PLUGINS_KEEP_VERSION_RULE) &&
- previousRule.matches(pom.getThisPom())) {
- explicitlyMentionedInRules = true;
- break;
- }
- }
-
- if (interactive && !explicitlyMentionedInRules && !"maven-plugin".equals(pom.getThisPom().getType())) {
- String version = pom.getThisPom().getVersion();
- System.out.println("Version of " + pom.getThisPom().getGroupId() + ":"
- + pom.getThisPom().getArtifactId() + " is " + version);
- System.out.println("Choose how it will be transformed:");
- List<Rule> choices = new ArrayList<Rule>();
-
- if (versionToRules.containsKey(version)) {
- choices.add(versionToRules.get(version));
- }
-
- Pattern p = Pattern.compile("(\\d+)(\\..*)");
- Matcher matcher = p.matcher(version);
- if (matcher.matches()) {
- String mainVersion = matcher.group(1);
- Rule mainVersionRule = new Rule("s/" + mainVersion + "\\..*/" +
- mainVersion + ".x/");
- mainVersionRule.setDescription("Replace all versions starting by "
- + mainVersion + ". with " + mainVersion + ".x");
- if (!choices.contains(mainVersionRule)) {
- choices.add(mainVersionRule);
- }
- }
- for (Rule rule : defaultRules) {
- if (!choices.contains(rule)) {
- choices.add(rule);
- }
- }
-
- int count = 1;
- for (Iterator<Rule> i = choices.iterator(); i.hasNext(); count++) {
- Rule rule = i.next();
- if (count == 1) {
- System.out.print("[1]");
- } else {
- System.out.print(" " + count + " ");
- }
- System.out.println(" - " + rule.getDescription());
- }
- System.out.print("> ");
- String s = readLine().toLowerCase();
- int choice = 1;
- try {
- choice = Integer.parseInt(s);
- } catch (Exception ignore) {
- }
-
- Rule selectedRule = choices.get(choice - 1);
- versionToRules.put(version, selectedRule);
- if (selectedRule.getPattern().equals("CUSTOM")) {
- System.out.println("Enter the pattern for your custom rule (in the form s/regex/replace/)");
- System.out.print("> ");
- s = readLine().toLowerCase();
- selectedRule = new Rule(s);
- selectedRule.setDescription("My custom rule " + s);
- defaultRules.add(selectedRule);
- }
-
- String dependencyRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
- + " " + pom.getThisPom().getType() + " " + selectedRule.toString();
- pomTransformer.getRules().add(new DependencyRule(dependencyRule));
- POMInfo transformedPom = pom.newPOMFromRules(pomTransformer.getRules().getRules(), getRepository());
- getRepository().registerPom(projectPom, transformedPom);
- projectPoms.add(transformedPom.getThisPom());
-
-
- if ("bundle".equals(pom.getThisPom().getType())) {
- System.out.println(pom.getThisPom().getGroupId() + ":" + pom.getThisPom().getArtifactId() +
- " is a bundle.");
- System.out.println("Inform mh_make that dependencies of type jar which may match this library should be transformed into bundles automatically?");
- System.out.print("[y]/n > ");
- s = readLine().toLowerCase();
- boolean transformJarsIntoBundle = !s.startsWith("n");
- if (transformJarsIntoBundle) {
- String transformBundleRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
- + " s/jar/bundle/ " + selectedRule.toString();
- pomTransformer.getPublishedRules().add(new DependencyRule(transformBundleRule));
- }
- }
- }
-
- if (pom.getParent() != null && !pom.getParent().isSuperPom()) {
- POMInfo parentPom = getRepository().searchMatchingPOM(pom.getParent());
- if (parentPom == null || parentPom.equals(getRepository().getSuperPOM())) {
- getPOMOptions(projectPom).setNoParent(true);
- }
- if (!baseDir.equals(projectPom.getParentFile())) {
- System.out.println("Checking the parent dependency in the sub project " + pomRelPath);
- resolveDependency(pom.getParent(), projectPom, false, false, false, true);
- }
- }
-
- resolveDependenciesLater(projectPom, POMInfo.DEPENDENCIES, false, false, false);
- resolveDependenciesLater(projectPom, POMInfo.DEPENDENCY_MANAGEMENT_LIST, false, false, true);
- resolveDependenciesLater(projectPom, POMInfo.PLUGINS, true, true, false);
- resolveDependenciesLater(projectPom, POMInfo.PLUGIN_DEPENDENCIES, true, true, false);
- resolveDependenciesLater(projectPom, POMInfo.PLUGIN_MANAGEMENT, true, true, true);
- resolveDependenciesLater(projectPom, POMInfo.REPORTING_PLUGINS, true, true, false);
- resolveDependenciesLater(projectPom, POMInfo.EXTENSIONS, true, true, false);
-
- if (exploreProjects && !pom.getModules().isEmpty()) {
- if (interactive && !askedToFilterModules) {
- System.out.println("This project contains modules. Include all modules?");
- System.out.print("[y]/n > ");
- String s = readLine().toLowerCase();
- filterModules = s.startsWith("n");
- askedToFilterModules = true;
- }
- for (String module : pom.getModules()) {
- File modulePom = new File(projectPom.getParent(), module + "/pom.xml");
- resolveDependencies(modulePom);
- }
- }
- } catch (Exception ex) {
- log.log(Level.SEVERE, "Error while resolving " + projectPom + ": " + ex.getMessage());
- log.log(Level.SEVERE, "", ex);
- System.exit(1);
- }
- }
-
- private POMInfo getPOM(File projectPom) throws XMLStreamException, IOException {
- POMInfo info = pomInfoCache.get(projectPom.getAbsolutePath());
- if (info != null) {
- return info;
- }
- File tmpDest = File.createTempFile("pom", ".tmp", baseDir);
- tmpDest.deleteOnExit();
- ListOfPOMs.POMOptions options = getPOMOptions(projectPom);
- boolean noParent = false;
- boolean hasPackageVersion = false;
- if (options != null) {
- noParent = options.isNoParent();
- hasPackageVersion = options.getHasPackageVersion();
- }
-
- info = pomTransformer.transformPom(projectPom, tmpDest, noParent, hasPackageVersion, false, false, null, null, true);
- pomInfoCache.put(projectPom.getAbsolutePath(), info);
- return info;
- }
-
- private ListOfPOMs.POMOptions getPOMOptions(File pom) {
- return pomTransformer.getListOfPOMs().getOrCreatePOMOptions(pom);
- }
-
- private void resetPOM(File projectPom) {
- pomInfoCache.remove(projectPom.getAbsolutePath());
- }
-
- private String readLine() {
- LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
- try {
- return consoleReader.readLine().trim();
- } catch (IOException e) {
- e.printStackTrace();
- return "";
- }
- }
-
- private void resolveDependenciesNow() {
- for (Iterator<ToResolve> i = toResolve.iterator(); i.hasNext();) {
- ToResolve tr = i.next();
- tr.resolve();
- i.remove();
- }
- }
-
- private void resolveDependenciesLater(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
- toResolve.add(new ToResolve(sourcePom, listType, buildTime, mavenExtension, management));
- }
-
- private void resolveDependencies(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) throws Exception {
- POMInfo pom = getPOM(sourcePom);
- List<Dependency> dependenciesByType = pom.getAllDependencies(listType);
-
- for (Dependency dependency : dependenciesByType) {
- resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management);
- }
- }
-
- public Dependency resolveDependency(Dependency dependency, File sourcePom, boolean buildTime, boolean mavenExtension, boolean management) throws DependencyNotFoundException {
- return resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management, false);
- }
-
- private Dependency resolveDependency(Dependency dependency, File sourcePom, boolean buildTime, boolean mavenExtension, boolean management, boolean resolvingParent) throws DependencyNotFoundException {
-
- if (containsDependencyIgnoreVersion(knownProjectDependencies, dependency)) {
- return dependency;
- }
-
- if (containsDependencyIgnoreVersion(ignoredDependencies, dependency) ||
- (management && isDefaultMavenPlugin(dependency))) {
- return null;
- }
-
- if (resolvingParent && dependency.isSuperPom()) {
- return dependency;
- }
-
- String sourcePomLoc = sourcePom.getAbsolutePath();
- String baseDirPath = baseDir.getAbsolutePath();
- sourcePomLoc = sourcePomLoc.substring(baseDirPath.length() + 1, sourcePomLoc.length());
- if (verbose) {
- String msg = "Resolving " + dependency;
- if (dependency.getScope() != null) {
- msg += " of scope " + dependency.getScope();
- }
- System.out.println(msg + "...");
- }
-
- // First let the packager mark as ignored those dependencies which should be ignored
- boolean ignoreDependency = false;
- if (!ignoreDependency && canIgnorePlugin(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin is not useful for the build or its use is against Debian policies. Ignore this plugin?");
- }
- if (!ignoreDependency && canIgnoreExtension(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This extension is not useful for the build or its use is against Debian policies. Ignore this extension?");
- }
- if (!ignoreDependency && canBeIgnoredPlugin(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin may be ignored in some cases. Ignore this plugin?");
- }
- if (!ignoreDependency && !runTests) {
- if ("test".equals(dependency.getScope())) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test dependency?");
- } else if (isTestPlugin(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test plugin?");
- }
- }
- if (!ignoreDependency && !generateJavadoc && isDocumentationOrReportPlugin(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Documentation is turned off. Ignore this documentation plugin?");
- }
-
- if (ignoreDependency) {
- ignoredDependencies.add(dependency);
- String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
- pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
- if (verbose) {
- System.out.println("[ignored]");
- }
- return null;
- }
-
- // Automatically skip some dependencies when ant packaging is used
- boolean skipDependency = false;
- String skipReason = "";
- if (packageType.equals("ant")) {
- if ("maven-plugin".equals(dependency.getType())) {
- try {
- if (!getPOM(sourcePom).getThisPom().getType().equals("pom")) {
- skipDependency = true;
- skipReason = "Maven plugins are not used during a build with Ant";
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (!runTests && "test".equals(dependency.getScope())) {
- skipDependency = true;
- skipReason = "Tests are not executed during the build";
- }
- }
- if (skipDependency) {
- // Even if we skip the dependency, try to locate its associated maven rules,
- // as this may be useful later - but never fail if the dependency is not found.
- POMInfo pom = getRepository().searchMatchingPOM(dependency);
- if (pom != null) {
- String mavenRules = pom.getProperties().get("debian.mavenRules");
- if (mavenRules != null) {
- StringTokenizer st = new StringTokenizer(mavenRules, ",");
- while (st.hasMoreTokens()) {
- String ruleDef = st.nextToken().trim();
- pomTransformer.getRules().add(new DependencyRule(ruleDef));
- }
- }
- }
- if (verbose) {
- if (!skipReason.isEmpty()) {
- System.out.println("[skipped - " + skipReason + "]");
- } else {
- System.out.println("[skipped]");
- }
- }
- return null;
- }
-
- POMInfo pom = getRepository().searchMatchingPOM(dependency);
- try {
- if (pom == null && dependency.getVersion() == null) {
- POMInfo containerPom = getPOM(sourcePom);
- String version = containerPom.getVersionFromManagementDependency(dependency);
- dependency.setVersion(version);
- if (version != null) {
- pom = getRepository().searchMatchingPOM(dependency);
- } else {
- System.out.println("In " + sourcePomLoc + ", cannot find the version for dependency " + dependency + " from this POM or its parent POMs");
- if (getPOMOptions(sourcePom).isNoParent()) {
- System.out.println("[warning] Option --no-parent has been set for POM file " + sourcePomLoc + ", maybe it was not a good idea and you should first package the parent POM " + containerPom.getParent());
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (pom == null && dependency.getVersion() != null) {
- List<POMInfo> poms = getRepository().searchMatchingPOMsIgnoreVersion(dependency);
- for (POMInfo potentialPom : poms) {
- String mavenRules = potentialPom.getProperties().get("debian.mavenRules");
- if (mavenRules != null) {
- StringTokenizer st = new StringTokenizer(mavenRules, ",");
- while (st.hasMoreTokens()) {
- String ruleDef = st.nextToken().trim();
- DependencyRule rule = new DependencyRule(ruleDef);
- if (rule.matches(dependency) && rule.apply(dependency).equals(potentialPom.getThisPom())) {
- pom = potentialPom;
- pomTransformer.getRules().add(rule);
- }
- }
- }
- }
- }
- if (pom == null && dependency.getVersion() == null) {
- // Set a dummy version and try again
- for (int version = 0; version < 10; version++) {
- dependency.setVersion(version + ".0");
- pom = getRepository().searchMatchingPOM(dependency);
- if (pom != null) {
- System.out.println("Use best guess version: " + dependency.getVersion() + " for "
- + dependency.getGroupId() + ":" + dependency.getArtifactId());
- break;
- }
- dependency.setVersion(null);
- }
- }
-
- if (pom == null && "maven-plugin".equals(dependency.getType())) {
- List<POMInfo> matchingPoms = getRepository().searchMatchingPOMsIgnoreVersion(dependency);
- if (matchingPoms.size() > 1) {
- issues.add(sourcePomLoc + ": More than one version matches the plugin " + dependency.getGroupId() + ":"
- + dependency.getArtifactId() + ":" + dependency.getVersion());
- }
- if (!matchingPoms.isEmpty()) {
- pom = matchingPoms.get(0);
- // Don't add a rule to force the version of a Maven plugin, it's now done
- // automatically at build time
- }
- }
-
- // Ignore fast cases
- if (pom == null) {
- if (management) {
- if (verbose) {
- System.out.println("[skipped dependency or plugin management]");
- }
- return null;
- } else if ("maven-plugin".equals(dependency.getType()) && packageType.equals("ant")) {
- if (verbose) {
- System.out.println("[skipped - not used in Ant build]");
- }
- return null;
- }
- }
-
- // In case we didn't find anything for "jar" packaging type, just check for a "bundle" type inside repository.
- // Some jars have been upgraded to OSGi bundles as OSGi metadata has been added to them.
- //
- // drazzib: I'm not sure this is really the right way to fix that (ie. maybe we should install "bundle" artifacts
- // directly with "jar" type inside Debian ?).
- //
- // ludovicc: a complex issue, I believe that libraries which evolve from a jar type to a bundle type should
- // inform packagers with a rule of the form
- // '<groupId> <artifactId> s/jar/bundle/ <versionRule>'
- // in other words, the packager of the library should add a published rule which will transform matching
- // libraries from jar type into bundle types, and apply as well the version substitution (for example to 2.x)
- // for Debian.
- //
- if (pom == null && "jar".equals(dependency.getType())) {
- if (verbose) {
- System.out.println("[check dependency with bundle type]");
- }
- Dependency bundleDependency = new Dependency(dependency);
- bundleDependency.setType("bundle");
- pom = getRepository().searchMatchingPOM(bundleDependency);
- if (pom != null) {
- dependency = bundleDependency;
- for (DependencyRule rule: pom.getPublishedRules()) {
- if (rule.matches(dependency)) {
- Dependency transformed = rule.apply(dependency);
- if (transformed.getGroupId().equals(dependency.getGroupId())
- && transformed.getArtifactId().equals(dependency.getArtifactId())
- && transformed.getType().equals(dependency.getType())) {
- String newRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
- + " s/jar/bundle/ " + rule.getVersionRule().toString();
- pomTransformer.getRules().add(new DependencyRule(newRule));
- }
- }
- }
- }
- }
-
- if (pom == null) {
- if (!ignoreDependency) {
- if (resolvingParent) {
- boolean noParent = askIgnoreDependency(sourcePomLoc, dependency,
- "The parent POM cannot be found in the Maven repository for Debian. Ignore it?");
- getPOMOptions(sourcePom).setNoParent(noParent);
- if (noParent) {
- if (verbose) {
- System.out.println("[no-parent]");
- }
- return null;
- }
- } else if (isDocumentationOrReportPlugin(dependency)) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency,
- "This documentation or report plugin cannot be found in the Maven repository for Debian. Ignore this plugin?");
- } else if ("maven-plugin".equals(dependency.getType())) {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin cannot be found in the Debian Maven repository. Ignore this plugin?", false);
- if (!ignoreDependency) {
- issues.add(sourcePomLoc + ": Plugin is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
- + dependency.getArtifactId() + ":" + dependency.getVersion());
- }
- } else {
- ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This dependency cannot be found in the Debian Maven repository. Ignore this dependency?", false);
- if (!ignoreDependency) {
- issues.add(sourcePomLoc + ": Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
- + dependency.getArtifactId() + ":" + dependency.getVersion());
- }
- }
- }
- if (ignoreDependency) {
- ignoredDependencies.add(dependency);
- String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
- pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
- if (verbose) {
- System.out.println("[ignored]");
- }
- return null;
- } else {
- String pkg = searchPkg(new File("/usr/share/maven-repo/"
- + dependency.getGroupId().replace('.', '/')
- + "/" + dependency.getArtifactId()));
- if (pkg != null) {
- String installedVersion = getPackageVersion(pkg, true);
- if (installedVersion != null) {
- System.out.println("[error] Package " + pkg + " (" + installedVersion + ") is already installed and contains a possible match," );
- System.out.println("but I cannot resolve library " + dependency + " in it.");
- System.out.println("[error] Please check manually that the library is up to date, otherwise it may be necessary to package version "
- + dependency.getVersion() + " in Debian.");
- } else {
- System.out.println("[warning] Please install the missing dependency. Run the following command in another terminal:");
- System.out.println(" sudo apt-get install " + pkg);
- }
- }
- if (interactive && pkg == null) {
- pkg = searchPkg(new File("/usr/share/java/" + dependency.getArtifactId() + ".jar"));
- if (pkg != null) {
- System.out.println("[error] Package " + pkg + " does not contain Maven dependency " + dependency + " but there seem to be a match");
- System.out.println("If the package contains already Maven artifacts but the names don't match, try to enter a substitution rule");
- System.out.println("of the form s/groupId/newGroupId/ s/artifactId/newArtifactId/ jar s/version/newVersion/ here:");
- System.out.print("> ");
- String newRule = readLine().trim();
- if (!newRule.isEmpty()) {
- DependencyRule userRule = new DependencyRule(newRule);
- pomTransformer.getRules().add(userRule);
- System.out.println("Please suggest the maintainer of package " + pkg + " to add this rule to debian/maven.publishedRules");
- return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
- }
- } else {
- System.out.println("[error] Cannot resolve Maven dependency " + dependency + ". If you know a package that contains a compatible dependency,");
- System.out.println("Try to enter a substitution rule of the form s/groupId/newGroupId/ s/artifactId/newArtifactId/ jar s/version/newVersion/ here:");
- System.out.print("> ");
- String newRule = readLine().trim();
- if (!newRule.isEmpty()) {
- DependencyRule userRule = new DependencyRule(newRule);
- pomTransformer.getRules().add(userRule);
- return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
- }
- }
- }
- if (interactive) {
- System.out.println("Try again to resolve the dependency?");
- System.out.print("[y]/n > ");
- String s = readLine().trim().toLowerCase();
- if (!s.startsWith("n")) {
- System.out.println("Rescanning /usr/share/maven-repo...");
- pomTransformer.getRepository().scan();
- return resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management);
- }
- }
- if (verbose) {
- System.out.println("[error]");
- }
- throw new DependencyNotFoundException(dependency);
- }
- }
-
- // Handle the case of Maven plugins built and used in a multi-module build:
- // they need to be added to maven.cleanIgnoreRules to avoid errors during
- // a mvn clean
- if ("maven-plugin".equals(dependency.getType()) && containsDependencyIgnoreVersion(projectPoms, dependency)) {
- String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " maven-plugin *";
- cleanIgnoreRules.add(new DependencyRule(ruleDef));
- }
-
- // Discover the library to import for the dependency
- String pkg = getPackage(pom, sourcePomLoc);
-
- if (pkg != null && !pkg.equals(getPackageName())) {
- String libraryWithVersionConstraint = pkg;
- String version = dependency.getVersion();
- if (version == null || (pom.getOriginalVersion() != null && version.compareTo(pom.getOriginalVersion()) > 0)) {
- version = pom.getOriginalVersion();
- }
- if (pom.getOriginalVersion() != null && (pom.getProperties().containsKey("debian.hasPackageVersion"))) {
- libraryWithVersionConstraint += " (>= " + version + ")";
- }
- if (!management) {
- if (buildTime) {
- if ("test".equals(dependency.getScope())) {
- testDepends.add(libraryWithVersionConstraint);
- } else if ("maven-plugin".equals(dependency.getType())) {
- if (!packageType.equals("ant")) {
- compileDepends.add(libraryWithVersionConstraint);
- }
- } else if (mavenExtension) {
- if (!packageType.equals("ant")) {
- compileDepends.add(libraryWithVersionConstraint);
- }
- } else {
- compileDepends.add(libraryWithVersionConstraint);
- }
- } else {
- if (dependency.isOptional()) {
- optionalDepends.add(libraryWithVersionConstraint);
- } else if ("test".equals(dependency.getScope())) {
- testDepends.add(libraryWithVersionConstraint);
- } else {
- runtimeDepends.add(libraryWithVersionConstraint);
- }
- }
- }
- versionedPackagesAndDependencies.put(libraryWithVersionConstraint, dependency);
- }
-
- String mavenRules = pom.getProperties().get("debian.mavenRules");
- if (mavenRules != null) {
- StringTokenizer st = new StringTokenizer(mavenRules, ",");
- while (st.hasMoreTokens()) {
- String ruleDef = st.nextToken().trim();
- pomTransformer.getRules().add(new DependencyRule(ruleDef));
- }
- }
- if (verbose) {
- System.out.println("Dependency " + dependency + " found in package " + pkg);
- System.out.println("[ok]");
- System.out.println();
- }
-
- if (resolvingParent) {
- try {
- POMInfo containerPom = getPOM(sourcePom);
- containerPom.setParentPOM(pom);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return pom.getThisPom();
- }
-
- private String getPackage(POMInfo pom, String sourcePomLoc) {
- String pkg = null;
- if (pom.getProperties() != null) {
- pkg = pom.getProperties().get("debian.package");
- }
- if (pkg == null) {
- Dependency dependency = pom.getThisPom();
- issues.add(sourcePomLoc + ": Dependency is missing the Debian properties in its POM: " + dependency.getGroupId() + ":"
- + dependency.getArtifactId() + ":" + dependency.getVersion());
- File pomFile = new File(mavenRepo, dependency.getGroupId().replace(".", "/") + "/" + dependency.getArtifactId() + "/" + dependency.getVersion() + "/" + dependency.getArtifactId() + "-" + dependency.getVersion() + ".pom");
- pkg = searchPkg(pomFile);
- }
- return pkg;
- }
-
- private String getPackageVersion(String pkg, boolean onlyInstalled) {
- GetPackageVersionResult packageResult = new GetPackageVersionResult();
- executeProcess(new String[]{"dpkg", "--status", pkg}, packageResult);
- if (packageResult.getResult() != null) {
- return packageResult.getResult();
- }
- if (!onlyInstalled) {
- GetChangelogVersionResult versionResult = new GetChangelogVersionResult(pkg);
- executeProcess(new String[]{"apt-get", "--no-act", "--verbose-versions", "install", pkg}, versionResult);
- if (versionResult.getResult() != null) {
- return versionResult.getResult();
- }
- }
- return null;
- }
-
- private boolean containsDependencyIgnoreVersion(Collection<Dependency> dependencies, Dependency dependency) {
- for (Dependency ignoredDependency : dependencies) {
- if (ignoredDependency.equalsIgnoreVersion(dependency)) {
- return true;
- }
- }
- return false;
- }
-
- private String searchPkg(File file) {
- if (filesInPackages.containsKey(file)) {
- return filesInPackages.get(file);
- }
-
- GetPackageResult packageResult = new GetPackageResult();
- executeProcess(new String[]{"dpkg", "--search", file.getAbsolutePath()}, packageResult);
- if (packageResult.getResult() != null) {
- String pkg = packageResult.getResult();
- if (pkg != null) {
- filesInPackages.put(file, pkg);
- }
- return pkg;
- }
-
- // Debian policy prevents the use of apt-file during a build
- if (offline) {
- return null;
- }
-
- if (!new File("/usr/bin/apt-file").exists()) {
- return null;
- }
- executeProcess(new String[]{"apt-file", "search", file.getAbsolutePath()}, packageResult);
- String pkg = packageResult.getResult();
- if (pkg != null) {
- filesInPackages.put(file, pkg);
- }
- return pkg;
- }
-
- public static void executeProcess(final String[] cmd, final OutputHandler handler) {
- try {
- ProcessBuilder pb = new ProcessBuilder(cmd);
- pb.redirectErrorStream(true);
- System.out.print("> ");
- for (String arg : cmd) {
- System.out.print(arg + " ");
- }
- System.out.println();
- final Process process = pb.start();
- try {
- ThreadFactory threadFactory = new ThreadFactory() {
-
- public Thread newThread(Runnable r) {
- Thread t = new Thread(r, "Run command " + cmd[0]);
- t.setDaemon(true);
- return t;
- }
- };
-
- ExecutorService executor = Executors.newSingleThreadExecutor(threadFactory);
- executor.execute(new Runnable() {
-
- public void run() {
- try {
- InputStreamReader isr = new InputStreamReader(process.getInputStream());
- BufferedReader br = new BufferedReader(isr);
- LineNumberReader aptIn = new LineNumberReader(br);
- String line;
- while ((line = aptIn.readLine()) != null) {
- handler.newLine(line);
- }
- aptIn.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- });
-
- process.waitFor();
- executor.awaitTermination(5, TimeUnit.SECONDS);
- if (process.exitValue() == 0) {
- } else {
- System.out.println(cmd[0] + " failed to execute successfully");
- }
- process.destroy();
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- Thread.interrupted();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- private String toString(Set<String> s) {
- StringBuffer sb = new StringBuffer();
- for (Iterator<String> i = s.iterator(); i.hasNext();) {
- String st = i.next();
- sb.append(st);
- if (i.hasNext()) {
- sb.append(", ");
- }
- }
- return sb.toString();
- }
-
- public static interface OutputHandler {
-
- void newLine(String line);
- }
-
- public static class NoOutputHandler implements OutputHandler {
-
- public void newLine(String line) {
- }
- }
-
- static class GetPackageResult implements OutputHandler {
-
- private String result;
-
- public void newLine(String line) {
- if (result != null) {
- return;
- }
- int colon = line.indexOf(':');
- if (colon > 0 && line.indexOf(' ') > colon) {
- result = line.substring(0, colon);
- // Ignore lines such as 'dpkg : xxx'
- if (!result.equals(result.trim()) || result.startsWith("dpkg")) {
- result = null;
- } else {
- System.out.println("Found " + result);
- }
- }
- }
-
- public String getResult() {
- return result;
- }
-
- }
-
- static class GetPackageVersionResult implements OutputHandler {
-
- private String result;
-
- public void newLine(String line) {
- if (result != null) {
- return;
- }
- if (line.startsWith("Version:")) {
- int space = line.indexOf(' ');
- result = line.substring(space + 1, line.length()).trim();
- }
- }
-
- public String getResult() {
- return result;
- }
-
- }
-
- static class GetChangelogVersionResult implements OutputHandler {
-
- private String result;
- private final Pattern pattern;
-
- public GetChangelogVersionResult(String pkg) {
- this.pattern = Pattern.compile(pkg + "\\s\\(.*\\)");
- }
-
- public void newLine(String line) {
- if (result != null) {
- return;
- }
- Matcher match = pattern.matcher(line);
- if (match.find()) {
- result = match.group(1);
- }
- }
-
- public String getResult() {
- return result;
- }
-
- }
-
- public static void main(String[] args) {
- if (args.length == 0 || "-h".equals(args[0]) || "--help".equals(args[0])) {
- System.out.println("Purpose: Solve the dependencies in the POM(s).");
- System.out.println("Usage: [option]");
- System.out.println("");
- System.out.println("Options:");
- System.out.println(" -v, --verbose: be extra verbose");
- System.out.println(" -p<package>, --package=<package>: name of the Debian package containing");
- System.out.println(" this library");
-// System.out.println(" -r<rules>, --rules=<rules>: path to the file containing the");
-// System.out.println(" extra rules to apply when cleaning the POM");
-// System.out.println(" -i<rules>, --published-rules=<rules>: path to the file containing the");
-// System.out.println(" extra rules to publish in the property debian.mavenRules in the cleaned POM");
- System.out.println(" --ant: use ant for the packaging");
- System.out.println(" --run-tests: run the unit tests");
- System.out.println(" --generate-javadoc: generate Javadoc");
- System.out.println(" --non-interactive: non interactive session");
- System.out.println(" --offline: offline mode for Debian build compatibility");
- System.out.println(" -m<repo root>--maven-repo=<repo root>: location of the Maven repository,");
- System.out.println(" used to force the versions of the Maven plugins used in the current");
- System.out.println(" POM file with the versions found in the repository");
- System.out.println(" --base-directory: path to root directory of package");
- System.out.println(" --non-explore: doesn't explore directories for pom.xml");
- return;
- }
-
- // Default values
- boolean verbose = false;
- String debianPackage = "";
- String packageType = "maven";
- File mavenRepo = null;
- File baseDirectory = new File(".");
-
- DependenciesSolver solver = new DependenciesSolver();
- solver.setExploreProjects(true); // can be overriden by args
-
- // Parse parameters
- int i = inc(-1, args);
- while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
- String arg = args[i].trim();
- if ("--verbose".equals(arg) || "-v".equals(arg)) {
- verbose = true;
- } else if ("--debug".equals(arg)) {
- log.setLevel(Level.FINEST);
- } else if (arg.startsWith("-p")) {
- debianPackage = arg.substring(2);
- } else if (arg.startsWith("--package=")) {
- debianPackage = arg.substring("--package=".length());
- } else if (arg.equals("--ant")) {
- packageType = "ant";
- } else if (arg.equals("--run-tests")) {
- solver.setRunTests(true);
- } else if (arg.equals("--generate-javadoc")) {
- solver.setGenerateJavadoc(true);
- } else if (arg.equals("--non-interactive")) {
- solver.setInteractive(false);
- } else if (arg.equals("--offline")) {
- solver.setOffline(true);
- } else if (arg.startsWith("-m")) {
- mavenRepo = new File(arg.substring(2));
- } else if (arg.startsWith("--maven-repo=")) {
- mavenRepo = new File(arg.substring("--maven-repo=".length()));
- } else if (arg.startsWith("-b")) {
- baseDirectory = new File(arg.substring(2));
- } else if (arg.startsWith("--base-directory=")) {
- baseDirectory = new File(arg.substring("--base-directory=".length()));
- } else if (arg.equals("--non-explore")) {
- solver.setExploreProjects(false);
- }
- i = inc(i, args);
- }
-
- solver.setBaseDir(baseDirectory);
- solver.setOutputDirectory(new File(baseDirectory, "debian"));
- solver.setPackageName(debianPackage);
- solver.setPackageType(packageType);
- File poms = new File(solver.getOutputDirectory(), debianPackage + ".poms");
- solver.setListOfPoms(poms);
-
- if (mavenRepo != null) {
- Repository repository = new Repository(mavenRepo);
- solver.getPomTransformer().setRepository(repository);
- solver.getPomTransformer().usePluginVersionsFromRepository();
- }
-
- if (verbose) {
- String msg = "Solving dependencies for package " + debianPackage;
- if (solver.isRunTests()) {
- msg += " (tests are included)";
- }
- if (solver.isGenerateJavadoc()) {
- msg += " (documentation is included)";
- }
- System.out.println(msg);
- solver.setVerbose(true);
- }
-
- solver.solveDependencies();
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveMavenIgnoreRules();
- solver.saveMavenCleanIgnoreRules();
- solver.saveMavenPublishedRules();
- solver.saveSubstvars();
-
- if (!solver.getIssues().isEmpty()) {
- System.exit(1);
- }
- }
-
- private static int inc(int i, String[] args) {
- do {
- i++;
- } while (i < args.length && args[i].isEmpty());
- return i;
- }
-}
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,1639 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ * Copyright 2011 Damien Raude-Morvan.
+ *
+ * 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.debian.maven.repo.Dependency;
+import org.debian.maven.repo.DependencyNotFoundException;
+import org.debian.maven.repo.DependencyRule;
+import org.debian.maven.repo.DependencyRuleSet;
+import org.debian.maven.repo.ListOfPOMs;
+import org.debian.maven.repo.POMHandler;
+import org.debian.maven.repo.POMInfo;
+import org.debian.maven.repo.POMTransformer;
+import org.debian.maven.repo.Repository;
+import org.debian.maven.repo.Rule;
+
+/**
+ * Analyze the Maven dependencies and extract the Maven rules to use
+ * as well as the list of dependent packages.
+ *
+ * @author Ludovic Claude
+ */
+public class DependenciesSolver {
+
+ private static final Logger log = Logger.getLogger(DependenciesSolver.class.getName());
+
+ // Plugins not useful for the build or whose use is against the
+ // Debian policy
+ private static final String[][] PLUGINS_TO_IGNORE = {
+ {"org.apache.maven.plugins", "maven-archetype-plugin"},
+ {"org.apache.maven.plugins", "changelog-maven-plugin"},
+ {"org.apache.maven.plugins", "maven-deploy-plugin"},
+ {"org.apache.maven.plugins", "maven-release-plugin"},
+ {"org.apache.maven.plugins", "maven-repository-plugin"},
+ {"org.apache.maven.plugins", "maven-scm-plugin"},
+ {"org.apache.maven.plugins", "maven-stage-plugin"},
+ {"org.apache.maven.plugins", "maven-eclipse-plugin"},
+ {"org.apache.maven.plugins", "maven-idea-plugin"},
+ {"org.apache.maven.plugins", "maven-source-plugin"},
+ {"org.codehaus.mojo", "changelog-maven-plugin"},
+ {"org.codehaus.mojo", "netbeans-freeform-maven-plugin"},
+ {"org.codehaus.mojo", "nbm-maven-plugin"},
+ {"org.codehaus.mojo", "ideauidesigner-maven-plugin"},
+ {"org.codehaus.mojo", "scmchangelog-maven-plugin"},};
+ private static final String[][] PLUGINS_THAT_CAN_BE_IGNORED = {
+ {"org.apache.maven.plugins", "maven-ant-plugin"},
+ {"org.apache.maven.plugins", "maven-assembly-plugin"},
+ {"org.apache.maven.plugins", "maven-enforcer-plugin"},
+ {"org.apache.maven.plugins", "maven-gpg-plugin"},
+ {"org.apache.rat", "apache-rat-plugin"},
+ {"org.codehaus.mojo", "buildnumber-maven-plugin"},
+ {"org.apache.maven.plugins", "maven-verifier-plugin"},
+ {"org.codehaus.mojo", "findbugs-maven-plugin"},
+ {"org.codehaus.mojo", "fitnesse-maven-plugin"},
+ {"org.codehaus.mojo", "selenium-maven-plugin"},
+ {"org.codehaus.mojo", "dbunit-maven-plugin"},
+ {"org.codehaus.mojo", "failsafe-maven-plugin"},
+ {"org.codehaus.mojo", "shitty-maven-plugin"},};
+ private static final String[][] DOC_PLUGINS = {
+ {"org.apache.maven.plugins", "maven-changelog-plugin"},
+ {"org.apache.maven.plugins", "maven-changes-plugin"},
+ {"org.apache.maven.plugins", "maven-checkstyle-plugin"},
+ {"org.apache.maven.plugins", "maven-clover-plugin"},
+ {"org.apache.maven.plugins", "maven-docck-plugin"},
+ {"org.apache.maven.plugins", "maven-javadoc-plugin"},
+ {"org.apache.maven.plugins", "maven-jxr-plugin"},
+ {"org.apache.maven.plugins", "maven-pmd-plugin"},
+ {"org.apache.maven.plugins", "maven-project-info-reports-plugin"},
+ {"org.apache.maven.plugins", "maven-surefire-report-plugin"},
+ {"org.apache.maven.plugins", "maven-pdf-plugin"},
+ {"org.apache.maven.plugins", "maven-site-plugin"},
+ {"org.codehaus.mojo", "changes-maven-plugin"},
+ {"org.codehaus.mojo", "clirr-maven-plugin"},
+ {"org.codehaus.mojo", "cobertura-maven-plugin"},
+ {"org.codehaus.mojo", "taglist-maven-plugin"},
+ {"org.codehaus.mojo", "dita-maven-plugin"},
+ {"org.codehaus.mojo", "docbook-maven-plugin"},
+ {"org.codehaus.mojo", "javancss-maven-plugin"},
+ {"org.codehaus.mojo", "jdepend-maven-plugin"},
+ {"org.codehaus.mojo", "jxr-maven-plugin"},
+ {"org.codehaus.mojo", "dashboard-maven-plugin"},
+ {"org.codehaus.mojo", "emma-maven-plugin"},
+ {"org.codehaus.mojo", "sonar-maven-plugin"},
+ {"org.codehaus.mojo", "surefire-report-maven-plugin"},
+ {"org.jboss.maven.plugins", "maven-jdocbook-plugin"},
+ };
+ private static final String[][] TEST_PLUGINS = {
+ {"org.apache.maven.plugins", "maven-failsafe-plugin"},
+ {"org.apache.maven.plugins", "maven-surefire-plugin"},
+ {"org.apache.maven.plugins", "maven-verifier-plugin"},
+ {"org.codehaus.mojo", "findbugs-maven-plugin"},
+ {"org.codehaus.mojo", "fitnesse-maven-plugin"},
+ {"org.codehaus.mojo", "selenium-maven-plugin"},
+ {"org.codehaus.mojo", "dbunit-maven-plugin"},
+ {"org.codehaus.mojo", "failsafe-maven-plugin"},
+ {"org.codehaus.mojo", "shitty-maven-plugin"},};
+ private static final String[][] EXTENSIONS_TO_IGNORE = {
+ {"org.apache.maven.wagon", "wagon-ssh"},
+ {"org.apache.maven.wagon", "wagon-ssh-external"},
+ {"org.apache.maven.wagon", "wagon-ftp"},
+ {"org.apache.maven.wagon", "wagon-http"},
+ {"org.apache.maven.wagon", "wagon-http-lightweight"},
+ {"org.apache.maven.wagon", "wagon-scm"},
+ {"org.apache.maven.wagon", "wagon-webdav"},
+ {"org.apache.maven.wagon", "wagon-webdav-jackrabbit"},
+ {"org.jvnet.wagon-svn", "wagon-svn"},
+ };
+
+ protected File baseDir;
+ protected POMTransformer pomTransformer = new POMTransformer();
+ protected File outputDirectory;
+ protected String packageName;
+ protected String packageType;
+ private String packageVersion;
+ protected File mavenRepo = new File("/usr/share/maven-repo");
+ protected boolean exploreProjects;
+ private Repository repository;
+ private List<String> issues = new ArrayList<String>();
+ private List<Dependency> projectPoms = new ArrayList<Dependency>();
+ private List<ToResolve> toResolve = new ArrayList<ToResolve>();
+ private Set<Dependency> knownProjectDependencies = new TreeSet<Dependency>();
+ private Set<Dependency> ignoredDependencies = new TreeSet<Dependency>();
+ private Set<Dependency> notIgnoredDependencies = new TreeSet<Dependency>();
+ private Set<String> compileDepends = new TreeSet<String>();
+ private Set<String> testDepends = new TreeSet<String>();
+ private Set<String> runtimeDepends = new TreeSet<String>();
+ private Set<String> optionalDepends = new TreeSet<String>();
+ private DependencyRuleSet cleanIgnoreRules = new DependencyRuleSet("Ignore rules to be applied during the Maven clean phase",
+ new File("debian/maven.cleanIgnoreRules"));
+ private boolean offline;
+ private boolean runTests;
+ private boolean generateJavadoc;
+ private boolean interactive = true;
+ private boolean askedToFilterModules = false;
+ private boolean filterModules = false;
+ private boolean verbose = false;
+ private Map<String, POMInfo> pomInfoCache = new HashMap<String, POMInfo>();
+ // Keep the previous selected rule for a given version
+ private Map<String, Rule> versionToRules = new HashMap<String, Rule>();
+ // Keep the list of known files and their package
+ private Map<File, String> filesInPackages = new HashMap<File, String>();
+ // Keep the list of packages and dependencies
+ private Map<String, Dependency> versionedPackagesAndDependencies = new HashMap<String, Dependency>();
+ private List<Rule> defaultRules = new ArrayList<Rule>();
+
+ public DependenciesSolver() {
+ pomTransformer.setVerbose(true);
+ pomTransformer.setFixVersions(false);
+ pomTransformer.getRules().setWarnRulesFileNotFound(false);
+ pomTransformer.getRules().setDescription(readResource("maven.rules.description"));
+ pomTransformer.getIgnoreRules().setDescription(readResource("maven.ignoreRules.description"));
+ pomTransformer.getIgnoreRules().setWarnRulesFileNotFound(false);
+ pomTransformer.getPublishedRules().setDescription(readResource("maven.publishedRules.description"));
+ pomTransformer.getPublishedRules().setWarnRulesFileNotFound(false);
+ cleanIgnoreRules.setDescription(readResource("maven.cleanIgnoreRules.description"));
+ cleanIgnoreRules.setWarnRulesFileNotFound(false);
+ cleanIgnoreRules.setVerbose(true);
+ cleanIgnoreRules.setDontDuplicate(pomTransformer.getIgnoreRules());
+
+ Rule toDebianRule = new Rule("s/.*/debian/");
+ toDebianRule.setDescription("Change the version to the symbolic 'debian' version");
+ Rule keepVersionRule = new Rule("*");
+ keepVersionRule.setDescription("Keep the version");
+ Rule customRule = new Rule("CUSTOM");
+ customRule.setDescription("Custom rule");
+ defaultRules.add(toDebianRule);
+ defaultRules.add(keepVersionRule);
+ defaultRules.add(customRule);
+ }
+
+ private static String readResource(String resource) {
+ StringBuffer sb = new StringBuffer();
+ try {
+ InputStream is = DependenciesSolver.class.getResourceAsStream("/" + resource);
+ LineNumberReader r = new LineNumberReader(new InputStreamReader(is));
+ String line;
+ while ((line = r.readLine()) != null) {
+ sb.append(line);
+ sb.append("\n");
+ }
+ r.close();
+ } catch (IOException e) {
+ log.log(Level.SEVERE, "Cannot read resource " + resource, e);
+ }
+ return sb.toString();
+ }
+
+ public boolean isRunTests() {
+ return runTests;
+ }
+
+ public void setRunTests(boolean b) {
+ this.runTests = b;
+ }
+
+ public void setOffline(boolean offline) {
+ this.offline = offline;
+ }
+
+ public boolean isGenerateJavadoc() {
+ return generateJavadoc;
+ }
+
+ public void setGenerateJavadoc(boolean b) {
+ this.generateJavadoc = b;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ private boolean containsPlugin(String[][] pluginDefinitions, Dependency plugin) {
+ for (String[] pluginDefinition : pluginDefinitions) {
+ if (!plugin.getGroupId().equals(pluginDefinition[0])) {
+ continue;
+ }
+ if (plugin.getArtifactId().equals(pluginDefinition[1])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isDocumentationOrReportPlugin(Dependency dependency) {
+ return containsPlugin(DOC_PLUGINS, dependency);
+ }
+
+ private boolean isTestPlugin(Dependency dependency) {
+ return containsPlugin(TEST_PLUGINS, dependency);
+ }
+
+ private boolean isDefaultMavenPlugin(Dependency dependency) {
+ if (getRepository() != null && getRepository().getSuperPOM() != null) {
+ for (Dependency defaultPlugin : getRepository().getSuperPOM().getPluginManagement()) {
+ if (defaultPlugin.equalsIgnoreVersion(dependency)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean canIgnorePlugin(Dependency dependency) {
+ return containsPlugin(PLUGINS_TO_IGNORE, dependency);
+ }
+
+ private boolean canIgnoreExtension(Dependency dependency) {
+ return containsPlugin(EXTENSIONS_TO_IGNORE, dependency);
+ }
+
+ private boolean canBeIgnoredPlugin(Dependency dependency) {
+ return containsPlugin(PLUGINS_THAT_CAN_BE_IGNORED, dependency);
+ }
+
+ private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message) {
+ return askIgnoreDependency(sourcePomLoc, dependency, message, true);
+ }
+
+ private boolean askIgnoreDependency(String sourcePomLoc, Dependency dependency, String message, boolean defaultToIgnore) {
+ if (!interactive || notIgnoredDependencies.contains(dependency)) {
+ return false;
+ }
+ System.out.println();
+ System.out.println("In " + sourcePomLoc + ":");
+ System.out.println(message);
+ System.out.println(" " + dependency);
+ if (defaultToIgnore) {
+ System.out.print("[y]/n > ");
+ } else {
+ System.out.print("y/[n] > ");
+ }
+ String s = readLine().toLowerCase();
+ boolean ignore = defaultToIgnore ? !s.startsWith("n") : s.startsWith("y");
+ if (!ignore) {
+ notIgnoredDependencies.add(dependency);
+ }
+ return ignore;
+ }
+
+ public boolean isInteractive() {
+ return interactive;
+ }
+
+ public void setInteractive(boolean interactive) {
+ this.interactive = interactive;
+ }
+
+ POMTransformer getPomTransformer() {
+ return pomTransformer;
+ }
+
+ public ListOfPOMs getListOfPOMs() {
+ return pomTransformer.getListOfPOMs();
+ }
+
+ private class ToResolve {
+
+ private final File sourcePom;
+ private final String listType;
+ private final boolean buildTime;
+ private final boolean mavenExtension;
+ private final boolean management;
+
+ private ToResolve(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
+ this.sourcePom = sourcePom;
+ this.listType = listType;
+ this.buildTime = buildTime;
+ this.mavenExtension = mavenExtension;
+ this.management = management;
+ }
+
+ public void resolve() {
+ try {
+ resolveDependencies(sourcePom, listType, buildTime, mavenExtension, management);
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "Cannot resolve dependencies in " + sourcePom + ": " + e.getMessage());
+ }
+ }
+ }
+
+ public File getBaseDir() {
+ return baseDir;
+ }
+
+ public void saveListOfPoms() {
+ pomTransformer.getListOfPOMs().save();
+ }
+
+ public void saveMavenRules() {
+ pomTransformer.getRules().save();
+ }
+
+ public void saveMavenPublishedRules() {
+ pomTransformer.getPublishedRules().save();
+ }
+
+ public void saveMavenIgnoreRules() {
+ pomTransformer.getIgnoreRules().save();
+ }
+
+ public void saveMavenCleanIgnoreRules() {
+ cleanIgnoreRules.save();
+ }
+
+ public void saveSubstvars() {
+ File dependencies = new File(outputDirectory, packageName + ".substvars");
+ Properties depVars = new Properties();
+ if (dependencies.exists()) {
+ try {
+ depVars.load(new FileReader(dependencies));
+ } catch (IOException ex) {
+ log.log(Level.SEVERE, "Error while reading file " + dependencies, ex);
+ }
+ }
+ depVars.put("maven.CompileDepends", toString(compileDepends));
+ depVars.put("maven.TestDepends", toString(testDepends));
+ depVars.put("maven.Depends", toString(runtimeDepends));
+ depVars.put("maven.OptionalDepends", toString(optionalDepends));
+ if (generateJavadoc) {
+ System.out.println("Checking dependencies for documentation packages...");
+ Set<String> docRuntimeDepends = new TreeSet<String>();
+ docRuntimeDepends.add("default-jdk-doc");
+ for (String dependency : runtimeDepends) {
+ Dependency runtimeDependency = versionedPackagesAndDependencies.get(dependency);
+ if (dependency.indexOf(' ') > 0) {
+ dependency = dependency.substring(0, dependency.indexOf(' '));
+ }
+ if (runtimeDependency != null && "pom".equals(runtimeDependency.getType())) {
+ continue;
+ }
+ String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
+ if (docPkg != null) {
+ docRuntimeDepends.add(docPkg);
+ }
+ }
+ Set<String> docOptionalDepends = new TreeSet<String>();
+ for (String dependency : optionalDepends) {
+ Dependency optionalDependency = versionedPackagesAndDependencies.get(dependency);
+ if (dependency.indexOf(' ') > 0) {
+ dependency = dependency.substring(0, dependency.indexOf(' '));
+ }
+ if (optionalDependency != null && "pom".equals(optionalDependency.getType())) {
+ continue;
+ }
+ String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
+ if (docPkg != null) {
+ docOptionalDepends.add(docPkg);
+ }
+ }
+ depVars.put("maven.DocDepends", toString(docRuntimeDepends));
+ depVars.put("maven.DocOptionalDepends", toString(docOptionalDepends));
+ }
+ if (packageVersion != null) {
+ depVars.put("maven.UpstreamPackageVersion", packageVersion);
+ }
+ // Write everything to debian/substvars
+ try {
+ FileWriter fstream = new FileWriter(dependencies);
+ BufferedWriter out = new BufferedWriter(fstream);
+ out.write("#List of dependencies for " + packageName + ", generated for use by debian/control");
+ out.write("\n");
+ Set<String> propertiesNames = depVars.stringPropertyNames();
+ if (propertiesNames != null) {
+ for (String propName : propertiesNames) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(propName);
+ sb.append("=");
+ sb.append(depVars.get(propName));
+ sb.append("\n");
+ out.write(sb.toString());
+ }
+ }
+ out.close();
+ } catch (IOException ex) {
+ log.log(Level.SEVERE, "Error while saving file " + dependencies, ex);
+ }
+ }
+
+ public void setBaseDir(File baseDir) {
+ this.baseDir = baseDir;
+ if (pomTransformer.getListOfPOMs() != null) {
+ pomTransformer.getListOfPOMs().setBaseDir(baseDir);
+ }
+ }
+
+ public void setListOfPoms(File listOfPoms) {
+ if (pomTransformer.getListOfPOMs() == null) {
+ pomTransformer.setListOfPOMs(new ListOfPOMs(listOfPoms));
+ } else {
+ pomTransformer.getListOfPOMs().setListOfPOMsFile(listOfPoms);
+ }
+ pomTransformer.getListOfPOMs().setBaseDir(baseDir);
+ }
+
+ public boolean isExploreProjects() {
+ return exploreProjects;
+ }
+
+ public void setExploreProjects(boolean exploreProjects) {
+ this.exploreProjects = exploreProjects;
+ }
+
+ public File getMavenRepo() {
+ return mavenRepo;
+ }
+
+ public void setMavenRepo(File mavenRepo) {
+ this.mavenRepo = mavenRepo;
+ }
+
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ public void setOutputDirectory(File outputDirectory) {
+ this.outputDirectory = outputDirectory;
+ File rulesFile = new File(outputDirectory, "maven.rules");
+ if (rulesFile.exists() && verbose) {
+ System.out.println("Use existing rules:");
+ }
+ pomTransformer.getRules().setRulesFile(rulesFile);
+
+ File ignoreRulesFile = new File(outputDirectory, "maven.ignoreRules");
+ if (ignoreRulesFile.exists() && verbose) {
+ System.out.println();
+ System.out.println("Use existing ignore rules:");
+ }
+ pomTransformer.getIgnoreRules().setRulesFile(ignoreRulesFile);
+
+ File publishedRulesFile = new File(outputDirectory, "maven.publishedRules");
+ if (publishedRulesFile.exists() && verbose) {
+ System.out.println();
+ System.out.println("Use existing published rules:");
+ }
+ pomTransformer.getPublishedRules().setRulesFile(publishedRulesFile);
+
+ File cleanIgnoreRules = new File(outputDirectory, "maven.cleanIgnoreRules");
+ if (cleanIgnoreRules.exists() && verbose) {
+ System.out.println();
+ System.out.println("Use existing clean ignore rules:");
+ }
+ this.cleanIgnoreRules.setRulesFile(cleanIgnoreRules);
+
+ if (verbose) {
+ System.out.println();
+ }
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public String getPackageType() {
+ return packageType;
+ }
+
+ public void setPackageType(String packageType) {
+ this.packageType = packageType;
+ }
+
+ public List<String> getIssues() {
+ return issues;
+ }
+
+ private Repository getRepository() {
+ if (repository == null && mavenRepo != null) {
+ repository = new Repository(mavenRepo);
+ repository.scan();
+ }
+ return repository;
+ }
+
+ public void solveDependencies() {
+ pomTransformer.setRepository(getRepository());
+ pomTransformer.usePluginVersionsFromRepository();
+
+ File f = outputDirectory;
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+
+ if (exploreProjects) {
+ File pom;
+ if (pomTransformer.getListOfPOMs().getPomOptions().isEmpty()) {
+ pom = new File(baseDir, "pom.xml");
+ if (pom.exists()) {
+ pomTransformer.getListOfPOMs().addPOM("pom.xml");
+ } else {
+ pom = new File(baseDir, "debian/pom.xml");
+ if (pom.exists()) {
+ pomTransformer.getListOfPOMs().addPOM("debian/pom.xml");
+ } else {
+ System.err.println("Cannot find the POM file");
+ return;
+ }
+ }
+ } else {
+ pom = new File(baseDir, pomTransformer.getListOfPOMs().getFirstPOM());
+ }
+ resolveDependencies(pom);
+ } else {
+ pomTransformer.getListOfPOMs().foreachPoms(new POMHandler() {
+
+ public void handlePOM(File pomFile, boolean noParent, boolean hasPackageVersion) throws Exception {
+ resolveDependencies(pomFile);
+ }
+
+ public void ignorePOM(File pomFile) throws Exception {
+ }
+ });
+ }
+
+ resolveDependenciesNow();
+
+ if (!issues.isEmpty()) {
+ System.err.println("ERROR:");
+ for (String issue : issues) {
+ System.err.println(issue);
+ }
+ System.err.println("--------");
+ }
+ }
+
+ private void resolveDependencies(File projectPom) {
+
+ if (getPOMOptions(projectPom) != null && getPOMOptions(projectPom).isIgnore()) {
+ return;
+ }
+
+ String pomRelPath = projectPom.getAbsolutePath().substring(baseDir.getAbsolutePath().length() + 1);
+ System.out.println("Analysing " + pomRelPath + "...");
+
+ try {
+ POMInfo pom = getPOM(projectPom);
+ pom.setProperties(new HashMap<String, String>());
+ pom.getProperties().put("debian.package", getPackageName());
+
+ if (getPOMOptions(projectPom).isNoParent()) {
+ pom.setParent(null);
+ } else if (pom.getParent() != null && !pom.getParent().isSuperPom()) {
+ boolean oldNoParent = getPOMOptions(projectPom).isNoParent();
+ // Don't mark the parent dependency as 'build time' dependency because once installed,
+ // the POM for this project will always need the parent POM to be available
+ Dependency parent = resolveDependency(pom.getParent(), projectPom, false, false, false, true);
+ // The user may have set or unset the --no-parent option, if so we update the POM to include or not the
+ // parent according to the user's choice
+ if (getPOMOptions(projectPom).isNoParent() != oldNoParent) {
+ resetPOM(projectPom);
+ pom = getPOM(projectPom);
+ }
+ pom.setParent(parent);
+ // If the parent is found, search the parent POM and update current POM
+ if (parent != null) {
+ POMInfo parentPOM = getRepository().searchMatchingPOM(parent);
+ pom.setParentPOM(parentPOM);
+ }
+ }
+
+ getRepository().registerPom(projectPom, pom);
+ // Also register automatically the test jar which may accompany the current jar and be
+ // used in another module of the same project
+ if ("jar".equals(pom.getThisPom().getType())) {
+ POMInfo testPom = (POMInfo) pom.clone();
+ testPom.getThisPom().setType("test-jar");
+ getRepository().registerPom(projectPom, testPom);
+ }
+
+ knownProjectDependencies.add(pom.getThisPom());
+
+ if (interactive && packageVersion == null) {
+ System.out.println("Enter the upstream version for the package. If you press <Enter> it will default to " + pom.getOriginalVersion());
+ System.out.print("> ");
+ String v = readLine();
+ if (v.isEmpty()) {
+ v = pom.getOriginalVersion();
+ }
+ packageVersion = v;
+ }
+
+ if (pom.getOriginalVersion().equals(packageVersion)) {
+ pom.getProperties().put("debian.hasPackageVersion", "true");
+ getPOMOptions(projectPom).setHasPackageVersion(true);
+ }
+
+ if (filterModules) {
+ System.out.println("Include the module " + pomRelPath + " ?");
+ System.out.print("[y]/n > ");
+ String s = readLine().toLowerCase();
+ boolean includeModule = !s.startsWith("n");
+ if (!includeModule) {
+ getPOMOptions(projectPom).setIgnore(true);
+ String type = "*";
+ if (pom.getThisPom().getType() != null) {
+ type = pom.getThisPom().getType();
+ }
+ String rule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+ + " " + type + " *";
+ pomTransformer.getIgnoreRules().add(new DependencyRule(rule));
+ return;
+ }
+ }
+
+ projectPoms.add(pom.getThisPom());
+
+ // Previous rule from another run
+ boolean explicitlyMentionedInRules = false;
+ for (DependencyRule previousRule : pomTransformer.getRules().findMatchingRules(pom.getThisPom())) {
+ if (!previousRule.equals(DependencyRule.TO_DEBIAN_VERSION_RULE) &&
+ !previousRule.equals(DependencyRule.MAVEN_PLUGINS_KEEP_VERSION_RULE) &&
+ previousRule.matches(pom.getThisPom())) {
+ explicitlyMentionedInRules = true;
+ break;
+ }
+ }
+
+ if (interactive && !explicitlyMentionedInRules && !"maven-plugin".equals(pom.getThisPom().getType())) {
+ String version = pom.getThisPom().getVersion();
+ System.out.println("Version of " + pom.getThisPom().getGroupId() + ":"
+ + pom.getThisPom().getArtifactId() + " is " + version);
+ System.out.println("Choose how it will be transformed:");
+ List<Rule> choices = new ArrayList<Rule>();
+
+ if (versionToRules.containsKey(version)) {
+ choices.add(versionToRules.get(version));
+ }
+
+ Pattern p = Pattern.compile("(\\d+)(\\..*)");
+ Matcher matcher = p.matcher(version);
+ if (matcher.matches()) {
+ String mainVersion = matcher.group(1);
+ Rule mainVersionRule = new Rule("s/" + mainVersion + "\\..*/" +
+ mainVersion + ".x/");
+ mainVersionRule.setDescription("Replace all versions starting by "
+ + mainVersion + ". with " + mainVersion + ".x");
+ if (!choices.contains(mainVersionRule)) {
+ choices.add(mainVersionRule);
+ }
+ }
+ for (Rule rule : defaultRules) {
+ if (!choices.contains(rule)) {
+ choices.add(rule);
+ }
+ }
+
+ int count = 1;
+ for (Iterator<Rule> i = choices.iterator(); i.hasNext(); count++) {
+ Rule rule = i.next();
+ if (count == 1) {
+ System.out.print("[1]");
+ } else {
+ System.out.print(" " + count + " ");
+ }
+ System.out.println(" - " + rule.getDescription());
+ }
+ System.out.print("> ");
+ String s = readLine().toLowerCase();
+ int choice = 1;
+ try {
+ choice = Integer.parseInt(s);
+ } catch (Exception ignore) {
+ }
+
+ Rule selectedRule = choices.get(choice - 1);
+ versionToRules.put(version, selectedRule);
+ if (selectedRule.getPattern().equals("CUSTOM")) {
+ System.out.println("Enter the pattern for your custom rule (in the form s/regex/replace/)");
+ System.out.print("> ");
+ s = readLine().toLowerCase();
+ selectedRule = new Rule(s);
+ selectedRule.setDescription("My custom rule " + s);
+ defaultRules.add(selectedRule);
+ }
+
+ String dependencyRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+ + " " + pom.getThisPom().getType() + " " + selectedRule.toString();
+ pomTransformer.getRules().add(new DependencyRule(dependencyRule));
+ POMInfo transformedPom = pom.newPOMFromRules(pomTransformer.getRules().getRules(), getRepository());
+ getRepository().registerPom(projectPom, transformedPom);
+ projectPoms.add(transformedPom.getThisPom());
+
+
+ if ("bundle".equals(pom.getThisPom().getType())) {
+ System.out.println(pom.getThisPom().getGroupId() + ":" + pom.getThisPom().getArtifactId() +
+ " is a bundle.");
+ System.out.println("Inform mh_make that dependencies of type jar which may match this library should be transformed into bundles automatically?");
+ System.out.print("[y]/n > ");
+ s = readLine().toLowerCase();
+ boolean transformJarsIntoBundle = !s.startsWith("n");
+ if (transformJarsIntoBundle) {
+ String transformBundleRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+ + " s/jar/bundle/ " + selectedRule.toString();
+ pomTransformer.getPublishedRules().add(new DependencyRule(transformBundleRule));
+ }
+ }
+ }
+
+ if (pom.getParent() != null && !pom.getParent().isSuperPom()) {
+ POMInfo parentPom = getRepository().searchMatchingPOM(pom.getParent());
+ if (parentPom == null || parentPom.equals(getRepository().getSuperPOM())) {
+ getPOMOptions(projectPom).setNoParent(true);
+ }
+ if (!baseDir.equals(projectPom.getParentFile())) {
+ System.out.println("Checking the parent dependency in the sub project " + pomRelPath);
+ resolveDependency(pom.getParent(), projectPom, false, false, false, true);
+ }
+ }
+
+ resolveDependenciesLater(projectPom, POMInfo.DEPENDENCIES, false, false, false);
+ resolveDependenciesLater(projectPom, POMInfo.DEPENDENCY_MANAGEMENT_LIST, false, false, true);
+ resolveDependenciesLater(projectPom, POMInfo.PLUGINS, true, true, false);
+ resolveDependenciesLater(projectPom, POMInfo.PLUGIN_DEPENDENCIES, true, true, false);
+ resolveDependenciesLater(projectPom, POMInfo.PLUGIN_MANAGEMENT, true, true, true);
+ resolveDependenciesLater(projectPom, POMInfo.REPORTING_PLUGINS, true, true, false);
+ resolveDependenciesLater(projectPom, POMInfo.EXTENSIONS, true, true, false);
+
+ if (exploreProjects && !pom.getModules().isEmpty()) {
+ if (interactive && !askedToFilterModules) {
+ System.out.println("This project contains modules. Include all modules?");
+ System.out.print("[y]/n > ");
+ String s = readLine().toLowerCase();
+ filterModules = s.startsWith("n");
+ askedToFilterModules = true;
+ }
+ for (String module : pom.getModules()) {
+ File modulePom = new File(projectPom.getParent(), module + "/pom.xml");
+ resolveDependencies(modulePom);
+ }
+ }
+ } catch (Exception ex) {
+ log.log(Level.SEVERE, "Error while resolving " + projectPom + ": " + ex.getMessage());
+ log.log(Level.SEVERE, "", ex);
+ System.exit(1);
+ }
+ }
+
+ private POMInfo getPOM(File projectPom) throws XMLStreamException, IOException {
+ POMInfo info = pomInfoCache.get(projectPom.getAbsolutePath());
+ if (info != null) {
+ return info;
+ }
+ File tmpDest = File.createTempFile("pom", ".tmp", baseDir);
+ tmpDest.deleteOnExit();
+ ListOfPOMs.POMOptions options = getPOMOptions(projectPom);
+ boolean noParent = false;
+ boolean hasPackageVersion = false;
+ if (options != null) {
+ noParent = options.isNoParent();
+ hasPackageVersion = options.getHasPackageVersion();
+ }
+
+ info = pomTransformer.transformPom(projectPom, tmpDest, noParent, hasPackageVersion, false, false, null, null, true);
+ pomInfoCache.put(projectPom.getAbsolutePath(), info);
+ return info;
+ }
+
+ private ListOfPOMs.POMOptions getPOMOptions(File pom) {
+ return pomTransformer.getListOfPOMs().getOrCreatePOMOptions(pom);
+ }
+
+ private void resetPOM(File projectPom) {
+ pomInfoCache.remove(projectPom.getAbsolutePath());
+ }
+
+ private String readLine() {
+ LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
+ try {
+ return consoleReader.readLine().trim();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ private void resolveDependenciesNow() {
+ for (Iterator<ToResolve> i = toResolve.iterator(); i.hasNext();) {
+ ToResolve tr = i.next();
+ tr.resolve();
+ i.remove();
+ }
+ }
+
+ private void resolveDependenciesLater(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) {
+ toResolve.add(new ToResolve(sourcePom, listType, buildTime, mavenExtension, management));
+ }
+
+ private void resolveDependencies(File sourcePom, String listType, boolean buildTime, boolean mavenExtension, boolean management) throws Exception {
+ POMInfo pom = getPOM(sourcePom);
+ List<Dependency> dependenciesByType = pom.getAllDependencies(listType);
+
+ for (Dependency dependency : dependenciesByType) {
+ resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management);
+ }
+ }
+
+ public Dependency resolveDependency(Dependency dependency, File sourcePom, boolean buildTime, boolean mavenExtension, boolean management) throws DependencyNotFoundException {
+ return resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management, false);
+ }
+
+ private Dependency resolveDependency(Dependency dependency, File sourcePom, boolean buildTime, boolean mavenExtension, boolean management, boolean resolvingParent) throws DependencyNotFoundException {
+
+ if (containsDependencyIgnoreVersion(knownProjectDependencies, dependency)) {
+ return dependency;
+ }
+
+ if (containsDependencyIgnoreVersion(ignoredDependencies, dependency) ||
+ (management && isDefaultMavenPlugin(dependency))) {
+ return null;
+ }
+
+ if (resolvingParent && dependency.isSuperPom()) {
+ return dependency;
+ }
+
+ String sourcePomLoc = sourcePom.getAbsolutePath();
+ String baseDirPath = baseDir.getAbsolutePath();
+ sourcePomLoc = sourcePomLoc.substring(baseDirPath.length() + 1, sourcePomLoc.length());
+ if (verbose) {
+ String msg = "Resolving " + dependency;
+ if (dependency.getScope() != null) {
+ msg += " of scope " + dependency.getScope();
+ }
+ System.out.println(msg + "...");
+ }
+
+ // First let the packager mark as ignored those dependencies which should be ignored
+ boolean ignoreDependency = false;
+ if (!ignoreDependency && canIgnorePlugin(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin is not useful for the build or its use is against Debian policies. Ignore this plugin?");
+ }
+ if (!ignoreDependency && canIgnoreExtension(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This extension is not useful for the build or its use is against Debian policies. Ignore this extension?");
+ }
+ if (!ignoreDependency && canBeIgnoredPlugin(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin may be ignored in some cases. Ignore this plugin?");
+ }
+ if (!ignoreDependency && !runTests) {
+ if ("test".equals(dependency.getScope())) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test dependency?");
+ } else if (isTestPlugin(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Tests are turned off. Ignore this test plugin?");
+ }
+ }
+ if (!ignoreDependency && !generateJavadoc && isDocumentationOrReportPlugin(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "Documentation is turned off. Ignore this documentation plugin?");
+ }
+
+ if (ignoreDependency) {
+ ignoredDependencies.add(dependency);
+ String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
+ pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
+ if (verbose) {
+ System.out.println("[ignored]");
+ }
+ return null;
+ }
+
+ // Automatically skip some dependencies when ant packaging is used
+ boolean skipDependency = false;
+ String skipReason = "";
+ if (packageType.equals("ant")) {
+ if ("maven-plugin".equals(dependency.getType())) {
+ try {
+ if (!getPOM(sourcePom).getThisPom().getType().equals("pom")) {
+ skipDependency = true;
+ skipReason = "Maven plugins are not used during a build with Ant";
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (!runTests && "test".equals(dependency.getScope())) {
+ skipDependency = true;
+ skipReason = "Tests are not executed during the build";
+ }
+ }
+ if (skipDependency) {
+ // Even if we skip the dependency, try to locate its associated maven rules,
+ // as this may be useful later - but never fail if the dependency is not found.
+ POMInfo pom = getRepository().searchMatchingPOM(dependency);
+ if (pom != null) {
+ String mavenRules = pom.getProperties().get("debian.mavenRules");
+ if (mavenRules != null) {
+ StringTokenizer st = new StringTokenizer(mavenRules, ",");
+ while (st.hasMoreTokens()) {
+ String ruleDef = st.nextToken().trim();
+ pomTransformer.getRules().add(new DependencyRule(ruleDef));
+ }
+ }
+ }
+ if (verbose) {
+ if (!skipReason.isEmpty()) {
+ System.out.println("[skipped - " + skipReason + "]");
+ } else {
+ System.out.println("[skipped]");
+ }
+ }
+ return null;
+ }
+
+ POMInfo pom = getRepository().searchMatchingPOM(dependency);
+ try {
+ if (pom == null && dependency.getVersion() == null) {
+ POMInfo containerPom = getPOM(sourcePom);
+ String version = containerPom.getVersionFromManagementDependency(dependency);
+ dependency.setVersion(version);
+ if (version != null) {
+ pom = getRepository().searchMatchingPOM(dependency);
+ } else {
+ System.out.println("In " + sourcePomLoc + ", cannot find the version for dependency " + dependency + " from this POM or its parent POMs");
+ if (getPOMOptions(sourcePom).isNoParent()) {
+ System.out.println("[warning] Option --no-parent has been set for POM file " + sourcePomLoc + ", maybe it was not a good idea and you should first package the parent POM " + containerPom.getParent());
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (pom == null && dependency.getVersion() != null) {
+ List<POMInfo> poms = getRepository().searchMatchingPOMsIgnoreVersion(dependency);
+ for (POMInfo potentialPom : poms) {
+ String mavenRules = potentialPom.getProperties().get("debian.mavenRules");
+ if (mavenRules != null) {
+ StringTokenizer st = new StringTokenizer(mavenRules, ",");
+ while (st.hasMoreTokens()) {
+ String ruleDef = st.nextToken().trim();
+ DependencyRule rule = new DependencyRule(ruleDef);
+ if (rule.matches(dependency) && rule.apply(dependency).equals(potentialPom.getThisPom())) {
+ pom = potentialPom;
+ pomTransformer.getRules().add(rule);
+ }
+ }
+ }
+ }
+ }
+ if (pom == null && dependency.getVersion() == null) {
+ // Set a dummy version and try again
+ for (int version = 0; version < 10; version++) {
+ dependency.setVersion(version + ".0");
+ pom = getRepository().searchMatchingPOM(dependency);
+ if (pom != null) {
+ System.out.println("Use best guess version: " + dependency.getVersion() + " for "
+ + dependency.getGroupId() + ":" + dependency.getArtifactId());
+ break;
+ }
+ dependency.setVersion(null);
+ }
+ }
+
+ if (pom == null && "maven-plugin".equals(dependency.getType())) {
+ List<POMInfo> matchingPoms = getRepository().searchMatchingPOMsIgnoreVersion(dependency);
+ if (matchingPoms.size() > 1) {
+ issues.add(sourcePomLoc + ": More than one version matches the plugin " + dependency.getGroupId() + ":"
+ + dependency.getArtifactId() + ":" + dependency.getVersion());
+ }
+ if (!matchingPoms.isEmpty()) {
+ pom = matchingPoms.get(0);
+ // Don't add a rule to force the version of a Maven plugin, it's now done
+ // automatically at build time
+ }
+ }
+
+ // Ignore fast cases
+ if (pom == null) {
+ if (management) {
+ if (verbose) {
+ System.out.println("[skipped dependency or plugin management]");
+ }
+ return null;
+ } else if ("maven-plugin".equals(dependency.getType()) && packageType.equals("ant")) {
+ if (verbose) {
+ System.out.println("[skipped - not used in Ant build]");
+ }
+ return null;
+ }
+ }
+
+ // In case we didn't find anything for "jar" packaging type, just check for a "bundle" type inside repository.
+ // Some jars have been upgraded to OSGi bundles as OSGi metadata has been added to them.
+ //
+ // drazzib: I'm not sure this is really the right way to fix that (ie. maybe we should install "bundle" artifacts
+ // directly with "jar" type inside Debian ?).
+ //
+ // ludovicc: a complex issue, I believe that libraries which evolve from a jar type to a bundle type should
+ // inform packagers with a rule of the form
+ // '<groupId> <artifactId> s/jar/bundle/ <versionRule>'
+ // in other words, the packager of the library should add a published rule which will transform matching
+ // libraries from jar type into bundle types, and apply as well the version substitution (for example to 2.x)
+ // for Debian.
+ //
+ if (pom == null && "jar".equals(dependency.getType())) {
+ if (verbose) {
+ System.out.println("[check dependency with bundle type]");
+ }
+ Dependency bundleDependency = new Dependency(dependency);
+ bundleDependency.setType("bundle");
+ pom = getRepository().searchMatchingPOM(bundleDependency);
+ if (pom != null) {
+ dependency = bundleDependency;
+ for (DependencyRule rule: pom.getPublishedRules()) {
+ if (rule.matches(dependency)) {
+ Dependency transformed = rule.apply(dependency);
+ if (transformed.getGroupId().equals(dependency.getGroupId())
+ && transformed.getArtifactId().equals(dependency.getArtifactId())
+ && transformed.getType().equals(dependency.getType())) {
+ String newRule = pom.getThisPom().getGroupId() + " " + pom.getThisPom().getArtifactId()
+ + " s/jar/bundle/ " + rule.getVersionRule().toString();
+ pomTransformer.getRules().add(new DependencyRule(newRule));
+ }
+ }
+ }
+ }
+ }
+
+ if (pom == null) {
+ if (!ignoreDependency) {
+ if (resolvingParent) {
+ boolean noParent = askIgnoreDependency(sourcePomLoc, dependency,
+ "The parent POM cannot be found in the Maven repository for Debian. Ignore it?");
+ getPOMOptions(sourcePom).setNoParent(noParent);
+ if (noParent) {
+ if (verbose) {
+ System.out.println("[no-parent]");
+ }
+ return null;
+ }
+ } else if (isDocumentationOrReportPlugin(dependency)) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency,
+ "This documentation or report plugin cannot be found in the Maven repository for Debian. Ignore this plugin?");
+ } else if ("maven-plugin".equals(dependency.getType())) {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This plugin cannot be found in the Debian Maven repository. Ignore this plugin?", false);
+ if (!ignoreDependency) {
+ issues.add(sourcePomLoc + ": Plugin is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
+ + dependency.getArtifactId() + ":" + dependency.getVersion());
+ }
+ } else {
+ ignoreDependency = askIgnoreDependency(sourcePomLoc, dependency, "This dependency cannot be found in the Debian Maven repository. Ignore this dependency?", false);
+ if (!ignoreDependency) {
+ issues.add(sourcePomLoc + ": Dependency is not packaged in the Maven repository for Debian: " + dependency.getGroupId() + ":"
+ + dependency.getArtifactId() + ":" + dependency.getVersion());
+ }
+ }
+ }
+ if (ignoreDependency) {
+ ignoredDependencies.add(dependency);
+ String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " * *";
+ pomTransformer.getIgnoreRules().add(new DependencyRule(ruleDef));
+ if (verbose) {
+ System.out.println("[ignored]");
+ }
+ return null;
+ } else {
+ String pkg = searchPkg(new File("/usr/share/maven-repo/"
+ + dependency.getGroupId().replace('.', '/')
+ + "/" + dependency.getArtifactId()), ".pom");
+ if (pkg != null) {
+ String installedVersion = getPackageVersion(pkg, true);
+ if (installedVersion != null) {
+ System.out.println("[error] Package " + pkg + " (" + installedVersion + ") is already installed and contains a possible match," );
+ System.out.println("but I cannot resolve library " + dependency + " in it.");
+ System.out.println("[error] Please check manually that the library is up to date, otherwise it may be necessary to package version "
+ + dependency.getVersion() + " in Debian.");
+ } else {
+ System.out.println("[warning] Please install the missing dependency. Run the following command in another terminal:");
+ System.out.println(" sudo apt-get install " + pkg);
+ }
+ }
+ if (interactive && pkg == null) {
+ pkg = searchPkg(new File("/usr/share/java/" + dependency.getArtifactId() + ".jar"));
+ if (pkg != null) {
+ System.out.println("[error] Package " + pkg + " does not contain Maven dependency " + dependency + " but there seem to be a match");
+ System.out.println("If the package contains already Maven artifacts but the names don't match, try to enter a substitution rule");
+ System.out.println("of the form s/groupId/newGroupId/ s/artifactId/newArtifactId/ jar s/version/newVersion/ here:");
+ System.out.print("> ");
+ String newRule = readLine().trim();
+ if (!newRule.isEmpty()) {
+ DependencyRule userRule = new DependencyRule(newRule);
+ pomTransformer.getRules().add(userRule);
+ System.out.println("Please suggest the maintainer of package " + pkg + " to add this rule to debian/maven.publishedRules");
+ return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
+ }
+ } else {
+ System.out.println("[error] Cannot resolve Maven dependency " + dependency + ". If you know a package that contains a compatible dependency,");
+ System.out.println("Try to enter a substitution rule of the form s/groupId/newGroupId/ s/artifactId/newArtifactId/ jar s/version/newVersion/ here:");
+ System.out.print("> ");
+ String newRule = readLine().trim();
+ if (!newRule.isEmpty()) {
+ DependencyRule userRule = new DependencyRule(newRule);
+ pomTransformer.getRules().add(userRule);
+ return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
+ }
+ }
+ }
+ if (interactive) {
+ System.out.println("Try again to resolve the dependency?");
+ System.out.print("[y]/n > ");
+ String s = readLine().trim().toLowerCase();
+ if (!s.startsWith("n")) {
+ System.out.println("Rescanning /usr/share/maven-repo...");
+ pomTransformer.getRepository().scan();
+ // Clear caches
+ filesInPackages.clear();
+ return resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management);
+ }
+ }
+ if (verbose) {
+ System.out.println("[error]");
+ }
+ throw new DependencyNotFoundException(dependency);
+ }
+ }
+
+ // Handle the case of Maven plugins built and used in a multi-module build:
+ // they need to be added to maven.cleanIgnoreRules to avoid errors during
+ // a mvn clean
+ if ("maven-plugin".equals(dependency.getType()) && containsDependencyIgnoreVersion(projectPoms, dependency)) {
+ String ruleDef = dependency.getGroupId() + " " + dependency.getArtifactId() + " maven-plugin *";
+ cleanIgnoreRules.add(new DependencyRule(ruleDef));
+ }
+
+ // Discover the library to import for the dependency
+ String pkg = getPackage(pom, sourcePomLoc);
+
+ if (pkg != null && !pkg.equals(getPackageName())) {
+ String libraryWithVersionConstraint = pkg;
+ String version = dependency.getVersion();
+ if (version == null || (pom.getOriginalVersion() != null && version.compareTo(pom.getOriginalVersion()) > 0)) {
+ version = pom.getOriginalVersion();
+ }
+ if (pom.getOriginalVersion() != null && (pom.getProperties().containsKey("debian.hasPackageVersion"))) {
+ libraryWithVersionConstraint += " (>= " + version + ")";
+ }
+ if (!management) {
+ if (buildTime) {
+ if ("test".equals(dependency.getScope())) {
+ testDepends.add(libraryWithVersionConstraint);
+ } else if ("maven-plugin".equals(dependency.getType())) {
+ if (!packageType.equals("ant")) {
+ compileDepends.add(libraryWithVersionConstraint);
+ }
+ } else if (mavenExtension) {
+ if (!packageType.equals("ant")) {
+ compileDepends.add(libraryWithVersionConstraint);
+ }
+ } else {
+ compileDepends.add(libraryWithVersionConstraint);
+ }
+ } else {
+ if (dependency.isOptional()) {
+ optionalDepends.add(libraryWithVersionConstraint);
+ } else if ("test".equals(dependency.getScope())) {
+ testDepends.add(libraryWithVersionConstraint);
+ } else {
+ runtimeDepends.add(libraryWithVersionConstraint);
+ }
+ }
+ }
+ versionedPackagesAndDependencies.put(libraryWithVersionConstraint, dependency);
+ }
+
+ String mavenRules = pom.getProperties().get("debian.mavenRules");
+ if (mavenRules != null) {
+ StringTokenizer st = new StringTokenizer(mavenRules, ",");
+ while (st.hasMoreTokens()) {
+ String ruleDef = st.nextToken().trim();
+ pomTransformer.getRules().add(new DependencyRule(ruleDef));
+ }
+ }
+ if (verbose) {
+ System.out.println("Dependency " + dependency + " found in package " + pkg);
+ System.out.println("[ok]");
+ System.out.println();
+ }
+
+ if (resolvingParent) {
+ try {
+ POMInfo containerPom = getPOM(sourcePom);
+ containerPom.setParentPOM(pom);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return pom.getThisPom();
+ }
+
+ private String getPackage(POMInfo pom, String sourcePomLoc) {
+ String pkg = null;
+ if (pom.getProperties() != null) {
+ pkg = pom.getProperties().get("debian.package");
+ }
+ if (pkg == null) {
+ Dependency dependency = pom.getThisPom();
+ issues.add(sourcePomLoc + ": Dependency is missing the Debian properties in its POM: " + dependency.getGroupId() + ":"
+ + dependency.getArtifactId() + ":" + dependency.getVersion());
+ File pomFile = new File(mavenRepo, dependency.getGroupId().replace(".", "/") + "/" + dependency.getArtifactId() + "/" + dependency.getVersion() + "/" + dependency.getArtifactId() + "-" + dependency.getVersion() + ".pom");
+ pkg = searchPkg(pomFile);
+ }
+ return pkg;
+ }
+
+ private String getPackageVersion(String pkg, boolean onlyInstalled) {
+ GetPackageVersionResult packageResult = new GetPackageVersionResult();
+ executeProcess(new String[]{"dpkg", "--status", pkg}, packageResult);
+ if (packageResult.getResult() != null) {
+ return packageResult.getResult();
+ }
+ if (!onlyInstalled) {
+ GetChangelogVersionResult versionResult = new GetChangelogVersionResult(pkg);
+ executeProcess(new String[]{"apt-get", "--no-act", "--verbose-versions", "install", pkg}, versionResult);
+ if (versionResult.getResult() != null) {
+ return versionResult.getResult();
+ }
+ }
+ return null;
+ }
+
+ private boolean containsDependencyIgnoreVersion(Collection<Dependency> dependencies, Dependency dependency) {
+ for (Dependency ignoredDependency : dependencies) {
+ if (ignoredDependency.equalsIgnoreVersion(dependency)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String searchPkg(File dir, String extension) {
+ GetFilteredPackageResult packageResult = new GetFilteredPackageResult(extension);
+ File cacheId = new File(dir, "_" + extension);
+ return searchPkg(cacheId, dir, packageResult);
+ }
+
+ private String searchPkg(File file) {
+ GetPackageResult packageResult = new GetPackageResult();
+ return searchPkg(file, file, packageResult);
+ }
+
+ private String searchPkg(File cacheId, File fileToSearch, GetPackageResult packageResult) {
+ if (filesInPackages.containsKey(cacheId)) {
+ return filesInPackages.get(cacheId);
+ }
+
+ executeProcess(new String[]{"dpkg", "--search", fileToSearch.getAbsolutePath()}, packageResult);
+ if (packageResult.getResult() != null) {
+ String pkg = packageResult.getResult();
+ if (pkg != null) {
+ filesInPackages.put(cacheId, pkg);
+ }
+ return pkg;
+ }
+
+ // Debian policy prevents the use of apt-file during a build
+ if (offline) {
+ return null;
+ }
+
+ if (!new File("/usr/bin/apt-file").exists()) {
+ return null;
+ }
+ executeProcess(new String[]{"apt-file", "search", fileToSearch.getAbsolutePath()}, packageResult);
+ String pkg = packageResult.getResult();
+ if (pkg != null) {
+ filesInPackages.put(cacheId, pkg);
+ }
+ return pkg;
+ }
+
+ public static void executeProcess(final String[] cmd, final OutputHandler handler) {
+ try {
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.redirectErrorStream(true);
+ System.out.print("> ");
+ for (String arg : cmd) {
+ System.out.print(arg + " ");
+ }
+ System.out.println();
+ final Process process = pb.start();
+ try {
+ ThreadFactory threadFactory = new ThreadFactory() {
+
+ public Thread newThread(Runnable r) {
+ Thread t = new Thread(r, "Run command " + cmd[0]);
+ t.setDaemon(true);
+ return t;
+ }
+ };
+
+ ExecutorService executor = Executors.newSingleThreadExecutor(threadFactory);
+ executor.execute(new Runnable() {
+
+ public void run() {
+ try {
+ InputStreamReader isr = new InputStreamReader(process.getInputStream());
+ BufferedReader br = new BufferedReader(isr);
+ LineNumberReader aptIn = new LineNumberReader(br);
+ String line;
+ while ((line = aptIn.readLine()) != null) {
+ handler.newLine(line);
+ }
+ aptIn.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ });
+
+ process.waitFor();
+ executor.awaitTermination(5, TimeUnit.SECONDS);
+ if (process.exitValue() == 0) {
+ } else {
+ System.out.println(cmd[0] + " failed to execute successfully");
+ }
+ process.destroy();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ Thread.interrupted();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private String toString(Set<String> s) {
+ StringBuffer sb = new StringBuffer();
+ for (Iterator<String> i = s.iterator(); i.hasNext();) {
+ String st = i.next();
+ sb.append(st);
+ if (i.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ return sb.toString();
+ }
+
+ public static interface OutputHandler {
+
+ void newLine(String line);
+ }
+
+ public static class NoOutputHandler implements OutputHandler {
+
+ public void newLine(String line) {
+ }
+ }
+
+ static class GetPackageResult implements OutputHandler {
+
+ private String result;
+
+ public void newLine(String line) {
+ if (result != null) {
+ return;
+ }
+ int colon = line.indexOf(':');
+ if (colon > 0 && line.indexOf(' ') > colon) {
+ result = line.substring(0, colon);
+ // Ignore lines such as 'dpkg : xxx'
+ if (!result.equals(result.trim()) || result.startsWith("dpkg")) {
+ result = null;
+ } else {
+ result = foundResult(result);
+ }
+ }
+ }
+
+ protected String foundResult(String potentialMatch) {
+ System.out.println("Found " + potentialMatch);
+ return potentialMatch;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ }
+
+ static class GetFilteredPackageResult extends GetPackageResult {
+ private final String extension;
+
+ public GetFilteredPackageResult(String extension) {
+ this.extension = extension;
+ }
+
+ protected String foundResult(String potentialMatch) {
+ if (potentialMatch.endsWith(extension)) {
+ System.out.println("Found " + potentialMatch);
+ return potentialMatch;
+ } else {
+ return null;
+ }
+ }
+
+ }
+
+ static class GetPackageVersionResult implements OutputHandler {
+
+ private String result;
+
+ public void newLine(String line) {
+ if (result != null) {
+ return;
+ }
+ if (line.startsWith("Version:")) {
+ int space = line.indexOf(' ');
+ result = line.substring(space + 1, line.length()).trim();
+ }
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ }
+
+ static class GetChangelogVersionResult implements OutputHandler {
+
+ private String result;
+ private final Pattern pattern;
+
+ public GetChangelogVersionResult(String pkg) {
+ this.pattern = Pattern.compile(pkg + "\\s\\(.*\\)");
+ }
+
+ public void newLine(String line) {
+ if (result != null) {
+ return;
+ }
+ Matcher match = pattern.matcher(line);
+ if (match.find()) {
+ result = match.group(1);
+ }
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ }
+
+ public static void main(String[] args) {
+ if (args.length == 0 || "-h".equals(args[0]) || "--help".equals(args[0])) {
+ System.out.println("Purpose: Solve the dependencies in the POM(s).");
+ System.out.println("Usage: [option]");
+ System.out.println("");
+ System.out.println("Options:");
+ System.out.println(" -v, --verbose: be extra verbose");
+ System.out.println(" -p<package>, --package=<package>: name of the Debian package containing");
+ System.out.println(" this library");
+// System.out.println(" -r<rules>, --rules=<rules>: path to the file containing the");
+// System.out.println(" extra rules to apply when cleaning the POM");
+// System.out.println(" -i<rules>, --published-rules=<rules>: path to the file containing the");
+// System.out.println(" extra rules to publish in the property debian.mavenRules in the cleaned POM");
+ System.out.println(" --ant: use ant for the packaging");
+ System.out.println(" --run-tests: run the unit tests");
+ System.out.println(" --generate-javadoc: generate Javadoc");
+ System.out.println(" --non-interactive: non interactive session");
+ System.out.println(" --offline: offline mode for Debian build compatibility");
+ System.out.println(" -m<repo root>--maven-repo=<repo root>: location of the Maven repository,");
+ System.out.println(" used to force the versions of the Maven plugins used in the current");
+ System.out.println(" POM file with the versions found in the repository");
+ System.out.println(" --base-directory: path to root directory of package");
+ System.out.println(" --non-explore: doesn't explore directories for pom.xml");
+ return;
+ }
+
+ // Default values
+ boolean verbose = false;
+ String debianPackage = "";
+ String packageType = "maven";
+ File mavenRepo = null;
+ File baseDirectory = new File(".");
+
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setExploreProjects(true); // can be overriden by args
+
+ // Parse parameters
+ int i = inc(-1, args);
+ while (i < args.length && (args[i].trim().startsWith("-") || args[i].trim().isEmpty())) {
+ String arg = args[i].trim();
+ if ("--verbose".equals(arg) || "-v".equals(arg)) {
+ verbose = true;
+ } else if ("--debug".equals(arg)) {
+ log.setLevel(Level.FINEST);
+ } else if (arg.startsWith("-p")) {
+ debianPackage = arg.substring(2);
+ } else if (arg.startsWith("--package=")) {
+ debianPackage = arg.substring("--package=".length());
+ } else if (arg.equals("--ant")) {
+ packageType = "ant";
+ } else if (arg.equals("--run-tests")) {
+ solver.setRunTests(true);
+ } else if (arg.equals("--generate-javadoc")) {
+ solver.setGenerateJavadoc(true);
+ } else if (arg.equals("--non-interactive")) {
+ solver.setInteractive(false);
+ } else if (arg.equals("--offline")) {
+ solver.setOffline(true);
+ } else if (arg.startsWith("-m")) {
+ mavenRepo = new File(arg.substring(2));
+ } else if (arg.startsWith("--maven-repo=")) {
+ mavenRepo = new File(arg.substring("--maven-repo=".length()));
+ } else if (arg.startsWith("-b")) {
+ baseDirectory = new File(arg.substring(2));
+ } else if (arg.startsWith("--base-directory=")) {
+ baseDirectory = new File(arg.substring("--base-directory=".length()));
+ } else if (arg.equals("--non-explore")) {
+ solver.setExploreProjects(false);
+ }
+ i = inc(i, args);
+ }
+
+ solver.setBaseDir(baseDirectory);
+ solver.setOutputDirectory(new File(baseDirectory, "debian"));
+ solver.setPackageName(debianPackage);
+ solver.setPackageType(packageType);
+ File poms = new File(solver.getOutputDirectory(), debianPackage + ".poms");
+ solver.setListOfPoms(poms);
+
+ if (mavenRepo != null) {
+ Repository repository = new Repository(mavenRepo);
+ solver.getPomTransformer().setRepository(repository);
+ solver.getPomTransformer().usePluginVersionsFromRepository();
+ }
+
+ if (verbose) {
+ String msg = "Solving dependencies for package " + debianPackage;
+ if (solver.isRunTests()) {
+ msg += " (tests are included)";
+ }
+ if (solver.isGenerateJavadoc()) {
+ msg += " (documentation is included)";
+ }
+ System.out.println(msg);
+ solver.setVerbose(true);
+ }
+
+ solver.solveDependencies();
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveMavenIgnoreRules();
+ solver.saveMavenCleanIgnoreRules();
+ solver.saveMavenPublishedRules();
+ solver.saveSubstvars();
+
+ if (!solver.getIssues().isEmpty()) {
+ System.exit(1);
+ }
+ }
+
+ private static int inc(int i, String[] args) {
+ do {
+ i++;
+ } while (i < args.length && args[i].isEmpty());
+ return i;
+ }
+}
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,755 +0,0 @@
-package org.debian.maven.packager;
-
-/*
- * Copyright 2009 Ludovic Claude.
- *
- * 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.
- */
-
-import org.apache.maven.model.Developer;
-import org.apache.maven.model.License;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.debian.maven.repo.ListOfPOMs;
-
-/**
- * Generate the Debian files for packaging the current Maven project.
- *
- * @goal generate
- * @aggregator
- * @requiresDependencyResolution
- * @phase process-sources
- *
- * @author Ludovic Claude
- */
-public class GenerateDebianFilesMojo
- extends AbstractMojo {
-
- /**
- * The Maven Project Object
- *
- * @parameter expression="${project}"
- * @readonly
- * @required
- */
- protected MavenProject project;
- /**
- * A list of every project in this reactor; provided by Maven
- * @parameter expression="${project.collectedProjects}"
- */
- protected List collectedProjects;
- /**
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- */
- protected ArtifactRepository localRepository;
- /**
- * Location of the file.
- * @parameter expression="${debian.directory}"
- * default-value="debian"
- */
- protected File outputDirectory;
- /**
- * Name of the packager (e.g. 'Ludovic Claude')
- * @parameter expression="${packager}"
- * @required
- */
- protected String packager;
- /**
- * Email of the packager (e.g. 'ludovic.claude at laposte.net')
- * @parameter expression="${email}"
- * @required
- */
- protected String email;
- /**
- * License used by the packager (e.g. 'GPL-3' or 'Apache-2.0')
- * See http://dep.debian.net/deps/dep5/ for the list of licenses.
- * @parameter expression="${packagerLicense}" default-value="GPL-3"
- * @required
- */
- protected String packagerLicense;
- /**
- * Name of the source package (e.g. 'commons-lang')
- * @parameter expression="${package}"
- * @required
- */
- protected String packageName;
- /**
- * Name of the binary package (e.g. 'libcommons-lang-java')
- * @parameter expression="${bin.package}"
- * @required
- */
- protected String binPackageName;
- /**
- * Type of the package (e.g. 'maven' or 'ant')
- * @parameter expression="${packageType}" default-value="maven"
- */
- protected String packageType;
- /**
- * URL for downloading the source code, in the form scm:[svn|cvs]:http://xxx/
- * for downloads using a source code repository,
- * or http://xxx.[tar|zip|gz|tgz] for downloads using source tarballs.
- * @parameter expression="${downloadUrl}"
- */
- protected String downloadUrl;
- /**
- * If true, include running the tests during the build.
- * @parameter expression="${runTests}" default-value="false"
- */
- protected boolean runTests;
- /**
- * If true, generate the Javadoc packaged in a separate package.
- * @parameter expression="${generateJavadoc}" default-value="false"
- */
- protected boolean generateJavadoc;
-
- public void execute()
- throws MojoExecutionException {
- File f = outputDirectory;
- if (!f.exists()) {
- f.mkdirs();
- }
-
- String controlTemplate = "control.vm";
- String rulesTemplate = "rules.vm";
- if ("ant".equals(packageType)) {
- controlTemplate = "control.ant.vm";
- rulesTemplate = "rules.ant.vm";
- }
- // #638788: clean up email
- if (email != null && email.indexOf('<') >= 0 && email.indexOf('>') >= 0) {
- email = email.substring(email.indexOf('<') + 1, email.indexOf('>') - 1);
- }
-
- try {
- Properties velocityProperties = new Properties();
- velocityProperties.put("resource.loader", "class");
- velocityProperties.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
- Velocity.init(velocityProperties);
- VelocityContext context = new VelocityContext();
- context.put("package", packageName);
- context.put("packageType", packageType);
- context.put("binPackage", binPackageName);
- context.put("packager", packager);
- context.put("packagerEmail", email);
- context.put("project", project);
- context.put("collectedProjects", wrapMavenProjects(collectedProjects));
- context.put("runTests", Boolean.valueOf(runTests));
- context.put("generateJavadoc", Boolean.valueOf(generateJavadoc));
-
- if (project.getName() == null || project.getName().isEmpty()) {
- System.out.println("POM does not contain the project name. Please enter the name of the project:");
- project.setName(readLine());
- }
- if (project.getUrl() == null || project.getUrl().isEmpty()) {
- System.out.println("POM does not contain the project URL. Please enter the URL of the project:");
- project.setUrl(readLine());
- }
-
- Set licenses = discoverLicenses();
- context.put("licenses", licenses);
-
- if (licenses.size() == 1) {
- packagerLicense = (String) licenses.iterator().next();
- }
- if (packagerLicense == null) {
- System.out.println("Packager license for the debian/ filse was not found, please enter a license name preferably in one of:");
- System.out.println("Apache Artistic BSD FreeBSD ISC CC-BY CC-BY-SA CC-BY-ND CC-BY-NC CC-BY-NC-SA CC-BY-NC-ND CC0 CDDL CPL Eiffel");
- System.out.println("Expat GPL LGPL GFDL GFDL-NIV LPPL MPL Perl PSF QPL W3C-Software ZLIB Zope");
- String s = readLine();
- if (s.length() > 0) {
- packagerLicense = s;
- }
- }
- context.put("packagerLicense", packagerLicense);
-
- String copyrightOwner = "";
- String projectTeam = "";
- if (project.getOrganization() != null) {
- copyrightOwner = project.getOrganization().getName();
- projectTeam = project.getOrganization().getName() + " developers";
- }
- if (copyrightOwner == null || copyrightOwner.isEmpty()) {
- Iterator devs = project.getDevelopers().iterator();
- if (devs.hasNext()) {
- Developer dev = (Developer) devs.next();
- copyrightOwner = dev.getName();
- if (dev.getEmail() != null && !dev.getEmail().isEmpty()) {
- copyrightOwner += " <" + dev.getEmail() + ">";
- }
- }
- }
- if (copyrightOwner == null || copyrightOwner.isEmpty()) {
- System.out.println("Could not find who owns the copyright for the upstream sources, please enter his name:");
- copyrightOwner = readLine();
- }
- context.put("copyrightOwner", copyrightOwner);
-
- if (projectTeam == null || projectTeam.isEmpty()) {
- projectTeam = project.getName() + " developers";
- }
- context.put("projectTeam", projectTeam);
-
- String copyrightYear;
- int currentYear = new GregorianCalendar().get(Calendar.YEAR);
- if (project.getInceptionYear() != null) {
- copyrightYear = project.getInceptionYear();
- if (Integer.parseInt(copyrightYear) < currentYear) {
- copyrightYear += "-" + currentYear;
- }
- } else {
- copyrightYear = String.valueOf(currentYear);
- }
- context.put("copyrightYear", copyrightYear);
- context.put("currentYear", new Integer(currentYear));
-
- List description = new ArrayList();
- if (project.getDescription() == null || project.getDescription().trim().isEmpty()) {
- System.out.println("Please enter a short description of the project, press Enter twice to stop.");
- StringBuffer sb = new StringBuffer();
- int emptyEnterCount = 0;
- while (emptyEnterCount < 2) {
- String s = readLine();
- if (s.isEmpty()) {
- emptyEnterCount++;
- } else {
- if (emptyEnterCount > 0) {
- emptyEnterCount = 0;
- sb.append("\n");
- }
- sb.append(s);
- sb.append("\n");
- }
- }
- project.setDescription(sb.toString());
- }
- if (project.getDescription() != null) {
- StringTokenizer st = new StringTokenizer(project.getDescription().trim(), "\n\t ");
- StringBuffer descLine = new StringBuffer();
- while (st.hasMoreTokens()) {
- descLine.append(st.nextToken());
- descLine.append(" ");
- if (descLine.length() > 70 || !st.hasMoreTokens()) {
- String line = descLine.toString().trim();
- if (line.isEmpty()) {
- line = ".";
- }
- description.add(line);
- descLine = new StringBuffer();
- }
- }
- }
- context.put("description", description);
-
- File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
- if (substvarsFile.exists()) {
- Properties substvars = new Properties();
- substvars.load(new FileReader(substvarsFile));
- List depends = new ArrayList();
- depends.addAll(split(substvars.getProperty("maven.CompileDepends")));
- depends.addAll(split(substvars.getProperty("maven.Depends")));
- if (runTests) {
- depends.addAll(split(substvars.getProperty("maven.TestDepends")));
- }
- if (generateJavadoc) {
- depends.addAll(split(substvars.getProperty("maven.DocDepends")));
- depends.addAll(split(substvars.getProperty("maven.DocOptionalDepends")));
- }
- if ("maven".equals(packageType)) {
- boolean seenJavadocPlugin = false;
- // Remove dependencies that are implied by maven-debian-helper
- for (Iterator i = depends.iterator(); i.hasNext();) {
- String dependency = (String) i.next();
- if (dependency.startsWith("libmaven-clean-plugin-java") ||
- dependency.startsWith("libmaven-resources-plugin-java") ||
- dependency.startsWith("libmaven-compiler-plugin-java") ||
- dependency.startsWith("libmaven-jar-plugin-java") ||
- dependency.startsWith("libmaven-site-plugin-java") ||
- dependency.startsWith("libsurefire-java") ||
- dependency.startsWith("velocity") ||
- dependency.startsWith("libplexus-velocity-java")) {
- i.remove();
- } else if (dependency.startsWith("libmaven-javadoc-plugin-java")) {
- seenJavadocPlugin = true;
- }
- }
- if (generateJavadoc && !seenJavadocPlugin) {
- depends.add("libmaven-javadoc-plugin-java");
- }
- } else if ("ant".equals(packageType)) {
- // Remove dependencies that are implied by ant packaging
- for (Iterator i = depends.iterator(); i.hasNext(); ) {
- String dependency = (String) i.next();
- if (dependency.equals("ant") ||
- dependency.startsWith("ant ") ||
- dependency.startsWith("ant-optional")) {
- i.remove();
- }
- }
- depends.remove("ant");
- depends.remove("ant-optional");
- }
- context.put("compileDependencies", depends);
- context.put("runtimeDependencies", split(substvars.getProperty("maven.Depends")));
- context.put("optionalDependencies", split(substvars.getProperty("maven.OptionalDepends")));
- context.put("javadocDependencies", split(substvars.getProperty("maven.DocDepends")));
- context.put("javadocOptionalDependencies", split(substvars.getProperty("maven.DocOptionalDepends")));
-
- if ("ant".equals(packageType)) {
- Set buildJars = new TreeSet();
- for (Iterator i = depends.iterator(); i.hasNext();) {
- String library = (String) i.next();
- buildJars.addAll(listSharedJars(library));
- }
- buildJars.add("ant-junit");
- context.put("buildJars", buildJars);
- }
- } else {
- System.err.println("Cannot find file " + substvarsFile);
- }
-
- if ("ant".equals(packageType)) {
- ListOfPOMs listOfPOMs = new ListOfPOMs(new File(outputDirectory, binPackageName + ".poms"));
- ListOfPOMs listOfJavadocPOMs = null;
- if (generateJavadoc && "ant".equals(packageType)) {
- listOfJavadocPOMs = new ListOfPOMs(new File(outputDirectory, binPackageName + "-doc.poms"));
- }
- setupArtifactLocation(listOfPOMs, listOfJavadocPOMs, project);
- for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
- MavenProject mavenProject = (MavenProject) i.next();
- setupArtifactLocation(listOfPOMs, listOfJavadocPOMs, mavenProject);
- }
- listOfPOMs.save();
- if (listOfJavadocPOMs != null) {
- listOfJavadocPOMs.save();
- }
- }
-
- String projectVersion = project.getVersion();
- int downloadType = DownloadType.UNKNOWN;
-
- if (downloadUrl == null) {
- if (project.getScm() != null) {
- downloadUrl = project.getScm().getConnection();
- }
- }
- if (downloadUrl != null && downloadUrl.startsWith("scm:svn:")) {
- downloadType = DownloadType.SVN;
- downloadUrl = downloadUrl.substring("scm:svn:".length());
- String tag = projectVersion;
- int tagPos = downloadUrl.indexOf(tag);
- String baseUrl = null;
- String suffixUrl = null;
- String tagMarker = null;
- if (tagPos >= 0) {
- baseUrl = downloadUrl.substring(0, tagPos);
- suffixUrl = downloadUrl.substring(tagPos + tag.length());
- if (!suffixUrl.endsWith("/")) {
- suffixUrl += "/";
- }
- int slashPos = baseUrl.lastIndexOf("/");
- tagMarker = baseUrl.substring(slashPos + 1);
- baseUrl = baseUrl.substring(0, slashPos);
- }
- if (tagPos < 0 && downloadUrl.indexOf("/trunk") >= 0) {
- System.out.println("Download URL does not include a tagged revision but /trunk found,");
- System.out.println("Trying to guess the address of the tagged revision.");
- tag = "trunk";
- tagPos = downloadUrl.indexOf(tag);
- baseUrl = downloadUrl.substring(0, tagPos);
- baseUrl += "tags";
- tagMarker = packageName + "-";
- suffixUrl = "";
- }
- if (tagPos >= 0) {
- context.put("baseUrl", baseUrl);
- context.put("tagMarker", tagMarker);
- context.put("suffixUrl", suffixUrl);
-
- generateFile(context, "watch.svn.vm", outputDirectory, "watch");
- generateFile(context, "orig-tar.svn.vm", outputDirectory, "orig-tar.sh");
-
- makeExecutable("debian/orig-tar.sh");
-
- } else {
- System.err.println("Cannot locate the version in the download url (" +
- downloadUrl + ").");
- System.err.println("Please run again and provide the download location with an explicit version tag, e.g.");
- System.err.println("-DdownloadUrl=scm:svn:http://svn.codehaus.org/modello/tags/modello-1.0-alpha-21/");
- }
- }
-
- if (downloadType == DownloadType.UNKNOWN) {
- System.err.println("Cannot recognize the download url (" +
- downloadUrl + ").");
- }
-
- generateFile(context, "README.source.vm", outputDirectory, "README.source");
- generateFile(context, "copyright.vm", outputDirectory, "copyright");
- generateFile(context, "compat.vm", outputDirectory, "compat");
- generateFile(context, rulesTemplate, outputDirectory, "rules");
-
- makeExecutable("debian/rules");
-
- String debianVersion = projectVersion.replace("-alpha-", "~alpha");
- debianVersion = debianVersion.replace("-beta-", "~beta");
- debianVersion += "-1";
- context.put("version.vm", debianVersion);
-
- generateFile(context, rulesTemplate, new File("."), ".debianVersion");
-
- if (generateJavadoc) {
- generateFile(context, "java-doc.doc-base.api.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
- generateFile(context, "java-doc.install.vm", outputDirectory, binPackageName + "-doc.install");
- }
-
- if ("ant".equals(packageType)) {
- boolean containsJars = false;
- boolean containsPlugins = false;
- if (project.getPackaging().equals("pom") && project.getModules().size() > 0) {
- for (Iterator i = collectedProjects.iterator(); i.hasNext(); ) {
- MavenProject module = (MavenProject) i.next();
- if (module.getPackaging().equals("maven-plugin")) {
- containsPlugins = true;
- } else if (!module.getPackaging().equals("pom")) {
- containsJars = true;
- }
- }
- } else if (!project.getPackaging().equals("pom")) {
- if (project.getPackaging().equals("maven-plugin")) {
- containsPlugins = true;
- } else if (!project.getPackaging().equals("pom")) {
- containsJars = true;
- }
- }
- context.put("containsJars", Boolean.valueOf(containsJars));
- context.put("containsPlugins", Boolean.valueOf(containsPlugins));
-
- if (project.getPackaging().equals("pom") && project.getModules().size() > 0) {
- generateFile(context, "build.xml.vm", outputDirectory, "build.xml");
- }
- generateFile(context, "build.properties.ant.vm", outputDirectory, "build.properties");
- generateFile(context, "build-classpath.vm", outputDirectory, "build-classpath");
- } else {
- generateFile(context, "maven.properties.vm", outputDirectory, "maven.properties");
- }
-
- generateFile(context, controlTemplate, outputDirectory, "control");
- generateFile(context, "format.vm", new File(outputDirectory, "source"), "format");
-
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- private List wrapMavenProjects(List<MavenProject> projects) {
- List<WrappedProject> wrappedProjects = new ArrayList<WrappedProject>();
- for (MavenProject aProject: projects) {
- wrappedProjects.add(new WrappedProject(this.project, aProject));
- }
- return wrappedProjects;
- }
-
- private void setupArtifactLocation(ListOfPOMs listOfPOMs, ListOfPOMs listOfJavadocPOMs, MavenProject mavenProject) {
- String dirRelPath = new WrappedProject(project, mavenProject).getBaseDir();
-
- if (! "pom".equals(mavenProject.getPackaging())) {
- String pomFile = dirRelPath + "pom.xml";
- listOfPOMs.getOrCreatePOMOptions(pomFile).setJavaLib(true);
- String extension = mavenProject.getPackaging();
- if (extension.equals("bundle")) {
- extension = "jar";
- }
- if (extension.equals("webapp")) {
- extension = "war";
- }
- if (mavenProject.getArtifact() != null && mavenProject.getArtifact().getFile() != null) {
- extension = mavenProject.getArtifact().getFile().toString();
- extension = extension.substring(extension.lastIndexOf('.') + 1);
- }
- ListOfPOMs.POMOptions pomOptions = listOfPOMs.getOrCreatePOMOptions(pomFile);
- pomOptions.setArtifact(dirRelPath + "target/" + mavenProject.getArtifactId() + "-*."
- + extension);
- if ("jar".equals(extension) && generateJavadoc && "ant".equals(packageType) && listOfJavadocPOMs != null) {
- String artifactId = mavenProject.getArtifact().getArtifactId();
- String docPom = dirRelPath + "target/" + artifactId + ".javadoc.pom";
- ListOfPOMs.POMOptions javadocPomOptions = listOfJavadocPOMs.getOrCreatePOMOptions(docPom);
- javadocPomOptions.setIgnorePOM(true);
- javadocPomOptions.setArtifact(dirRelPath + "target/" + artifactId + ".javadoc.jar");
- javadocPomOptions.setClassifier("javadoc");
- javadocPomOptions.setHasPackageVersion(pomOptions.getHasPackageVersion());
- }
- pomOptions.setJavaLib(true);
- if (mavenProject.getArtifactId().matches(packageName + "\\d")) {
- pomOptions.setUsjName(packageName);
- }
- }
- }
-
- private Set discoverLicenses() {
- Set licenses = new TreeSet();
- for (Iterator i = project.getLicenses().iterator(); i.hasNext(); ) {
- License license = (License) i.next();
- String licenseName = "";
- if (license.getName() != null) {
- licenseName = license.getName() + " ";
- }
- String licenseUrl = "";
- if (license.getUrl() != null) {
- licenseUrl = license.getUrl();
- }
- boolean recognized = recognizeLicense(licenses, licenseName, licenseUrl);
- if (!recognized) {
- System.out.println("License " + licenseName + licenseUrl + " was not recognized, please enter a license name preferably in one of:");
- printAvailableLicenses();
- System.out.print("> ");
- String s = readLine();
- if (s.length() > 0) {
- licenses.add(s);
- }
- }
- }
-
- System.out.println();
- System.out.println("Checking licenses in the upstream sources...");
- LicenseCheckResult licenseResult = new LicenseCheckResult();
- DependenciesSolver.executeProcess(new String[]{"/bin/sh", "-c", "licensecheck `find . -type f`"},
- licenseResult);
- for (Iterator i = licenseResult.getLicenses().iterator(); i.hasNext(); ) {
- String license = (String) i.next();
- boolean recognized = recognizeLicense(licenses, license, "");
- if (!recognized) {
- System.out.println("License " + license + " was not recognized, please enter a license name preferably in one of:");
- printAvailableLicenses();
- System.out.print("> ");
- String s = readLine();
- if (s.length() > 0) {
- licenses.add(s);
- }
- }
- }
-
- if (licenses.isEmpty()) {
- System.out.println("License was not found, please enter a license name preferably in one of:");
- printAvailableLicenses();
- System.out.print("> ");
- String s = readLine();
- if (s.length() > 0) {
- licenses.add(s);
- }
- }
- return licenses;
- }
-
- private void printAvailableLicenses() {
- System.out.println("Apache-2.0 Artistic BSD FreeBSD ISC CC-BY CC-BY-SA CC-BY-ND CC-BY-NC CC-BY-NC-SA");
- System.out.println("CC-BY-NC-ND CC0 CDDL CPL Eiffel Expat GPL-2 GPL-3 LGPL-2 LGPL-2.1 LGPL-3");
- System.out.println("GFDL-1.2 GFDL-1.3 GFDL-NIV LPPL MPL Perl PSF QPL W3C-Software ZLIB Zope");
- }
-
- boolean recognizeLicense(Set licenses, String licenseName, String licenseUrl) {
- boolean recognized = false;
- licenseName = licenseName.toLowerCase();
- licenseUrl = licenseUrl.toLowerCase();
- if (licenseName.indexOf("mit ") >= 0 || licenseUrl.indexOf("mit-license") >= 0) {
- licenses.add("MIT");
- recognized = true;
- } else if (licenseName.indexOf("bsd ") >= 0 || licenseUrl.indexOf("bsd-license") >= 0) {
- licenses.add("BSD");
- recognized = true;
- } else if (licenseName.indexOf("artistic ") >= 0 || licenseUrl.indexOf("artistic-license") >= 0) {
- licenses.add("Artistic");
- recognized = true;
- } else if (licenseName.indexOf("apache ") >= 0 || licenseUrl.indexOf("apache") >= 0) {
- if (licenseName.indexOf("2.") >= 0 || licenseUrl.indexOf("2.") >= 0) {
- licenses.add("Apache-2.0");
- recognized = true;
- } else if (licenseName.indexOf("1.0") >= 0 || licenseUrl.indexOf("1.0") >= 0) {
- licenses.add("Apache-1.0");
- recognized = true;
- } else if (licenseName.indexOf("1.1") >= 0 || licenseUrl.indexOf("1.1") >= 0) {
- licenses.add("Apache-1.1");
- recognized = true;
- }
- } else if (licenseName.indexOf("lgpl ") >= 0 || licenseUrl.indexOf("lgpl") >= 0) {
- if (licenseName.indexOf("2.1") >= 0 || licenseUrl.indexOf("2.1") >= 0) {
- licenses.add("LGPL-2.1");
- recognized = true;
- } else if (licenseName.indexOf("2") >= 0 || licenseUrl.indexOf("2") >= 0) {
- licenses.add("LGPL-2");
- recognized = true;
- } else if (licenseName.indexOf("3") >= 0 || licenseUrl.indexOf("3") >= 0) {
- licenses.add("LGPL-2");
- recognized = true;
- }
- } else if (licenseName.indexOf("gpl ") >= 0 || licenseUrl.indexOf("gpl") >= 0) {
- if (licenseName.indexOf("2") >= 0 || licenseUrl.indexOf("2") >= 0) {
- licenses.add("GPL-2");
- recognized = true;
- } else if (licenseName.indexOf("3") >= 0 || licenseUrl.indexOf("3") >= 0) {
- licenses.add("GPL-3");
- recognized = true;
- }
-
- } else if (licenseUrl.indexOf("http://creativecommons.org/licenses/by-sa/3.0") >= 0) {
- licenses.add("CC-BY-SA-3.0");
- recognized = true;
- }
- return recognized;
- }
-
- private void generateFile(VelocityContext context, String templateName, File destDir, String fileName) throws Exception {
- destDir.mkdirs();
- FileWriter out = new FileWriter(new File(destDir, fileName));
- Velocity.mergeTemplate(templateName, "UTF8", context, out);
- out.flush();
- out.close();
- }
-
- private List listSharedJars(String library) {
- final List jars = new ArrayList();
- if (library.indexOf("(") > 0) {
- library = library.substring(0, library.indexOf("(")).trim();
- }
- System.out.println();
- System.out.println("Looking for shared jars in package " + library + "...");
- DependenciesSolver.executeProcess(new String[]{"/usr/bin/dpkg", "--listfiles", library},
- new DependenciesSolver.OutputHandler() {
-
- public void newLine(String line) {
- if (line.startsWith("/usr/share/java/") && line.endsWith(".jar")) {
- String jar = line.substring("/usr/share/java/".length());
- jar = jar.substring(0, jar.length() - 4);
- if (!line.matches(".*/.*-\\d.*")) {
- jars.add(jar);
- System.out.println(" Add " + jar + " to the classpath");
- }
- }
- }
- });
- return jars;
- }
-
- private String readLine() {
- LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
- try {
- return consoleReader.readLine().trim();
- } catch (IOException e) {
- e.printStackTrace();
- return "";
- }
- }
-
- private List split(String s) {
- List l = new ArrayList();
- if (s != null) {
- StringTokenizer st = new StringTokenizer(s, ",");
- while (st.hasMoreTokens()) {
- l.add(st.nextToken().trim());
- }
- }
- return l;
- }
-
- private void makeExecutable(String file) {
- DependenciesSolver.executeProcess(new String[]{"chmod", "+x", file}, new DependenciesSolver.NoOutputHandler());
- }
-
- public static class WrappedProject {
- private final MavenProject baseProject;
- private final MavenProject mavenProject;
-
- public WrappedProject(MavenProject baseProject, MavenProject mavenProject) {
- this.baseProject = baseProject;
- this.mavenProject = mavenProject;
- }
-
- public String getBaseDir() {
- String basedir = baseProject.getBasedir().getAbsolutePath();
- String dirRelPath = "";
- if (! mavenProject.getBasedir().equals(baseProject.getBasedir())) {
- dirRelPath = mavenProject.getBasedir().getAbsolutePath().substring(basedir.length() + 1) + "/";
- }
- return dirRelPath;
- }
-
- public String getArtifactId() {
- return mavenProject.getArtifactId();
- }
-
- public String getGroupId() {
- return mavenProject.getGroupId();
- }
-
- public String getVersion() {
- return mavenProject.getVersion();
- }
-
- public String getPackaging() {
- return mavenProject.getPackaging();
- }
- }
-
- static class LicenseCheckResult implements DependenciesSolver.OutputHandler {
-
- private Set licenses = new TreeSet();
- private Set copyrightOwners = new TreeSet();
-
- public void newLine(String line) {
- if (line.startsWith(".") && line.indexOf(":") > 0) {
- int col = line.lastIndexOf(":");
- String license = line.substring(col + 1).trim();
- if (license.indexOf("UNKNOWN") >= 0) {
- return;
- }
- if (license.indexOf("*") >= 0) {
- license = license.substring(license.lastIndexOf("*") + 1).trim();
- }
- licenses.add(license);
- }
- }
-
- public Set getLicenses() {
- return licenses;
- }
-
- public Set getCopyrightOwners() {
- return copyrightOwners;
- }
- }
-
- interface DownloadType {
-
- int UNKNOWN = 0;
- int SVN = 1;
- int CVS = 2;
- int TARBALL = 3;
- }
-}
-
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,766 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ *
+ * 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.
+ */
+
+import org.apache.maven.model.Developer;
+import org.apache.maven.model.License;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.debian.maven.repo.ListOfPOMs;
+
+/**
+ * Generate the Debian files for packaging the current Maven project.
+ *
+ * @goal generate
+ * @aggregator
+ * @requiresDependencyResolution
+ * @phase process-sources
+ *
+ * @author Ludovic Claude
+ */
+public class GenerateDebianFilesMojo
+ extends AbstractMojo {
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ * @required
+ */
+ protected MavenProject project;
+ /**
+ * A list of every project in this reactor; provided by Maven
+ * @parameter expression="${project.collectedProjects}"
+ */
+ protected List collectedProjects;
+ /**
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactRepository localRepository;
+ /**
+ * Location of the file.
+ * @parameter expression="${debian.directory}"
+ * default-value="debian"
+ */
+ protected File outputDirectory;
+ /**
+ * Name of the packager (e.g. 'Ludovic Claude')
+ * @parameter expression="${packager}"
+ * @required
+ */
+ protected String packager;
+ /**
+ * Email of the packager (e.g. 'ludovic.claude at laposte.net')
+ * @parameter expression="${email}"
+ * @required
+ */
+ protected String email;
+ /**
+ * License used by the packager (e.g. 'GPL-3' or 'Apache-2.0')
+ * See http://dep.debian.net/deps/dep5/ for the list of licenses.
+ * @parameter expression="${packagerLicense}" default-value="GPL-3"
+ * @required
+ */
+ protected String packagerLicense;
+ /**
+ * Name of the source package (e.g. 'commons-lang')
+ * @parameter expression="${package}"
+ * @required
+ */
+ protected String packageName;
+ /**
+ * Name of the binary package (e.g. 'libcommons-lang-java')
+ * @parameter expression="${bin.package}"
+ * @required
+ */
+ protected String binPackageName;
+ /**
+ * Type of the package (e.g. 'maven' or 'ant')
+ * @parameter expression="${packageType}" default-value="maven"
+ */
+ protected String packageType;
+ /**
+ * URL for downloading the source code, in the form scm:[svn|cvs]:http://xxx/
+ * for downloads using a source code repository,
+ * or http://xxx.[tar|zip|gz|tgz] for downloads using source tarballs.
+ * @parameter expression="${downloadUrl}"
+ */
+ protected String downloadUrl;
+ /**
+ * If true, include running the tests during the build.
+ * @parameter expression="${runTests}" default-value="false"
+ */
+ protected boolean runTests;
+ /**
+ * If true, generate the Javadoc packaged in a separate package.
+ * @parameter expression="${generateJavadoc}" default-value="false"
+ */
+ protected boolean generateJavadoc;
+
+ public void execute()
+ throws MojoExecutionException {
+ File f = outputDirectory;
+ if (!f.exists()) {
+ f.mkdirs();
+ }
+
+ String controlTemplate = "control.vm";
+ String rulesTemplate = "rules.vm";
+ if ("ant".equals(packageType)) {
+ controlTemplate = "control.ant.vm";
+ rulesTemplate = "rules.ant.vm";
+ }
+ // #638788: clean up email
+ if (email != null && email.indexOf('<') >= 0 && email.indexOf('>') >= 0) {
+ email = email.substring(email.indexOf('<') + 1, email.indexOf('>') - 1);
+ }
+
+ try {
+ Properties velocityProperties = new Properties();
+ velocityProperties.put("resource.loader", "class");
+ velocityProperties.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ Velocity.init(velocityProperties);
+ VelocityContext context = new VelocityContext();
+ context.put("package", packageName);
+ context.put("packageType", packageType);
+ context.put("binPackage", binPackageName);
+ context.put("packager", packager);
+ context.put("packagerEmail", email);
+ context.put("project", project);
+ context.put("collectedProjects", wrapMavenProjects(collectedProjects));
+ context.put("runTests", Boolean.valueOf(runTests));
+ context.put("generateJavadoc", Boolean.valueOf(generateJavadoc));
+
+ if (project.getName() == null || project.getName().isEmpty()) {
+ System.out.println("POM does not contain the project name. Please enter the name of the project:");
+ project.setName(readLine());
+ }
+ if (project.getUrl() == null || project.getUrl().isEmpty()) {
+ System.out.println("POM does not contain the project URL. Please enter the URL of the project:");
+ project.setUrl(readLine());
+ }
+
+ Set licenses = discoverLicenses();
+ context.put("licenses", licenses);
+
+ if (licenses.size() == 1) {
+ packagerLicense = (String) licenses.iterator().next();
+ }
+ if (packagerLicense == null) {
+ System.out.println("Packager license for the debian/ filse was not found, please enter a license name preferably in one of:");
+ System.out.println("Apache Artistic BSD FreeBSD ISC CC-BY CC-BY-SA CC-BY-ND CC-BY-NC CC-BY-NC-SA CC-BY-NC-ND CC0 CDDL CPL Eiffel");
+ System.out.println("Expat GPL LGPL GFDL GFDL-NIV LPPL MPL Perl PSF QPL W3C-Software ZLIB Zope");
+ String s = readLine();
+ if (s.length() > 0) {
+ packagerLicense = s;
+ }
+ }
+ context.put("packagerLicense", packagerLicense);
+
+ String copyrightOwner = "";
+ String projectTeam = "";
+ if (project.getOrganization() != null) {
+ copyrightOwner = project.getOrganization().getName();
+ projectTeam = project.getOrganization().getName() + " developers";
+ }
+ if (copyrightOwner == null || copyrightOwner.isEmpty()) {
+ Iterator devs = project.getDevelopers().iterator();
+ if (devs.hasNext()) {
+ Developer dev = (Developer) devs.next();
+ copyrightOwner = dev.getName();
+ if (dev.getEmail() != null && !dev.getEmail().isEmpty()) {
+ copyrightOwner += " <" + dev.getEmail() + ">";
+ }
+ }
+ }
+ if (copyrightOwner == null || copyrightOwner.isEmpty()) {
+ System.out.println("Could not find who owns the copyright for the upstream sources, please enter his name:");
+ copyrightOwner = readLine();
+ }
+ context.put("copyrightOwner", copyrightOwner);
+
+ if (projectTeam == null || projectTeam.isEmpty()) {
+ projectTeam = project.getName() + " developers";
+ }
+ context.put("projectTeam", projectTeam);
+
+ String copyrightYear;
+ int currentYear = new GregorianCalendar().get(Calendar.YEAR);
+ if (project.getInceptionYear() != null) {
+ copyrightYear = project.getInceptionYear();
+ if (Integer.parseInt(copyrightYear) < currentYear) {
+ copyrightYear += "-" + currentYear;
+ }
+ } else {
+ copyrightYear = String.valueOf(currentYear);
+ }
+ context.put("copyrightYear", copyrightYear);
+ context.put("currentYear", new Integer(currentYear));
+
+ List description = new ArrayList();
+ if (project.getDescription() == null || project.getDescription().trim().isEmpty()) {
+ System.out.println("Please enter a short description of the project, press Enter twice to stop.");
+ StringBuffer sb = new StringBuffer();
+ int emptyEnterCount = 0;
+ while (emptyEnterCount < 2) {
+ String s = readLine();
+ if (s.isEmpty()) {
+ emptyEnterCount++;
+ } else {
+ if (emptyEnterCount > 0) {
+ emptyEnterCount = 0;
+ sb.append("\n");
+ }
+ sb.append(s);
+ sb.append("\n");
+ }
+ }
+ project.setDescription(sb.toString());
+ }
+ if (project.getDescription() != null) {
+ StringTokenizer st = new StringTokenizer(project.getDescription().trim(), "\n\t ");
+ StringBuffer descLine = new StringBuffer();
+ while (st.hasMoreTokens()) {
+ descLine.append(st.nextToken());
+ descLine.append(" ");
+ if (descLine.length() > 70 || !st.hasMoreTokens()) {
+ String line = descLine.toString().trim();
+ if (line.isEmpty()) {
+ line = ".";
+ }
+ description.add(line);
+ descLine = new StringBuffer();
+ }
+ }
+ }
+ context.put("description", description);
+
+ File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
+ if (substvarsFile.exists()) {
+ Properties substvars = new Properties();
+ substvars.load(new FileReader(substvarsFile));
+ List compileDepends = new ArrayList();
+ compileDepends.addAll(split(substvars.getProperty("maven.CompileDepends")));
+ compileDepends.addAll(split(substvars.getProperty("maven.Depends")));
+ List buildDepends = new ArrayList(compileDepends);
+ List testDepends = new ArrayList(split(substvars.getProperty("maven.TestDepends")));
+ if (runTests) {
+ buildDepends.addAll(testDepends);
+ }
+ if (generateJavadoc) {
+ buildDepends.addAll(split(substvars.getProperty("maven.DocDepends")));
+ buildDepends.addAll(split(substvars.getProperty("maven.DocOptionalDepends")));
+ }
+ if ("maven".equals(packageType)) {
+ boolean seenJavadocPlugin = false;
+ // Remove dependencies that are implied by maven-debian-helper
+ for (Iterator i = buildDepends.iterator(); i.hasNext();) {
+ String dependency = (String) i.next();
+ if (dependency.startsWith("libmaven-clean-plugin-java") ||
+ dependency.startsWith("libmaven-resources-plugin-java") ||
+ dependency.startsWith("libmaven-compiler-plugin-java") ||
+ dependency.startsWith("libmaven-jar-plugin-java") ||
+ dependency.startsWith("libmaven-site-plugin-java") ||
+ dependency.startsWith("libsurefire-java") ||
+ dependency.startsWith("velocity") ||
+ dependency.startsWith("libplexus-velocity-java")) {
+ i.remove();
+ } else if (dependency.startsWith("libmaven-javadoc-plugin-java")) {
+ seenJavadocPlugin = true;
+ }
+ }
+ if (generateJavadoc && !seenJavadocPlugin) {
+ buildDepends.add("libmaven-javadoc-plugin-java");
+ }
+ } else if ("ant".equals(packageType)) {
+ // Remove dependencies that are implied by ant packaging
+ for (Iterator i = buildDepends.iterator(); i.hasNext(); ) {
+ String dependency = (String) i.next();
+ if (dependency.equals("ant") ||
+ dependency.startsWith("ant ") ||
+ dependency.startsWith("ant-optional")) {
+ i.remove();
+ }
+ }
+ buildDepends.remove("ant");
+ buildDepends.remove("ant-optional");
+ }
+ context.put("buildDependencies", buildDepends);
+ context.put("runtimeDependencies", split(substvars.getProperty("maven.Depends")));
+ context.put("testDependencies", split(substvars.getProperty("maven.TestDepends")));
+ context.put("optionalDependencies", split(substvars.getProperty("maven.OptionalDepends")));
+ context.put("javadocDependencies", split(substvars.getProperty("maven.DocDepends")));
+ context.put("javadocOptionalDependencies", split(substvars.getProperty("maven.DocOptionalDepends")));
+
+ if ("ant".equals(packageType)) {
+ Set compileJars = new TreeSet();
+ for (Iterator i = compileDepends.iterator(); i.hasNext();) {
+ String library = (String) i.next();
+ compileJars.addAll(listSharedJars(library));
+ }
+ context.put("compileJars", compileJars);
+ Set testJars = new TreeSet();
+ for (Iterator i = testDepends.iterator(); i.hasNext();) {
+ String library = (String) i.next();
+ testJars.addAll(listSharedJars(library));
+ }
+ context.put("testJars", testJars);
+ }
+ } else {
+ System.err.println("Cannot find file " + substvarsFile);
+ }
+
+ if ("ant".equals(packageType)) {
+ ListOfPOMs listOfPOMs = new ListOfPOMs(new File(outputDirectory, binPackageName + ".poms"));
+ ListOfPOMs listOfJavadocPOMs = null;
+ if (generateJavadoc && "ant".equals(packageType)) {
+ listOfJavadocPOMs = new ListOfPOMs(new File(outputDirectory, binPackageName + "-doc.poms"));
+ }
+ setupArtifactLocation(listOfPOMs, listOfJavadocPOMs, project);
+ for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
+ MavenProject mavenProject = (MavenProject) i.next();
+ setupArtifactLocation(listOfPOMs, listOfJavadocPOMs, mavenProject);
+ }
+ listOfPOMs.save();
+ if (listOfJavadocPOMs != null) {
+ listOfJavadocPOMs.save();
+ }
+ }
+
+ String projectVersion = project.getVersion();
+ int downloadType = DownloadType.UNKNOWN;
+
+ if (downloadUrl == null) {
+ if (project.getScm() != null) {
+ downloadUrl = project.getScm().getConnection();
+ }
+ }
+ if (downloadUrl != null && downloadUrl.startsWith("scm:svn:")) {
+ downloadType = DownloadType.SVN;
+ downloadUrl = downloadUrl.substring("scm:svn:".length());
+ String tag = projectVersion;
+ int tagPos = downloadUrl.indexOf(tag);
+ String baseUrl = null;
+ String suffixUrl = null;
+ String tagMarker = null;
+ if (tagPos >= 0) {
+ baseUrl = downloadUrl.substring(0, tagPos);
+ suffixUrl = downloadUrl.substring(tagPos + tag.length());
+ if (!suffixUrl.endsWith("/")) {
+ suffixUrl += "/";
+ }
+ int slashPos = baseUrl.lastIndexOf("/");
+ tagMarker = baseUrl.substring(slashPos + 1);
+ baseUrl = baseUrl.substring(0, slashPos);
+ }
+ if (tagPos < 0 && downloadUrl.indexOf("/trunk") >= 0) {
+ System.out.println("Download URL does not include a tagged revision but /trunk found,");
+ System.out.println("Trying to guess the address of the tagged revision.");
+ tag = "trunk";
+ tagPos = downloadUrl.indexOf(tag);
+ baseUrl = downloadUrl.substring(0, tagPos);
+ baseUrl += "tags";
+ tagMarker = packageName + "-";
+ suffixUrl = "";
+ }
+ if (tagPos >= 0) {
+ context.put("baseUrl", baseUrl);
+ context.put("tagMarker", tagMarker);
+ context.put("suffixUrl", suffixUrl);
+
+ generateFile(context, "watch.svn.vm", outputDirectory, "watch");
+ generateFile(context, "orig-tar.svn.vm", outputDirectory, "orig-tar.sh");
+
+ makeExecutable("debian/orig-tar.sh");
+
+ } else {
+ System.err.println("Cannot locate the version in the download url (" +
+ downloadUrl + ").");
+ System.err.println("Please run again and provide the download location with an explicit version tag, e.g.");
+ System.err.println("-DdownloadUrl=scm:svn:http://svn.codehaus.org/modello/tags/modello-1.0-alpha-21/");
+ }
+ }
+
+ if (downloadType == DownloadType.UNKNOWN) {
+ System.err.println("Cannot recognize the download url (" +
+ downloadUrl + ").");
+ }
+
+ generateFile(context, "README.source.vm", outputDirectory, "README.source");
+ generateFile(context, "copyright.vm", outputDirectory, "copyright");
+ generateFile(context, "compat.vm", outputDirectory, "compat");
+ generateFile(context, rulesTemplate, outputDirectory, "rules");
+
+ makeExecutable("debian/rules");
+
+ String debianVersion = projectVersion.replace("-alpha-", "~alpha");
+ debianVersion = debianVersion.replace("-beta-", "~beta");
+ debianVersion += "-1";
+ context.put("version.vm", debianVersion);
+
+ generateFile(context, rulesTemplate, new File("."), ".debianVersion");
+
+ if (generateJavadoc) {
+ if (project.getPackaging().equals("pom") && collectedProjects.size() > 1) {
+ generateFile(context, "java-doc.doc-base.api.multi.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
+ generateFile(context, "java-doc.install.multi.vm", outputDirectory, binPackageName + "-doc.install");
+ } else {
+ generateFile(context, "java-doc.doc-base.api.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
+ generateFile(context, "java-doc.install.vm", outputDirectory, binPackageName + "-doc.install");
+ }
+ }
+
+ if ("ant".equals(packageType)) {
+ boolean containsJars = false;
+ boolean containsPlugins = false;
+ if (project.getPackaging().equals("pom") && project.getModules().size() > 0) {
+ for (Iterator i = collectedProjects.iterator(); i.hasNext(); ) {
+ MavenProject module = (MavenProject) i.next();
+ if (module.getPackaging().equals("maven-plugin")) {
+ containsPlugins = true;
+ } else if (!module.getPackaging().equals("pom")) {
+ containsJars = true;
+ }
+ }
+ } else if (!project.getPackaging().equals("pom")) {
+ if (project.getPackaging().equals("maven-plugin")) {
+ containsPlugins = true;
+ } else if (!project.getPackaging().equals("pom")) {
+ containsJars = true;
+ }
+ }
+ context.put("containsJars", Boolean.valueOf(containsJars));
+ context.put("containsPlugins", Boolean.valueOf(containsPlugins));
+
+ if (project.getPackaging().equals("pom") && project.getModules().size() > 0) {
+ generateFile(context, "build.xml.vm", outputDirectory, "build.xml");
+ }
+ generateFile(context, "build.properties.ant.vm", outputDirectory, "build.properties");
+ generateFile(context, "build-classpath.vm", outputDirectory, "build-classpath");
+ } else {
+ generateFile(context, "maven.properties.vm", outputDirectory, "maven.properties");
+ }
+
+ generateFile(context, controlTemplate, outputDirectory, "control");
+ generateFile(context, "format.vm", new File(outputDirectory, "source"), "format");
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ private List wrapMavenProjects(List<MavenProject> projects) {
+ List<WrappedProject> wrappedProjects = new ArrayList<WrappedProject>();
+ for (MavenProject aProject: projects) {
+ wrappedProjects.add(new WrappedProject(this.project, aProject));
+ }
+ return wrappedProjects;
+ }
+
+ private void setupArtifactLocation(ListOfPOMs listOfPOMs, ListOfPOMs listOfJavadocPOMs, MavenProject mavenProject) {
+ String dirRelPath = new WrappedProject(project, mavenProject).getBaseDir();
+
+ if (! "pom".equals(mavenProject.getPackaging())) {
+ String pomFile = dirRelPath + "pom.xml";
+ listOfPOMs.getOrCreatePOMOptions(pomFile).setJavaLib(true);
+ String extension = mavenProject.getPackaging();
+ if (extension.equals("bundle")) {
+ extension = "jar";
+ }
+ if (extension.equals("webapp")) {
+ extension = "war";
+ }
+ if (mavenProject.getArtifact() != null && mavenProject.getArtifact().getFile() != null) {
+ extension = mavenProject.getArtifact().getFile().toString();
+ extension = extension.substring(extension.lastIndexOf('.') + 1);
+ }
+ ListOfPOMs.POMOptions pomOptions = listOfPOMs.getOrCreatePOMOptions(pomFile);
+ pomOptions.setArtifact(dirRelPath + "target/" + mavenProject.getArtifactId() + "-*."
+ + extension);
+ if ("jar".equals(extension) && generateJavadoc && "ant".equals(packageType) && listOfJavadocPOMs != null) {
+ String artifactId = mavenProject.getArtifact().getArtifactId();
+ ListOfPOMs.POMOptions javadocPomOptions = listOfJavadocPOMs.getOrCreatePOMOptions(pomFile);
+ javadocPomOptions.setIgnorePOM(true);
+ javadocPomOptions.setArtifact(dirRelPath + "target/" + artifactId + ".javadoc.jar");
+ javadocPomOptions.setClassifier("javadoc");
+ javadocPomOptions.setHasPackageVersion(pomOptions.getHasPackageVersion());
+ }
+ pomOptions.setJavaLib(true);
+ if (mavenProject.getArtifactId().matches(packageName + "\\d")) {
+ pomOptions.setUsjName(packageName);
+ }
+ }
+ }
+
+ private Set discoverLicenses() {
+ Set licenses = new TreeSet();
+ for (Iterator i = project.getLicenses().iterator(); i.hasNext(); ) {
+ License license = (License) i.next();
+ String licenseName = "";
+ if (license.getName() != null) {
+ licenseName = license.getName() + " ";
+ }
+ String licenseUrl = "";
+ if (license.getUrl() != null) {
+ licenseUrl = license.getUrl();
+ }
+ boolean recognized = recognizeLicense(licenses, licenseName, licenseUrl);
+ if (!recognized) {
+ System.out.println("License " + licenseName + licenseUrl + " was not recognized, please enter a license name preferably in one of:");
+ printAvailableLicenses();
+ System.out.print("> ");
+ String s = readLine();
+ if (s.length() > 0) {
+ licenses.add(s);
+ }
+ }
+ }
+
+ System.out.println();
+ System.out.println("Checking licenses in the upstream sources...");
+ LicenseCheckResult licenseResult = new LicenseCheckResult();
+ DependenciesSolver.executeProcess(new String[]{"/bin/sh", "-c", "licensecheck `find . -type f`"},
+ licenseResult);
+ for (Iterator i = licenseResult.getLicenses().iterator(); i.hasNext(); ) {
+ String license = (String) i.next();
+ boolean recognized = recognizeLicense(licenses, license, "");
+ if (!recognized) {
+ System.out.println("License " + license + " was not recognized, please enter a license name preferably in one of:");
+ printAvailableLicenses();
+ System.out.print("> ");
+ String s = readLine();
+ if (s.length() > 0) {
+ licenses.add(s);
+ }
+ }
+ }
+
+ if (licenses.isEmpty()) {
+ System.out.println("License was not found, please enter a license name preferably in one of:");
+ printAvailableLicenses();
+ System.out.print("> ");
+ String s = readLine();
+ if (s.length() > 0) {
+ licenses.add(s);
+ }
+ }
+ return licenses;
+ }
+
+ private void printAvailableLicenses() {
+ System.out.println("Apache-2.0 Artistic BSD FreeBSD ISC CC-BY CC-BY-SA CC-BY-ND CC-BY-NC CC-BY-NC-SA");
+ System.out.println("CC-BY-NC-ND CC0 CDDL CPL Eiffel Expat GPL-2 GPL-3 LGPL-2 LGPL-2.1 LGPL-3");
+ System.out.println("GFDL-1.2 GFDL-1.3 GFDL-NIV LPPL MPL Perl PSF QPL W3C-Software ZLIB Zope");
+ }
+
+ boolean recognizeLicense(Set licenses, String licenseName, String licenseUrl) {
+ boolean recognized = false;
+ licenseName = licenseName.toLowerCase();
+ licenseUrl = licenseUrl.toLowerCase();
+ if (licenseName.indexOf("mit ") >= 0 || licenseUrl.indexOf("mit-license") >= 0) {
+ licenses.add("MIT");
+ recognized = true;
+ } else if (licenseName.indexOf("bsd ") >= 0 || licenseUrl.indexOf("bsd-license") >= 0) {
+ licenses.add("BSD");
+ recognized = true;
+ } else if (licenseName.indexOf("artistic ") >= 0 || licenseUrl.indexOf("artistic-license") >= 0) {
+ licenses.add("Artistic");
+ recognized = true;
+ } else if (licenseName.indexOf("apache ") >= 0 || licenseUrl.indexOf("apache") >= 0) {
+ if (licenseName.indexOf("2.") >= 0 || licenseUrl.indexOf("2.") >= 0) {
+ licenses.add("Apache-2.0");
+ recognized = true;
+ } else if (licenseName.indexOf("1.0") >= 0 || licenseUrl.indexOf("1.0") >= 0) {
+ licenses.add("Apache-1.0");
+ recognized = true;
+ } else if (licenseName.indexOf("1.1") >= 0 || licenseUrl.indexOf("1.1") >= 0) {
+ licenses.add("Apache-1.1");
+ recognized = true;
+ }
+ } else if (licenseName.indexOf("lgpl ") >= 0 || licenseUrl.indexOf("lgpl") >= 0) {
+ if (licenseName.indexOf("2.1") >= 0 || licenseUrl.indexOf("2.1") >= 0) {
+ licenses.add("LGPL-2.1");
+ recognized = true;
+ } else if (licenseName.indexOf("2") >= 0 || licenseUrl.indexOf("2") >= 0) {
+ licenses.add("LGPL-2");
+ recognized = true;
+ } else if (licenseName.indexOf("3") >= 0 || licenseUrl.indexOf("3") >= 0) {
+ licenses.add("LGPL-2");
+ recognized = true;
+ }
+ } else if (licenseName.indexOf("gpl ") >= 0 || licenseUrl.indexOf("gpl") >= 0) {
+ if (licenseName.indexOf("2") >= 0 || licenseUrl.indexOf("2") >= 0) {
+ licenses.add("GPL-2");
+ recognized = true;
+ } else if (licenseName.indexOf("3") >= 0 || licenseUrl.indexOf("3") >= 0) {
+ licenses.add("GPL-3");
+ recognized = true;
+ }
+
+ } else if (licenseUrl.indexOf("http://creativecommons.org/licenses/by-sa/3.0") >= 0) {
+ licenses.add("CC-BY-SA-3.0");
+ recognized = true;
+ }
+ return recognized;
+ }
+
+ private void generateFile(VelocityContext context, String templateName, File destDir, String fileName) throws Exception {
+ destDir.mkdirs();
+ FileWriter out = new FileWriter(new File(destDir, fileName));
+ Velocity.mergeTemplate(templateName, "UTF8", context, out);
+ out.flush();
+ out.close();
+ }
+
+ private Map<String, List<String>> cacheOfSharedJars = new HashMap<String, List<String>>();
+ private List<String> listSharedJars(String library) {
+ if (cacheOfSharedJars.get(library) != null) {
+ return cacheOfSharedJars.get(library);
+ }
+
+ final List<String> jars = new ArrayList<String>();
+ if (library.indexOf("(") > 0) {
+ library = library.substring(0, library.indexOf("(")).trim();
+ }
+ System.out.println();
+ System.out.println("Looking for shared jars in package " + library + "...");
+ DependenciesSolver.executeProcess(new String[]{"/usr/bin/dpkg", "--listfiles", library},
+ new DependenciesSolver.OutputHandler() {
+
+ public void newLine(String line) {
+ if (line.startsWith("/usr/share/java/") && line.endsWith(".jar")) {
+ String jar = line.substring("/usr/share/java/".length());
+ jar = jar.substring(0, jar.length() - 4);
+ if (!line.matches(".*/.*-\\d.*")) {
+ jars.add(jar);
+ System.out.println(" Add " + jar + " to the classpath");
+ }
+ }
+ }
+ });
+ cacheOfSharedJars.put(library, jars);
+ return jars;
+ }
+
+ private String readLine() {
+ LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
+ try {
+ return consoleReader.readLine().trim();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ private List split(String s) {
+ List l = new ArrayList();
+ if (s != null) {
+ StringTokenizer st = new StringTokenizer(s, ",");
+ while (st.hasMoreTokens()) {
+ l.add(st.nextToken().trim());
+ }
+ }
+ return l;
+ }
+
+ private void makeExecutable(String file) {
+ DependenciesSolver.executeProcess(new String[]{"chmod", "+x", file}, new DependenciesSolver.NoOutputHandler());
+ }
+
+ public static class WrappedProject {
+ private final MavenProject baseProject;
+ private final MavenProject mavenProject;
+
+ public WrappedProject(MavenProject baseProject, MavenProject mavenProject) {
+ this.baseProject = baseProject;
+ this.mavenProject = mavenProject;
+ }
+
+ public String getBaseDir() {
+ String basedir = baseProject.getBasedir().getAbsolutePath();
+ String dirRelPath = "";
+ if (! mavenProject.getBasedir().equals(baseProject.getBasedir())) {
+ dirRelPath = mavenProject.getBasedir().getAbsolutePath().substring(basedir.length() + 1) + "/";
+ }
+ return dirRelPath;
+ }
+
+ public String getArtifactId() {
+ return mavenProject.getArtifactId();
+ }
+
+ public String getGroupId() {
+ return mavenProject.getGroupId();
+ }
+
+ public String getVersion() {
+ return mavenProject.getVersion();
+ }
+
+ public String getPackaging() {
+ return mavenProject.getPackaging();
+ }
+ }
+
+ static class LicenseCheckResult implements DependenciesSolver.OutputHandler {
+
+ private Set licenses = new TreeSet();
+ private Set copyrightOwners = new TreeSet();
+
+ public void newLine(String line) {
+ if (line.startsWith(".") && line.indexOf(":") > 0) {
+ int col = line.lastIndexOf(":");
+ String license = line.substring(col + 1).trim();
+ if (license.indexOf("UNKNOWN") >= 0) {
+ return;
+ }
+ if (license.indexOf("*") >= 0) {
+ license = license.substring(license.lastIndexOf("*") + 1).trim();
+ }
+ licenses.add(license);
+ }
+ }
+
+ public Set getLicenses() {
+ return licenses;
+ }
+
+ public Set getCopyrightOwners() {
+ return copyrightOwners;
+ }
+ }
+
+ interface DownloadType {
+
+ int UNKNOWN = 0;
+ int SVN = 1;
+ int CVS = 2;
+ int TARBALL = 3;
+ }
+}
+
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build-classpath.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1 +0,0 @@
-/usr/share/java/ant-nodeps.jar
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build-classpath.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build-classpath.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,4 @@
+/usr/share/java/ant-nodeps.jar
+#if($runTests)
+/usr/share/java/ant-junit.jar
+#end
\ No newline at end of file
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,19 +0,0 @@
-build.directory=target
-#if($generateJavadoc)
-javadoc.dir=target/apidocs
-javadoc.generate=true
-#end
-#if(!$runTests)
-maven.test.skip=true
-#end
-classpath.compile=\
-#foreach ($jar in $buildJars)
- /usr/share/java/${jar}.jar:\
-#end
-#set( $D = '$' )
-#foreach ($module in $collectedProjects)
-#if($module.packaging != "pom")
- ${D}{basedir}/${module.baseDir}target/${module.artifactId}-${D}{version}.jar:\
-#end
-#end
- target/classes
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.properties.ant.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.properties.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,25 @@
+build.directory=target
+#if($generateJavadoc)
+javadoc.dir=target/apidocs
+javadoc.generate=true
+#end
+#if(!$runTests)
+maven.test.skip=true
+#end
+classpath.compile=\
+#foreach ($jar in $compileJars)
+ /usr/share/java/${jar}.jar:\
+#end
+#set( $D = '$' )
+#foreach ($module in $collectedProjects)
+#if($module.packaging != "pom")
+ ${D}{basedir}/${module.baseDir}target/${module.artifactId}-${D}{version}.jar:\
+#end
+#end
+ target/classes
+
+classpath.test=\
+#foreach ($jar in $testJars)
+ /usr/share/java/${jar}.jar:\
+#end
+ target/classes
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.xml.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,79 +0,0 @@
-<?xml version="1.0"?>
-
-<project name="pkg-java" default="build-all" basedir="..">
-
- <property file="debian/build.properties"/>
- <property name="maven.build" value="/usr/share/maven-ant-helper/maven-build.xml"/>
- <property file="/usr/share/maven-ant-helper/maven-defaults.properties"/>
-
- <macrodef name="clean-module">
- <attribute name="dir"/>
- <sequential>
- <ant target="clean" antfile="${maven.build}" dir="@{dir}">
- <property name="debian.dir" location="debian" />
- <property name="project.dir" value="@{dir}" />
- </ant>
- </sequential>
- </macrodef>
-
- <macrodef name="package-module">
- <attribute name="dir"/>
- <sequential>
- <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}">
- <property name="debian.dir" location="debian" />
- <property name="project.dir" value="@{dir}" />
- <property name="keep-cleaned-pom" value="true" />
- </ant>
- </sequential>
- </macrodef>
-
-#if ($containsPlugins)
- <macrodef name="package-plugin-module">
- <attribute name="dir"/>
- <sequential>
- <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}">
- <property name="debian.dir" location="debian" />
- <property name="project.dir" value="@{dir}" />
- <property name="maven.generate.target" value="plugin:descriptor" />
- <property name="keep-cleaned-pom" value="true" />
- <property name="use-local-repo" value="true" />
- </ant>
- </sequential>
- </macrodef>
-
-#end
- <target name="clean">
- <clean-module dir=""/>
-#foreach ($module in $collectedProjects)
- <clean-module dir="${module.baseDir}"/>
-#end
- </target>
-
- <target name="package">
- <package-module dir=""/>
-#foreach ($module in $collectedProjects)
-#if ($module.packaging == "maven-plugin")
- <package-plugin-module dir="${module.baseDir}"/>
-#else
- <package-module dir="${module.baseDir}"/>
-#end
-#end
- </target>
-
-#if ($generateJavadoc)
- <target name="javadoc">
- <javadoc destdir="${javadoc.dir}">
-#foreach ($module in $collectedProjects)
-#if ($module.packaging != "pom")
- <packageset dir="${module.baseDir}src/main/java/"/>
-#end
-#end
- </javadoc>
- </target>
-
- <target name="build-all" depends="package, javadoc" />
-#else
- <target name="build-all" depends="package" />
-#end
-
-</project>
\ No newline at end of file
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/build.xml.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/build.xml.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,90 @@
+<?xml version="1.0"?>
+
+<project name="pkg-java" default="build-all" basedir="..">
+
+ <property file="debian/build.properties"/>
+ <property name="maven.build" value="/usr/share/maven-ant-helper/maven-build.xml"/>
+ <property file="/usr/share/maven-ant-helper/maven-defaults.properties"/>
+
+ <macrodef name="clean-module">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="clean" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="package-module">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ <property name="keep-cleaned-pom" value="true" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+#if ($containsPlugins)
+ <macrodef name="package-plugin-module">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ <property name="maven.generate.target" value="plugin:descriptor" />
+ <property name="keep-cleaned-pom" value="true" />
+ <property name="use-local-repo" value="true" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+#end
+#if($generateJavadoc)
+ <macrodef name="package-module-doc">
+ <attribute name="dir"/>
+ <sequential>
+ <ant target="local-install-doc" antfile="${maven.build}" dir="@{dir}">
+ <property name="debian.dir" location="debian" />
+ <property name="project.dir" value="@{dir}" />
+ <property name="keep-cleaned-pom" value="true" />
+ </ant>
+ </sequential>
+ </macrodef>
+
+#end
+ <target name="clean">
+ <clean-module dir=""/>
+#foreach ($module in $collectedProjects)
+ <clean-module dir="${module.baseDir}"/>
+#end
+ </target>
+
+ <target name="package">
+ <package-module dir=""/>
+#foreach ($module in $collectedProjects)
+#if ($module.packaging == "maven-plugin")
+ <package-plugin-module dir="${module.baseDir}"/>
+#else
+ <package-module dir="${module.baseDir}"/>
+#end
+#end
+ </target>
+
+#if ($generateJavadoc)
+ <target name="javadoc">
+#foreach ($module in $collectedProjects)
+#if ($module.packaging != "pom")
+ <package-module-doc dir="${module.baseDir}"/>
+#end
+#end
+ </target>
+
+ <target name="build-all" depends="package, javadoc" />
+#else
+ <target name="build-all" depends="package" />
+#end
+
+</project>
\ No newline at end of file
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,75 +0,0 @@
-#set ($dollar = "$")
-#set ($space = " ")
-#macro(printDependencies $dependencies)
-#set ($lineLength=0)
-#foreach ($dependency in $dependencies)
-#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #elseif ($velocityHasNext)
-$space
-#end
-#set ($lineLength = $lineLength + $dependency.length() + 2)
-#if ($lineLength > 70 && $velocityHasNext)
-$space
-#set ($lineLength=0)
-#end
-#end
-#end
-Source: ${package}
-Section: java
-Priority: optional
-Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
-Uploaders: ${packager} <${packagerEmail}>
-Build-Depends: debhelper (>= 7), default-jdk, maven-repo-helper (>= 1.5)#if ($project.packaging != "pom" || $project.modules.size() > 0), ant-optional, maven-ant-helper (>= 7.1)#end$space
-#if(!$compileDependencies.isEmpty())
-Build-Depends-Indep:#printDependencies($compileDependencies)$space
-#end
-Standards-Version: 3.9.2
-Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
-Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
-Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
-
-
-Package: ${binPackage}
-Architecture: all
-## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
-Depends: ${dollar}{misc:Depends},#printDependencies($runtimeDependencies)$space
-#if(!$optionalDependencies.isEmpty())
-Recommends: #printDependencies($optionalDependencies)$space
-#end
-#if ($generateJavadoc)
-Suggests: ${binPackage}-doc
-#end
-Description: ${project.Name}
-#if ($description.isEmpty()) TODO - fill the description
-#else
-#foreach ($line in $description)
-#if ($line == "")
- .
-#else
- $line
-#end
-#end
-#end
-
-#if ($generateJavadoc)
-Package: ${binPackage}-doc
-Architecture: all
-Section: doc
-Depends: ${dollar}{misc:Depends}, #printDependencies($javadocDependencies)$space
-#if(!$javadocOptionalDependencies.isEmpty())
-Recommends: #printDependencies($javadocOptionalDependencies)$space
-#end
-Suggests: ${binPackage}
-Description: Documentation for ${project.Name}
-#if ($description.isEmpty()) TODO - fill the description
-#else
-#foreach ($line in $description)
-#if ($line == "")
- .
-#else
- $line
-#end
-#end
-#end
- .
- This package contains the API documentation of ${binPackage}.
-#end
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,75 @@
+#set ($dollar = "$")
+#set ($space = " ")
+#macro(printDependencies $dependencies)
+#set ($lineLength=0)
+#foreach ($dependency in $dependencies)
+#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #elseif ($velocityHasNext)
+$space
+#end
+#set ($lineLength = $lineLength + $dependency.length() + 2)
+#if ($lineLength > 70 && $velocityHasNext)
+$space
+#set ($lineLength=0)
+#end
+#end
+#end
+Source: ${package}
+Section: java
+Priority: optional
+Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
+Uploaders: ${packager} <${packagerEmail}>
+Build-Depends: debhelper (>= 7), default-jdk, maven-repo-helper (>= 1.7.1)#if ($project.packaging != "pom" || $project.modules.size() > 0), ant-optional, maven-ant-helper (>= 7.6)#end$space
+#if(!$buildDependencies.isEmpty())
+Build-Depends-Indep:#printDependencies($buildDependencies)$space
+#end
+Standards-Version: 3.9.2
+Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
+Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
+
+
+Package: ${binPackage}
+Architecture: all
+## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
+Depends: ${dollar}{misc:Depends},#printDependencies($runtimeDependencies)$space
+#if(!$optionalDependencies.isEmpty())
+Recommends: #printDependencies($optionalDependencies)$space
+#end
+#if ($generateJavadoc)
+Suggests: ${binPackage}-doc
+#end
+Description: ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
+#foreach ($line in $description)
+#if ($line == "")
+ .
+#else
+ $line
+#end
+#end
+#end
+
+#if ($generateJavadoc)
+Package: ${binPackage}-doc
+Architecture: all
+Section: doc
+Depends: ${dollar}{misc:Depends}, #printDependencies($javadocDependencies)$space
+#if(!$javadocOptionalDependencies.isEmpty())
+Recommends: #printDependencies($javadocOptionalDependencies)$space
+#end
+Suggests: ${binPackage}
+Description: Documentation for ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
+#foreach ($line in $description)
+#if ($line == "")
+ .
+#else
+ $line
+#end
+#end
+#end
+ .
+ This package contains the API documentation of ${binPackage}.
+#end
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,71 +0,0 @@
-#set ($dollar = "$")
-#set ($space = " ")
-#macro(printDependencies $dependencies)
-#set ($lineLength=0)
-#foreach ($dependency in $dependencies)
-#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #elseif ($velocityHasNext)
-$space
-#end
-#set ($lineLength = $lineLength + $dependency.length() + 2)
-#if ($lineLength > 70 && $velocityHasNext)
-$space
-#set ($lineLength=0)
-#end
-#end
-#end
-Source: ${package}
-Section: java
-Priority: optional
-Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
-Uploaders: ${packager} <${packagerEmail}>
-Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper (>= 1.4)
-#if(!$compileDependencies.isEmpty())
-Build-Depends-Indep:#printDependencies($compileDependencies)$space
-#end
-Standards-Version: 3.9.2
-Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
-Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
-Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
-
-
-Package: ${binPackage}
-Architecture: all
-## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
-Depends: ${dollar}{misc:Depends}, ${dollar}{maven:Depends}
-Recommends: ${dollar}{maven:OptionalDepends}
-#if ($generateJavadoc)
-Suggests: ${binPackage}-doc
-#end
-Description: ${project.Name}
-#if ($description.isEmpty()) TODO - fill the description
-#else
-#foreach ($line in $description)
-#if ($line == "")
- .
-#else
- $line
-#end
-#end
-#end
-
-#if ($generateJavadoc)
-Package: ${binPackage}-doc
-Architecture: all
-Section: doc
-Depends: ${dollar}{misc:Depends}, ${dollar}{maven:DocDepends}
-Recommends: ${dollar}{maven:DocOptionalDepends}
-Suggests: ${binPackage}
-Description: Documentation for ${project.Name}
-#if ($description.isEmpty()) TODO - fill the description
-#else
-#foreach ($line in $description)
-#if ($line == "")
- .
-#else
- $line
-#end
-#end
-#end
- .
- This package contains the API documentation of ${binPackage}.
-#end
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/control.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,71 @@
+#set ($dollar = "$")
+#set ($space = " ")
+#macro(printDependencies $dependencies)
+#set ($lineLength=0)
+#foreach ($dependency in $dependencies)
+#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #elseif ($velocityHasNext)
+$space
+#end
+#set ($lineLength = $lineLength + $dependency.length() + 2)
+#if ($lineLength > 70 && $velocityHasNext)
+$space
+#set ($lineLength=0)
+#end
+#end
+#end
+Source: ${package}
+Section: java
+Priority: optional
+Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
+Uploaders: ${packager} <${packagerEmail}>
+Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper (>= 1.5)
+#if(!$buildDependencies.isEmpty())
+Build-Depends-Indep:#printDependencies($buildDependencies)$space
+#end
+Standards-Version: 3.9.2
+Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/${package}
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-java/trunk/${package}
+Homepage:#if(${project.Url}) ${project.Url} #else TODO #end
+
+
+Package: ${binPackage}
+Architecture: all
+## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
+Depends: ${dollar}{misc:Depends}, ${dollar}{maven:Depends}
+Recommends: ${dollar}{maven:OptionalDepends}
+#if ($generateJavadoc)
+Suggests: ${binPackage}-doc
+#end
+Description: ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
+#foreach ($line in $description)
+#if ($line == "")
+ .
+#else
+ $line
+#end
+#end
+#end
+
+#if ($generateJavadoc)
+Package: ${binPackage}-doc
+Architecture: all
+Section: doc
+Depends: ${dollar}{misc:Depends}, ${dollar}{maven:DocDepends}
+Recommends: ${dollar}{maven:DocOptionalDepends}
+Suggests: ${binPackage}
+Description: Documentation for ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
+#foreach ($line in $description)
+#if ($line == "")
+ .
+#else
+ $line
+#end
+#end
+#end
+ .
+ This package contains the API documentation of ${binPackage}.
+#end
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.doc-base.api.multi.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.doc-base.api.multi.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.doc-base.api.multi.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.doc-base.api.multi.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,20 @@
+Document: ${binPackage}
+Title: API Javadoc for ${project.Name}
+Author: ${projectTeam}
+Abstract: This is the API Javadoc provided for the
+ ${binPackage} libraries.
+Section: Programming
+
+Format: HTML
+#set($seenIndex=false)
+#foreach ($module in $collectedProjects)
+#if ($module.packaging != "pom")
+#if(!$seenIndex)
+Index: /usr/share/doc/${binPackage}/${module.baseDir}index.html
+Files: /usr/share/doc/${binPackage}/${module.baseDir}*
+#else
+#set($seenIndex=true)
+ /usr/share/doc/${binPackage}/${module.baseDir}*
+#end
+#end
+#end
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.install.multi.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/java-doc.install.multi.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.install.multi.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/java-doc.install.multi.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,5 @@
+#foreach ($module in $collectedProjects)
+#if ($module.packaging != "pom")
+${module.baseDir}target/apidocs/* usr/share/doc/${binPackage}/${module.baseDir}
+#end
+#end
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,24 +0,0 @@
-#!/usr/bin/make -f
-
-DEB_SOURCE_PACKAGE := $(shell dpkg-parsechangelog | grep '^Source:' | cut -f 2 -d ' ')
-DEB_UPSTREAM_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ' | cut -d: -f2- | sed 's/-[^-]*$$//')
-
-#if ($project.packaging != "pom" || $project.modules.size() > 0)
-export JAVA_HOME=/usr/lib/jvm/default-java
-export CLASSPATH=$(shell for jar in `cat debian/build-classpath`; do if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; done)
-#if ($project.packaging == "pom" && $project.modules.size() > 0)
-export ANT_ARGS=-Dbasedir=$(realpath .) -Dpackage=$(DEB_SOURCE_PACKAGE) -f debian/build.xml
-#else
-export ANT_ARGS=-Dbasedir=$(realpath .) -Dpackage=$(DEB_SOURCE_PACKAGE) -Dversion=$(DEB_UPSTREAM_VERSION) -f /usr/share/maven-ant-helper/maven-build.xml
-#end
-
-#end
-%:
-#if ($project.packaging == "pom" && $project.modules.size() == 0)
- dh $@ --with maven_repo_helper
-#else
- dh $@ --buildsystem=ant --with maven_repo_helper
-#end
-
-get-orig-source:
- uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/main/resources/rules.ant.vm 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+
+DEB_SOURCE_PACKAGE := $(shell dpkg-parsechangelog | grep '^Source:' | cut -f 2 -d ' ')
+DEB_UPSTREAM_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ' | cut -d: -f2- | sed 's/-[^-]*$$//')
+
+#if ($project.packaging != "pom" || $project.modules.size() > 0)
+export JAVA_HOME=/usr/lib/jvm/default-java
+export CLASSPATH=$(shell for jar in `cat debian/build-classpath`; do if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; done)
+#if ($project.packaging == "pom")
+export ANT_ARGS=-Dbasedir=$(realpath .) -Dpackage=$(DEB_SOURCE_PACKAGE) -Dversion=$(DEB_UPSTREAM_VERSION) -f debian/build.xml
+#else
+export ANT_ARGS=-Dbasedir=$(realpath .) -Dpackage=$(DEB_SOURCE_PACKAGE) -f /usr/share/maven-ant-helper/maven-build.xml
+#end
+
+#end
+%:
+#if ($project.packaging == "pom" && $project.modules.size() == 0)
+ dh $@ --with maven_repo_helper
+#else
+ dh $@ --buildsystem=ant --with maven_repo_helper
+#end
+
+get-orig-source:
+ uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,370 +0,0 @@
-package org.debian.maven.packager;
-
-/*
- * Copyright 2009 Ludovic Claude.
- *
- * 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.
- */
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.debian.maven.repo.DependencyRule;
-import org.debian.maven.repo.ListOfPOMs;
-import org.debian.maven.repo.Repository;
-
-public class DependenciesSolverTest extends TestCase {
-
- private File testDir = new File("tmp");
- private File pomFile = new File(testDir, "pom.xml");
- private List openedReaders = new ArrayList();
-
- protected void setUp() throws Exception {
- super.setUp();
- testDir.mkdirs();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- for (Iterator i = openedReaders.iterator(); i.hasNext(); ) {
- Reader reader = (Reader) i.next();
- try {
- reader.close();
- } catch (IOException ex) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
- }
- }
- openedReaders.clear();
- FileUtils.deleteDirectory(testDir);
- }
-
- /**
- * Test of solveDependencies method, of class DependenciesSolver.
- */
- public void testSolvePlexusActiveCollectionsDependencies() throws Exception {
- useFile("plexus-active-collections/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(true);
- solver.setPackageName("libplexus-active-collections-java");
- solver.setPackageType("maven");
- File listOfPoms = getFileInClasspath("libplexus-active-collections-java.poms");
- solver.setBaseDir(getFileInClasspath("plexus-active-collections/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "libplexus-active-collections-java.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("libplexus-active-collections-java.poms", "libplexus-active-collections-java.poms");
- assertFileEquals("libplexus-active-collections-java.substvars", "libplexus-active-collections-java.substvars");
- assertFileEquals("libplexus-active-collections-java.rules", "maven.rules");
- }
-
- /**
- * Test of solveDependencies method, of class DependenciesSolver.
- */
- public void testSolvePlexusUtils2Dependencies() throws Exception {
- useFile("plexus-utils2/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(true);
- solver.setPackageName("libplexus-utils2-java");
- solver.setPackageType("maven");
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
- File listOfPoms = getFileInClasspath("libplexus-utils2-java.poms");
- solver.setBaseDir(getFileInClasspath("plexus-utils2/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "libplexus-utils2-java.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("libplexus-utils2-java.poms", "libplexus-utils2-java.poms");
- assertFileEquals("libplexus-utils2-java.substvars", "libplexus-utils2-java.substvars");
- assertFileEquals("libplexus-utils2-java.rules", "maven.rules");
- }
-
- /**
- * Test of solveDependencies method, of class DependenciesSolver.
- */
- public void testSolveOpenMRSDependenciesWithErrors() throws Exception {
- useFile("openmrs/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(false);
- solver.setPackageName("openmrs");
- solver.setPackageType("maven");
- //solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
- File listOfPoms = getFileInClasspath("openmrs.poms");
- solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
-
- solver.solveDependencies();
-
- assertEquals(1, solver.getIssues().size());
- assertTrue(solver.getIssues().get(0).toString().indexOf("buildnumber-maven-plugin") > 0);
- }
-
- public void testSolveOpenMRSDependencies() throws Exception {
- useFile("openmrs/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(false);
- solver.setPackageName("openmrs");
- solver.setPackageType("maven");
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.codehaus.mojo buildnumber-maven-plugin * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.mojo build-helper-maven-plugin * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-assembly-plugin * *"));
- File listOfPoms = getFileInClasspath("openmrs.poms");
- solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "openmrs.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("openmrs.poms", "openmrs.poms");
- assertFileEquals("openmrs.substvars", "openmrs.substvars");
- assertFileEquals("openmrs.rules", "maven.rules");
- }
-
- public void testSolveOpenMRSApiDependencies() throws Exception {
- useFile("openmrs/api/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(false);
- solver.setPackageName("openmrs");
- solver.setPackageType("maven");
- solver.setVerbose(true);
- solver.getPomTransformer().addRule(new DependencyRule("cglib s/cglib-nodep/cglib jar s/.*/debian/ * *"));
- // Some dependencies are ignored here because there's a long list of libraries not packaged yet in Debian
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.test openmrs-test * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.codehaus.mojo buildnumber-maven-plugin * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.mojo build-helper-maven-plugin * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-assembly-plugin * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.springframework * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("ca.uhn.hapi hapi * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.simpleframework simple-xml * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.hibernate * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("stax stax* * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("dom4j dom4j * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("c3p0 c3p0 * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("net.sf.ehcache * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("javax.mail mail * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("javax.mail mail * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.liquibase * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("xml-resolver xml-resolver * *"));
- File listOfPoms = getFileInClasspath("openmrs-api.poms");
- solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "openmrs-api.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("openmrs-api.poms", "openmrs-api.poms");
- assertFileEquals("openmrs-api.substvars", "openmrs.substvars");
- assertFileEquals("openmrs-api.rules", "maven.rules");
- }
-
- public void testSolveBuildhelperPluginDependencies() throws Exception {
- useFile("buildhelper-maven-plugin/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(false);
- solver.setPackageName("buildhelper-maven-plugin");
- solver.setPackageType("maven");
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changelog-plugin * * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changes-plugin * * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-checkstyle-plugin * * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-enforcer-plugin * * * *"));
- solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-project-info-reports-plugin * * * *"));
- File listOfPoms = getFileInClasspath("buildhelper-maven-plugin.poms");
- solver.setBaseDir(getFileInClasspath("buildhelper-maven-plugin/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
- solver.setVerbose(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "buildhelper-maven-plugin.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("buildhelper-maven-plugin.poms", "buildhelper-maven-plugin.poms");
- assertFileEquals("buildhelper-maven-plugin.substvars", "buildhelper-maven-plugin.substvars");
- assertFileEquals("buildhelper-maven-plugin.rules", "maven.rules");
- }
-
- // TODO: fix this test
- public void XXXtestSolvePlexusCompilerDependencies() throws Exception {
- useFile("plexus-compiler/pom.xml", pomFile);
- DependenciesSolver solver = new DependenciesSolver();
- solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
- solver.setOutputDirectory(testDir);
- solver.setExploreProjects(false);
- solver.setPackageName("libplexus-compiler-java");
- solver.setPackageType("maven");
-// solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changelog-plugin * * * *"));
-// solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changes-plugin * * * *"));
-// solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-checkstyle-plugin * * * *"));
-// solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-enforcer-plugin * * * *"));
-// solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-project-info-reports-plugin * * * *"));
- File listOfPoms = getFileInClasspath("libplexus-compiler-java.poms");
- solver.setBaseDir(getFileInClasspath("plexus-compiler/pom.xml").getParentFile());
- solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
- solver.setInteractive(false);
- solver.setOffline(true);
- solver.setVerbose(true);
-
- solver.solveDependencies();
-
- assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
-
- solver.setBaseDir(testDir);
- solver.setListOfPoms(new File(testDir, "libplexus-compiler-java.poms"));
-
- solver.saveListOfPoms();
- solver.saveMavenRules();
- solver.saveSubstvars();
-
- assertFileEquals("libplexus-compiler-java.poms", "libplexus-compiler-java.poms");
- assertFileEquals("libplexus-compiler-java.substvars", "libplexus-compiler-java.substvars");
- assertFileEquals("libplexus-compiler-java.rules", "maven.rules");
- }
-
- protected void assertFileEquals(String resource, String fileName) throws Exception {
- File file = new File(testDir, fileName);
- assertTrue(file.exists());
- LineNumberReader fileReader = new LineNumberReader(new FileReader(file));
- LineNumberReader refReader = new LineNumberReader(read(resource));
-
- String ref, test = null;
- boolean skipReadTest = false;
- while (true) {
- if (!skipReadTest) {
- test = fileReader.readLine();
-
- if (test != null && (test.startsWith("#") || test.trim().isEmpty())) {
- continue;
- }
- }
- skipReadTest = false;
-
- ref = refReader.readLine();
- if (ref == null) {
- return;
- }
- if (ref.startsWith("#") || ref.trim().isEmpty()) {
- skipReadTest = true;
- continue;
- }
- assertNotNull("Error in " + fileName + ": expected " + ref.trim() + " but found nothing", test);
- assertEquals("Error in " + fileName, ref.trim(), test.trim());
- }
- }
-
- protected void useFile(String resource, File file) throws IOException {
- final FileWriter out = new FileWriter(file);
- final Reader in = read(resource);
- IOUtils.copy(in,out);
- in.close();
- out.close();
- }
-
- protected Reader read(String resource) {
- Reader r = new InputStreamReader(this.getClass().getResourceAsStream("/" + resource));
- openedReaders.add(r);
- return r;
- }
-
- protected File getFileInClasspath(String resource) {
- if (! resource.startsWith("/")) {
- resource = "/" + resource;
- }
- URL url = this.getClass().getResource(resource);
- File f;
- try {
- f = new File(url.toURI());
- } catch(URISyntaxException e) {
- f = new File(url.getPath());
- }
- return f;
- }
-
-}
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,387 @@
+package org.debian.maven.packager;
+
+/*
+ * Copyright 2009 Ludovic Claude.
+ *
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.Reader;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import junit.framework.TestCase;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.debian.maven.repo.DependencyRule;
+import org.debian.maven.repo.ListOfPOMs;
+import org.debian.maven.repo.Repository;
+
+public class DependenciesSolverTest extends TestCase {
+
+ private File testDir = new File("tmp");
+ private File pomFile = new File(testDir, "pom.xml");
+ private List openedReaders = new ArrayList();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testDir.mkdirs();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ for (Iterator i = openedReaders.iterator(); i.hasNext(); ) {
+ Reader reader = (Reader) i.next();
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ openedReaders.clear();
+ FileUtils.deleteDirectory(testDir);
+ }
+
+ /**
+ * Test of solveDependencies method, of class DependenciesSolver.
+ */
+ public void testSolvePlexusActiveCollectionsDependencies() throws Exception {
+ useFile("plexus-active-collections/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(true);
+ solver.setPackageName("libplexus-active-collections-java");
+ solver.setPackageType("maven");
+ File listOfPoms = getFileInClasspath("libplexus-active-collections-java.poms");
+ solver.setBaseDir(getFileInClasspath("plexus-active-collections/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "libplexus-active-collections-java.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("libplexus-active-collections-java.poms", "libplexus-active-collections-java.poms");
+ assertFileEquals("libplexus-active-collections-java.substvars", "libplexus-active-collections-java.substvars");
+ assertFileEquals("libplexus-active-collections-java.rules", "maven.rules");
+ }
+
+ /**
+ * Test of solveDependencies method, of class DependenciesSolver.
+ */
+ public void testSolvePlexusUtils2Dependencies() throws Exception {
+ useFile("plexus-utils2/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(true);
+ solver.setPackageName("libplexus-utils2-java");
+ solver.setPackageType("maven");
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
+ File listOfPoms = getFileInClasspath("libplexus-utils2-java.poms");
+ solver.setBaseDir(getFileInClasspath("plexus-utils2/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "libplexus-utils2-java.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("libplexus-utils2-java.poms", "libplexus-utils2-java.poms");
+ assertFileEquals("libplexus-utils2-java.substvars", "libplexus-utils2-java.substvars");
+ assertFileEquals("libplexus-utils2-java.rules", "maven.rules");
+ }
+
+ /**
+ * Test of solveDependencies method, of class DependenciesSolver.
+ */
+ public void testSolveOpenMRSDependenciesWithErrors() throws Exception {
+ useFile("openmrs/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(false);
+ solver.setPackageName("openmrs");
+ solver.setPackageType("maven");
+ //solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-release-plugin * *"));
+ File listOfPoms = getFileInClasspath("openmrs.poms");
+ solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+
+ solver.solveDependencies();
+
+ assertEquals(1, solver.getIssues().size());
+ assertTrue(solver.getIssues().get(0).toString().indexOf("buildnumber-maven-plugin") > 0);
+ }
+
+ public void testSolveOpenMRSDependencies() throws Exception {
+ useFile("openmrs/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(false);
+ solver.setPackageName("openmrs");
+ solver.setPackageType("maven");
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.codehaus.mojo buildnumber-maven-plugin * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.mojo build-helper-maven-plugin * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-assembly-plugin * *"));
+ File listOfPoms = getFileInClasspath("openmrs.poms");
+ solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "openmrs.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("openmrs.poms", "openmrs.poms");
+ assertFileEquals("openmrs.substvars", "openmrs.substvars");
+ assertFileEquals("openmrs.rules", "maven.rules");
+ }
+
+ public void testSolveOpenMRSApiDependencies() throws Exception {
+ useFile("openmrs/api/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(false);
+ solver.setPackageName("openmrs");
+ solver.setPackageType("maven");
+ solver.setVerbose(true);
+ solver.getPomTransformer().addRule(new DependencyRule("cglib s/cglib-nodep/cglib jar s/.*/debian/ * *"));
+ // Some dependencies are ignored here because there's a long list of libraries not packaged yet in Debian
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.test openmrs-test * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.codehaus.mojo buildnumber-maven-plugin * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.mojo build-helper-maven-plugin * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-assembly-plugin * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.springframework * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("ca.uhn.hapi hapi * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.simpleframework simple-xml * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.hibernate * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("stax stax* * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("dom4j dom4j * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("c3p0 c3p0 * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("net.sf.ehcache * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("javax.mail mail * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("javax.mail mail * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.openmrs.liquibase * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("xml-resolver xml-resolver * *"));
+ File listOfPoms = getFileInClasspath("openmrs-api.poms");
+ solver.setBaseDir(getFileInClasspath("openmrs/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "openmrs-api.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("openmrs-api.poms", "openmrs-api.poms");
+ assertFileEquals("openmrs-api.substvars", "openmrs.substvars");
+ assertFileEquals("openmrs-api.rules", "maven.rules");
+ }
+
+ public void testSolveBuildhelperPluginDependencies() throws Exception {
+ useFile("buildhelper-maven-plugin/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ solver.setExploreProjects(false);
+ solver.setPackageName("buildhelper-maven-plugin");
+ solver.setPackageType("maven");
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changelog-plugin * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-changes-plugin * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-checkstyle-plugin * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-enforcer-plugin * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-project-info-reports-plugin * * * *"));
+ File listOfPoms = getFileInClasspath("buildhelper-maven-plugin.poms");
+ solver.setBaseDir(getFileInClasspath("buildhelper-maven-plugin/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+ solver.setVerbose(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "buildhelper-maven-plugin.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("buildhelper-maven-plugin.poms", "buildhelper-maven-plugin.poms");
+ assertFileEquals("buildhelper-maven-plugin.substvars", "buildhelper-maven-plugin.substvars");
+ assertFileEquals("buildhelper-maven-plugin.rules", "maven.rules");
+ }
+
+ public void testSolvePlexusCompilerDependencies() throws Exception {
+ useFile("plexus-compiler/pom.xml", pomFile);
+ DependenciesSolver solver = new DependenciesSolver();
+ solver.setMavenRepo(getFileInClasspath("repository/root.dir").getParentFile());
+ solver.setOutputDirectory(testDir);
+ // libplexus-compiler-java.poms already contains some POMs but we want to discover them all
+ solver.setExploreProjects(true);
+ solver.setPackageName("libplexus-compiler-java");
+ solver.setPackageType("maven");
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("junit junit jar s/3\\..*/3.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-api jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-aspectj jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-csharp jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-eclipse jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-javac jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-jikes jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-manager jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-test jar s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler pom s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compilers pom s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-components pom s/1\\..*/1.x/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-container-default jar s/1\\.0-alpha.*/1.0-alpha/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("s/org.eclipse.jdt/org.eclipse.jdt.core.compiler/ s/core/ecj/ jar s/.*/debian/ * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-gpg-plugin * * * *"));
+ // Ignore those plugins for Ant builds
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-component-metadata * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven maven-artifact-test * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.apache.maven.plugins maven-surefire-plugin * * * *"));
+ solver.getPomTransformer().addIgnoreRule(new DependencyRule("org.codehaus.plexus plexus-compiler-test * * * *"));
+
+ File listOfPoms = getFileInClasspath("libplexus-compiler-java.poms");
+ solver.setBaseDir(getFileInClasspath("plexus-compiler/pom.xml").getParentFile());
+ solver.setListOfPoms(new File(listOfPoms.getParent(), listOfPoms.getName()));
+ solver.setInteractive(false);
+ solver.setOffline(true);
+ solver.setRunTests(true);
+ solver.setVerbose(true);
+
+ solver.solveDependencies();
+
+ assertTrue("Did not expect any issues", solver.getIssues().isEmpty());
+
+ solver.setBaseDir(testDir);
+ solver.setListOfPoms(new File(testDir, "libplexus-compiler-java.poms"));
+
+ solver.saveListOfPoms();
+ solver.saveMavenRules();
+ solver.saveSubstvars();
+
+ assertFileEquals("libplexus-compiler-java.poms", "libplexus-compiler-java.poms");
+ assertFileEquals("libplexus-compiler-java.substvars", "libplexus-compiler-java.substvars");
+ assertFileEquals("libplexus-compiler-java.rules", "maven.rules");
+ }
+
+ protected void assertFileEquals(String resource, String fileName) throws Exception {
+ File file = new File(testDir, fileName);
+ assertTrue(file.exists());
+ LineNumberReader fileReader = new LineNumberReader(new FileReader(file));
+ LineNumberReader refReader = new LineNumberReader(read(resource));
+
+ String ref, test = null;
+ boolean skipReadTest = false;
+ while (true) {
+ if (!skipReadTest) {
+ test = fileReader.readLine();
+
+ if (test != null && (test.startsWith("#") || test.trim().isEmpty())) {
+ continue;
+ }
+ }
+ skipReadTest = false;
+
+ ref = refReader.readLine();
+ if (ref == null) {
+ return;
+ }
+ if (ref.startsWith("#") || ref.trim().isEmpty()) {
+ skipReadTest = true;
+ continue;
+ }
+ assertNotNull("Error in " + fileName + ": expected " + ref.trim() + " but found nothing", test);
+ assertEquals("Error in " + fileName, ref.trim(), test.trim());
+ }
+ }
+
+ protected void useFile(String resource, File file) throws IOException {
+ final FileWriter out = new FileWriter(file);
+ final Reader in = read(resource);
+ IOUtils.copy(in,out);
+ in.close();
+ out.close();
+ }
+
+ protected Reader read(String resource) {
+ Reader r = new InputStreamReader(this.getClass().getResourceAsStream("/" + resource));
+ openedReaders.add(r);
+ return r;
+ }
+
+ protected File getFileInClasspath(String resource) {
+ if (! resource.startsWith("/")) {
+ resource = "/" + resource;
+ }
+ URL url = this.getClass().getResource(resource);
+ File f;
+ try {
+ f = new File(url.toURI());
+ } catch(URISyntaxException e) {
+ f = new File(url.getPath());
+ }
+ return f;
+ }
+
+}
Deleted: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,2 +0,0 @@
-pom.xml --no-parent
-plexus-compiler-api/pom.xml
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.poms 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,4 @@
+pom.xml
+plexus-compiler-api/pom.xml
+plexus-compilers/plexus-compiler-aspectj/pom.xml --ignore
+plexus-compiler-test/pom.xml --ignore
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.result.poms (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-compiler-java.result.poms)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.result.poms (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.result.poms 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,37 @@
+# List of POM files for the package
+# Format of this file is:
+# <path to pom file> [option]*
+# where option can be:
+# --ignore: ignore this POM and its artifact if any
+# --ignore-pom: don't install the POM. To use on POM files that are created
+# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms]
+# --no-parent: remove the <parent> tag from the POM
+# --package=<package>: an alternative package to use when installing this POM
+# and its artifact
+# --has-package-version: to indicate that the original version of the POM is the same as the upstream part
+# of the version for the package.
+# --keep-elements=<elem1,elem2>: a list of XML elements to keep in the POM
+# during a clean operation with mh_cleanpom or mh_installpom
+# --artifact=<path>: path to the build artifact associated with this POM,
+# it will be installed when using the command mh_install. [mh_install]
+# --java-lib: install the jar into /usr/share/java to comply with Debian
+# packaging guidelines
+# --usj-name=<name>: name to use when installing the library in /usr/share/java
+# --usj-version=<version>: version to use when installing the library in /usr/share/java
+# --no-usj-versionless: don't install the versionless link in /usr/share/java
+# --dest-jar=<path>: the destination for the real jar.
+# It will be installed with mh_install. [mh_install]
+# --classifier=<classifier>: Optional, the classifier for the jar. Empty by default.
+# --site-xml=<location>: Optional, the location for site.xml if it needs to be installed.
+# Empty by default. [mh_install]
+#
+pom.xml
+plexus-compiler-api/pom.xml
+plexus-compilers/plexus-compiler-aspectj/pom.xml --ignore
+plexus-compiler-test/pom.xml --ignore
+plexus-compiler-manager/pom.xml
+plexus-compilers/pom.xml
+plexus-compilers/plexus-compiler-csharp/pom.xml
+plexus-compilers/plexus-compiler-eclipse/pom.xml
+plexus-compilers/plexus-compiler-jikes/pom.xml
+plexus-compilers/plexus-compiler-javac/pom.xml
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.rules (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-compiler-java.rules)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.rules (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.rules 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,21 @@
+# Maven rules - transform Maven dependencies and plugins
+# Format of this file is:
+# [group] [artifact] [type] [version] [classifier] [scope]
+# where each element can be either
+# - the exact string, for example org.apache for the group, or 3.1
+# for the version. In this case, the element is simply matched
+# and left as it is
+# - * (the star character, alone). In this case, anything will
+# match and be left as it is. For example, using * on the
+# position of the artifact field will match any artifact id
+# - a regular expression of the form s/match/replace/
+# in this case, elements that match are transformed using
+# the regex rule.
+# All elements much match before a rule can be applied
+# Example rule: match jar with groupid= junit, artifactid= junit
+# and version starting with 3., replacing the version with 3.x
+# junit junit jar s/3\..*/3.x/
+
+junit junit jar s/3\..*/3.x/ * *
+org.codehaus.plexus plexus-components pom s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-container-default jar s/1\.0-alpha.*/1.0-alpha/ * *
Copied: tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.substvars (from rev 15734, trunk/maven-debian-helper/maven-packager-utils/src/test/resources/libplexus-compiler-java.substvars)
===================================================================
--- tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.substvars (rev 0)
+++ tags/maven-debian-helper/1.5/maven-packager-utils/src/test/resources/libplexus-compiler-java.substvars 2012-01-24 23:09:55 UTC (rev 15740)
@@ -0,0 +1,5 @@
+#List of dependencies for libplexus-compiler-java, generated for use by debian/control
+maven.CompileDepends=
+maven.Depends=libplexus-components-java (>= 1.1.18), libplexus-utils-java (>= 1.5.15)
+maven.OptionalDepends=
+maven.TestDepends=
Modified: tags/maven-debian-helper/1.5/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml 2012-01-23 00:37:30 UTC (rev 15733)
+++ tags/maven-debian-helper/1.5/pom.xml 2012-01-24 23:09:55 UTC (rev 15740)
@@ -1,97 +1,87 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-debian</artifactId>
- <version>1.5</version>
- <packaging>pom</packaging>
- <name>helper tools for using Maven to build Debian packages</name>
-
- <modules>
- <module>maven-debian-helper</module>
- <module>maven-debian-plugin</module>
- <module>maven-build-nodocs</module>
- <module>maven-packager-utils</module>
- </modules>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.5.8</version>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.debian.maven</groupId>
- <artifactId>maven-repo-helper</artifactId>
- <version>1.7.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>classworlds</groupId>
- <artifactId>classworlds</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
+<?xml version='1.0' encoding='UTF-8'?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-debian</artifactId>
+ <version>1.5</version>
+ <packaging>pom</packaging>
+ <properties>
+ <debian.hasPackageVersion/>
+ <debian.org.apache.maven.maven-compat.originalVersion>2.2.1</debian.org.apache.maven.maven-compat.originalVersion>
+ <debian.org.apache.maven.maven-core.originalVersion>2.2.1</debian.org.apache.maven.maven-core.originalVersion>
+ <debian.org.codehaus.plexus.plexus-utils.originalVersion>1.5.8</debian.org.codehaus.plexus.plexus-utils.originalVersion>
+ <debian.originalVersion>1.5</debian.originalVersion>
+ <debian.package>maven-debian-helper</debian.package>
+ </properties>
+
+ <name>helper tools for using Maven to build Debian packages</name>
+ <modules>
+ <module>maven-debian-helper</module>
+ <module>maven-debian-plugin</module>
+ <module>maven-build-nodocs</module>
+ <module>maven-packager-utils</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>debian</version>
+ </dependency>
+ </dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.debian.maven</groupId>
+ <artifactId>maven-repo-helper</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>debian</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.x</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>debian</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
\ No newline at end of file
More information about the pkg-java-commits
mailing list