[pkg-java] r16036 - in trunk/maven-debian-helper: . debian debian-maven-plugin debian-maven-plugin/src/main/java/org/debian/maven/plugin debian-maven-plugin/src/test debian-maven-plugin/src/test/java/org/debian/maven/plugin debian-maven-plugin/src/test/resources debian-maven-plugin/src/test/resources/plexus-compiler debian-maven-plugin/src/test/resources/plexus-compiler/debian debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/target debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/target debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes etc maven-build-nodocs maven-debian-helper maven-packager-utils maven-packager-utils/src/main/java/org/debian/maven/packager maven-packager-utils/src/main/java/org/debian/maven/packager/util maven-packager-utils/src/main/resources maven-packager-utils/src/test/java/org/debian/maven/packager maven-packager-utils/src/test/java/org/debian/maven/packager/util share/cdbs/1/class
Ludovic Claude
ludovicc-guest at alioth.debian.org
Wed May 2 22:28:56 UTC 2012
Author: ludovicc-guest
Date: 2012-05-02 22:28:55 +0000 (Wed, 02 May 2012)
New Revision: 16036
Added:
trunk/maven-debian-helper/debian-maven-plugin/
trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/InstallMojoTest.java
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/libplexus-compiler-java.poms
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/debian/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/debian/maven.rules
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/target/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/target/plexus-compiler-api-1.8.2.jar
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/target/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/target/plexus-compiler-test-1.8.2.jar
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes/
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/pom.xml
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetChangelogVersionResult.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageContainingPatternResult.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageResult.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageVersionResult.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IOUtil.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicenseCheckResult.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicensesScanner.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/NoOutputHandler.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/OutputHandler.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/PackageScanner.java
trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/SharedJarOutputHandler.java
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageContainingPatternResultTest.java
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageResultTest.java
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageVersionResultTest.java
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/LicensesScannerTest.java
Removed:
trunk/maven-debian-helper/maven-debian-plugin/
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/GenerateDebianFilesMojoTest.java
Modified:
trunk/maven-debian-helper/debian-maven-plugin/pom.xml
trunk/maven-debian-helper/debian-maven-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
trunk/maven-debian-helper/debian-maven-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/DirectoryUtilsTest.java
trunk/maven-debian-helper/debian/build.properties
trunk/maven-debian-helper/debian/build.xml
trunk/maven-debian-helper/debian/changelog
trunk/maven-debian-helper/debian/control
trunk/maven-debian-helper/debian/maven-debian-helper.poms
trunk/maven-debian-helper/debian/maven.rules
trunk/maven-debian-helper/debian/rules
trunk/maven-debian-helper/etc/fake-poms.conf
trunk/maven-debian-helper/maven-build-nodocs/pom.xml
trunk/maven-debian-helper/maven-debian-helper/pom.xml
trunk/maven-debian-helper/maven-packager-utils/pom.xml
trunk/maven-debian-helper/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/GenerateDebianFilesMojo.java
trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm
trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java
trunk/maven-debian-helper/pom.xml
trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk
Log:
* d/control: update version constraint on maven-repo-helper
(Closes: #657889)
* Update the build to use junit 4
* Refactor code in maven-packager-util and fix reading of output
from dpkg and apt-file
* Keep improving usability of mh_make (Closes: #638782, #641266)
* Remove Michael Koch from the list of uploaders. Thanks for your
work! (Closes: #654110)
* Remove BSD license from the list of licenses stored in
/usr/share/common-licenses (Closes: #641301)
* When the jar is installed in /usr/share/java, use symlinks in the
repository to avoid duplication of the jar contents (Closes: #665799)
* Rename plugin maven-debian-plugin as debian-maven-plugin to adhere to
Maven naming conventions.
Modified: trunk/maven-debian-helper/debian/build.properties
===================================================================
--- trunk/maven-debian-helper/debian/build.properties 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/build.properties 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,5 +1,6 @@
build.directory=target
build.javaVersion=1.5
javadoc.dir=target/api
+classpath.test=/usr/share/java/junit4.jar
#maven.test.skip=true
Modified: trunk/maven-debian-helper/debian/build.xml
===================================================================
--- trunk/maven-debian-helper/debian/build.xml 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/build.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -43,7 +43,7 @@
<target name="clean">
<cleanmodule dir=""/>
<cleanmodule dir="maven-debian-helper"/>
- <cleanmodule dir="maven-debian-plugin"/>
+ <cleanmodule dir="debian-maven-plugin"/>
<cleanmodule dir="maven-build-nodocs"/>
<cleanmodule dir="maven-packager-utils"/>
</target>
@@ -52,14 +52,14 @@
<packagemodule dir=""/>
<packagemodule dir="maven-debian-helper"/>
<packagemodule dir="maven-build-nodocs"/>
- <package-plugin-module dir="maven-debian-plugin"/>
+ <package-plugin-module dir="debian-maven-plugin"/>
<package-plugin-module dir="maven-packager-utils"/>
</target>
<target name="javadoc">
<javadoc destdir="${javadoc.dir}">
<packageset dir="maven-debian-helper/src/main/java/"/>
- <packageset dir="maven-debian-plugin/src/main/java/"/>
+ <packageset dir="debian-maven-plugin/src/main/java/"/>
<packageset dir="maven-packager-utils/src/main/java/"/>
</javadoc>
</target>
Modified: trunk/maven-debian-helper/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/changelog 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,3 +1,22 @@
+maven-debian-helper (1.5.1) UNRELEASED; urgency=low
+
+ * d/control: update version constraint on maven-repo-helper
+ (Closes: #657889)
+ * Update the build to use junit 4
+ * Refactor code in maven-packager-util and fix reading of output
+ from dpkg and apt-file
+ * Keep improving usability of mh_make (Closes: #638782, #641266)
+ * Remove Michael Koch from the list of uploaders. Thanks for your
+ work! (Closes: #654110)
+ * Remove BSD license from the list of licenses stored in
+ /usr/share/common-licenses (Closes: #641301)
+ * When the jar is installed in /usr/share/java, use symlinks in the
+ repository to avoid duplication of the jar contents (Closes: #665799)
+ * Rename plugin maven-debian-plugin as debian-maven-plugin to adhere to
+ Maven naming conventions.
+
+ -- Ludovic Claude <ludovic.claude at laposte.net> Mon, 30 Jan 2012 23:46:27 +0100
+
maven-debian-helper (1.5) unstable; urgency=low
[ Ludovic Claude ]
Modified: trunk/maven-debian-helper/debian/control
===================================================================
--- trunk/maven-debian-helper/debian/control 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/control 2012-05-02 22:28:55 UTC (rev 16036)
@@ -3,9 +3,9 @@
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
Uploaders: Torsten Werner <twerner at debian.org>, Ludovic Claude <ludovic.claude at laposte.net>,
- Michael Koch <konqueror at gmx.de>, Damien Raude-Morvan <drazzib at debian.org>
+ Damien Raude-Morvan <drazzib at debian.org>
Build-Depends: cdbs, debhelper (>= 7), default-jdk, maven-ant-helper (>= 7.0), ant-optional, help2man
-Build-Depends-Indep: maven-repo-helper (>= 1.7.1), junit, libmaven-plugin-tools-java,
+Build-Depends-Indep: maven-repo-helper (>= 1.7.1), junit4, libmaven-plugin-tools-java,
libplexus-velocity-java, libcommons-io-java
Standards-Version: 3.9.2
Vcs-Svn: svn://svn.debian.org/svn/pkg-java/trunk/maven-debian-helper
@@ -14,7 +14,7 @@
Package: maven-debian-helper
Architecture: all
-Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.5), maven2 (>= 2.2.1-5),
+Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.7.1), maven2 (>= 2.2.1-5),
libmaven-clean-plugin-java, libmaven-resources-plugin-java,
libmaven-compiler-plugin-java, libmaven-jar-plugin-java, libmaven-site-plugin-java,
libsurefire-java, velocity, libplexus-velocity-java
Modified: trunk/maven-debian-helper/debian/maven-debian-helper.poms
===================================================================
--- trunk/maven-debian-helper/debian/maven-debian-helper.poms 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/maven-debian-helper.poms 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,5 +1,5 @@
pom.xml --no-parent --has-package-version
maven-debian-helper/pom.xml --has-package-version --artifact=maven-debian-helper/target/maven-debian-helper-*.jar --java-lib
-maven-debian-plugin/pom.xml --has-package-version --artifact=maven-debian-plugin/target/maven-debian-plugin-*.jar --java-lib
+debian-maven-plugin/pom.xml --has-package-version --artifact=debian-maven-plugin/target/debian-maven-plugin-*.jar --java-lib
maven-build-nodocs/pom.xml --has-package-version --artifact=maven-build-nodocs/target/maven-build-nodocs-*.jar --java-lib
maven-packager-utils/pom.xml --has-package-version --artifact=maven-packager-utils/target/maven-packager-utils-*.jar --java-lib
Modified: trunk/maven-debian-helper/debian/maven.rules
===================================================================
--- trunk/maven-debian-helper/debian/maven.rules 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/maven.rules 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,3 +1,2 @@
-junit junit jar s/3\..*/3.x/
+junit junit jar s/4\..*/4.x/
org.codehaus.plexus plexus-container-default jar s/1\.0-alpha-.*/1.0-alpha/
-
Modified: trunk/maven-debian-helper/debian/rules
===================================================================
--- trunk/maven-debian-helper/debian/rules 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/debian/rules 2012-05-02 22:28:55 UTC (rev 16036)
@@ -56,7 +56,7 @@
# Helper target, to use when updating the version of this package
update-package-version:
perl -p -i -e "s/^ <version>([0-9\.]+<)/ <version>${VERSION}</" pom.xml
- perl -p -i -e "s/^ <version>([0-9\.]+<)/ <version>${VERSION}</" maven-build-nodocs/pom.xml maven-debian-helper/pom.xml maven-debian-plugin/pom.xml
+ perl -p -i -e "s/^ <version>([0-9\.]+<)/ <version>${VERSION}</" maven-build-nodocs/pom.xml maven-debian-helper/pom.xml debian-maven-plugin/pom.xml
perl -p -i -e "s/maven-debian-helper \(>= ([0-9\.]+)\)/maven-debian-helper \(>= ${VERSION})/" share/cdbs/1/class/maven-vars.mk maven-packager-utils/src/main/resources/control.vm
Modified: trunk/maven-debian-helper/debian-maven-plugin/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/pom.xml 2012-04-27 19:38:22 UTC (rev 16022)
+++ trunk/maven-debian-helper/debian-maven-plugin/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -6,10 +6,10 @@
<parent>
<artifactId>maven-debian</artifactId>
<groupId>org.debian.maven</groupId>
- <version>1.5</version>
+ <version>1.5.1</version>
</parent>
- <artifactId>maven-debian-plugin</artifactId>
+ <artifactId>debian-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Maven Debian Plugin</name>
@@ -18,5 +18,10 @@
<groupId>org.debian.maven</groupId>
<artifactId>maven-repo-helper</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: trunk/maven-debian-helper/debian-maven-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java 2012-04-27 19:38:22 UTC (rev 16022)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/main/java/org/debian/maven/plugin/InstallMojo.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -23,50 +23,60 @@
*
* @goal install
*/
-public class InstallMojo extends SysInstallMojo
-{
+public class InstallMojo extends SysInstallMojo {
- /**
- * Maven repository root
- *
- * @parameter expression="${maven.repo.local}"
- */
- private File mavenRepoLocal;
+ /**
+ * Maven repository root
+ *
+ * @parameter expression="${maven.repo.local}"
+ */
+ private File mavenRepoLocal;
/**
- * If true, use local Maven repository for installation
- *
- * @parameter expression="${use.maven.repo.local}"
- */
+ * If true, use local Maven repository for installation
+ *
+ * @parameter expression="${use.maven.repo.local}"
+ */
private boolean useMavenRepoLocal;
- // ----------------------------------------------------------------------
- // Public methods
- // ----------------------------------------------------------------------
+ // ----------------------------------------------------------------------
+ // Public methods
+ // ----------------------------------------------------------------------
- // ----------------------------------------------------------------------
- // Private methods
- // ----------------------------------------------------------------------
+ public File getMavenRepoLocal() {
+ return mavenRepoLocal;
+ }
- /* returns e.g. $CURDIR/debian/libfoobar-java
- */
+ public void setMavenRepoLocal(File mavenRepoLocal) {
+ this.mavenRepoLocal = mavenRepoLocal;
+ }
- protected String packagePath()
- {
- if (useMavenRepoLocal) {
- return mavenRepoLocal.getAbsolutePath();
- } else {
+ public boolean isUseMavenRepoLocal() {
+ return useMavenRepoLocal;
+ }
+
+ public void setUseMavenRepoLocal(boolean useMavenRepoLocal) {
+ this.useMavenRepoLocal = useMavenRepoLocal;
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
+ /**
+ * Returns e.g. $CURDIR/debian/libfoobar-java
+ */
+
+ protected String packagePath() {
return getDebianDir() + "/" + getDestPackage();
}
- }
/**
* absolute path to destination dir
*/
- protected String fullRepoPath()
- {
+ protected String fullRepoPath() {
if (useMavenRepoLocal) {
- return packagePath() + destRepoPath();
+ return mavenRepoLocal.getAbsolutePath() + "/" + destRepoPath();
} else {
return super.fullRepoPath();
}
@@ -75,14 +85,12 @@
/**
* absolute path to destination dir
*/
- protected String debianFullRepoPath()
- {
+ protected String debianFullRepoPath() {
if (useMavenRepoLocal) {
- return packagePath() + debianRepoPath();
+ return mavenRepoLocal.getAbsolutePath() + "/" + debianRepoPath();
} else {
return super.debianFullRepoPath();
}
}
-
}
Modified: trunk/maven-debian-helper/debian-maven-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-04-27 19:38:22 UTC (rev 16022)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -125,7 +125,7 @@
private File debianDir;
/**
- * Debian package (send from commande line)
+ * Debian package (send from command line)
*
* @parameter expression="${debian.package}"
*/
@@ -133,7 +133,7 @@
/**
* Debian package destination (set by xxx.poms file).
- * By defaul, equals to <code>debianPackage</code> attribute.
+ * By default, equals to <code>debianPackage</code> attribute.
*
* @parameter expression="${debian.package}"
*/
@@ -191,38 +191,58 @@
}
}
- // ----------------------------------------------------------------------
- // Private methods
- // ----------------------------------------------------------------------
-
- protected String getArtifactId() {
+ public String getArtifactId() {
return artifactId;
}
- protected String getDestArtifactId() {
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public String getDestArtifactId() {
return destArtifactId;
}
- protected String getVersion() {
+ public void setDestArtifactId(String destArtifactId) {
+ this.destArtifactId = destArtifactId;
+ }
+
+ public String getVersion() {
return version;
}
- protected String getDebianVersion() {
+ public String getDebianVersion() {
return debianVersion;
}
- protected File getDebianDir() {
+ public void setDebianVersion(String debianVersion) {
+ this.debianVersion = debianVersion;
+ }
+
+ public File getDebianDir() {
return debianDir;
}
- protected String getDebianPackage() {
+ public void setDebianDir(File debianDir) {
+ this.debianDir = debianDir;
+ }
+
+ public String getDebianPackage() {
return debianPackage;
}
- protected String getDestPackage() {
+ public void setDebianPackage(String debianPackage) {
+ this.debianPackage = debianPackage;
+ }
+
+ public String getDestPackage() {
return destPackage;
}
+ public void setDestPackage(String destPackage) {
+ this.destPackage = destPackage;
+ }
+
public String getClassifier() {
return classifier;
}
@@ -231,6 +251,102 @@
this.classifier = classifier;
}
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getDestGroupId() {
+ return destGroupId;
+ }
+
+ public void setDestGroupId(String destGroupId) {
+ this.destGroupId = destGroupId;
+ }
+
+ public File getBasedir() {
+ return basedir;
+ }
+
+ public void setBasedir(File basedir) {
+ this.basedir = basedir;
+ }
+
+ public String getJarDir() {
+ return jarDir;
+ }
+
+ public void setJarDir(String jarDir) {
+ this.jarDir = jarDir;
+ }
+
+ public String getFinalName() {
+ return finalName;
+ }
+
+ public void setFinalName(String finalName) {
+ this.finalName = finalName;
+ }
+
+ public String getMavenRules() {
+ return mavenRules;
+ }
+
+ public void setMavenRules(String mavenRules) {
+ this.mavenRules = mavenRules;
+ }
+
+ public File getRepoDir() {
+ return repoDir;
+ }
+
+ public void setRepoDir(File repoDir) {
+ this.repoDir = repoDir;
+ }
+
+ public boolean isInstallToUsj() {
+ return installToUsj;
+ }
+
+ public void setInstallToUsj(boolean installToUsj) {
+ this.installToUsj = installToUsj;
+ }
+
+ public String getUsjName() {
+ return usjName;
+ }
+
+ public void setUsjName(String usjName) {
+ this.usjName = usjName;
+ }
+
+ public String getUsjVersion() {
+ return usjVersion;
+ }
+
+ public void setUsjVersion(String usjVersion) {
+ this.usjVersion = usjVersion;
+ }
+
+ public boolean isNoUsjVersionless() {
+ return noUsjVersionless;
+ }
+
+ public void setNoUsjVersionless(boolean noUsjVersionless) {
+ this.noUsjVersionless = noUsjVersionless;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+
/**
* optional destination prefix, empty by default
*/
@@ -239,21 +355,21 @@
}
/**
- * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
+ * returns e.g. /org/debian/maven/debian-maven-plugin/0.1/
*/
protected final String repoPath() {
return "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
}
/**
- * returns e.g. /org/debian/maven/maven-debian-plugin/0.1/
+ * returns e.g. /org/debian/maven/debian-maven-plugin/0.1/
*/
protected final String destRepoPath() {
return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + version + "/";
}
/**
- * returns e.g. /org/debian/maven/maven-debian-plugin/debian/
+ * returns e.g. /org/debian/maven/debian-maven-plugin/debian/
*/
protected final String debianRepoPath() {
return "/" + destGroupId.replace('.', '/') + "/" + destArtifactId + "/" + debianVersion + "/";
@@ -363,7 +479,7 @@
return destArtifactId + ".jar";
}
- protected final String compatSharePath() {
+ protected String compatSharePath() {
return packagePath() + "/usr/share/java/";
}
@@ -460,11 +576,11 @@
if (jarFile.exists()) {
System.out.println("Install jar for " + artifactId + " into /usr/share/java");
mkdir(compatSharePath());
- FileUtils.copyFile(jarFile, new File(jarDestPath()));
+ FileUtils.copyFile(jarFile, new File(fullCompatPath()));
if (noUsjVersionless) {
- FileUtils.copyFile(jarFile, new File(versionedFullCompatPath()));
+ run(linkCommand(destUsjJarName(), versionedFullCompatPath()));
} else {
- FileUtils.copyFile(jarFile, new File(fullCompatPath()));
+ run(linkCommand(destUsjJarName(), fullCompatPath()));
run(linkCommand(destUsjJarName(), versionedFullCompatPath()));
}
}
Modified: trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/DirectoryUtilsTest.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/src/test/java/org/debian/maven/plugin/DirectoryUtilsTest.java 2012-04-27 19:38:22 UTC (rev 16022)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/DirectoryUtilsTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,7 +1,5 @@
package org.debian.maven.plugin;
-import junit.framework.TestCase;
-
/*
* Copyright 2011 Ludovic Claude.
*
@@ -18,9 +16,13 @@
* limitations under the License.
*/
+import org.junit.Test;
-public class DirectoryUtilsTest extends TestCase {
+import static junit.framework.Assert.assertEquals;
+public class DirectoryUtilsTest {
+
+ @Test
public void testRelativePath() {
assertEquals("../maven-repo/my/test/file.jar", DirectoryUtils.relativePath("/usr/share/java", "/usr/share/maven-repo/my/test/file.jar"));
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/InstallMojoTest.java
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/InstallMojoTest.java (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/java/org/debian/maven/plugin/InstallMojoTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,190 @@
+package org.debian.maven.plugin;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+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 org.apache.commons.io.FileUtils;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
+/*
+ * Copyright 2012 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.
+ */
+
+public class InstallMojoTest {
+
+ private File testDir = new File("tmp");
+ private InstallMojo mojo;
+
+ private List openedReaders = new ArrayList();
+
+ @Before
+ public void setUp() throws Exception {
+ testDir.mkdirs();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ 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);
+
+ File debianDir = getFileInClasspath("plexus-compiler/debian/maven.rules").getParentFile();
+ FileUtils.deleteDirectory(new File(debianDir, "libplexus-compiler-java"));
+ }
+
+ @Test
+ public void testInstallJarToRepo() throws Exception {
+ mojo = new InstallMojo();
+ mojo.setBasedir(getFileInClasspath("plexus-compiler/plexus-compiler-test/pom.xml").getParentFile());
+ mojo.setDebianDir(getFileInClasspath("plexus-compiler/debian/maven.rules").getParentFile());
+ mojo.setDestGroupId("org.codehaus.plexus");
+ mojo.setGroupId("org.codehaus.plexus");
+ mojo.setArtifactId("plexus-compiler-test");
+ mojo.setDestArtifactId("plexus-compiler-test");
+ mojo.setInstallToUsj(false);
+ mojo.setJarDir(getFileInClasspath("plexus-compiler/plexus-compiler-test/target/plexus-compiler-test-1.8.2.jar").getParentFile().getAbsolutePath());
+ mojo.setMavenRules("maven.rules");
+ mojo.setNoUsjVersionless(false);
+ mojo.setDebianPackage("libplexus-compiler-java");
+ mojo.setDestPackage("libplexus-compiler-java");
+ mojo.setVersion("1.8.2");
+ mojo.setDebianVersion("1.x");
+
+ mojo.execute();
+
+ File versionedRepoJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-test/1.8.2/plexus-compiler-test-1.8.2.jar");
+ assertNotNull(versionedRepoJar);
+ File versionedRepoPom = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-test/1.8.2/plexus-compiler-test-1.8.2.pom");
+ assertNotNull(versionedRepoPom);
+
+ File debianRepoJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-test/1.x/plexus-compiler-test-1.x.jar");
+ assertNotNull(debianRepoJar);
+ assertEquals(versionedRepoJar, debianRepoJar.getCanonicalFile());
+ File debianRepoPom = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-test/1.x/plexus-compiler-test-1.x.pom");
+ assertNotNull(debianRepoPom);
+ }
+
+ // Bug#665799: maven-debian-helper: jar files installed to /usr/share/java AND /usr/share/maven-repo
+ @Test
+ public void testInstallJarToRepoAndUsj() throws Exception {
+ mojo = new InstallMojo();
+ mojo.setBasedir(getFileInClasspath("plexus-compiler/plexus-compiler-api/pom.xml").getParentFile());
+ mojo.setDebianDir(getFileInClasspath("plexus-compiler/debian/maven.rules").getParentFile());
+ mojo.setDestGroupId("org.codehaus.plexus");
+ mojo.setGroupId("org.codehaus.plexus");
+ mojo.setArtifactId("plexus-compiler-api");
+ mojo.setDestArtifactId("plexus-compiler-api");
+ //mojo.setFinalName("plexus-compiler-api");
+ mojo.setInstallToUsj(true);
+ mojo.setJarDir(getFileInClasspath("plexus-compiler/plexus-compiler-api/target/plexus-compiler-api-1.8.2.jar").getParentFile().getAbsolutePath());
+ mojo.setMavenRules("maven.rules");
+ mojo.setNoUsjVersionless(false);
+ mojo.setDebianPackage("libplexus-compiler-java");
+ mojo.setDestPackage("libplexus-compiler-java");
+ mojo.setVersion("1.8.2");
+ mojo.setDebianVersion("1.x");
+
+ mojo.execute();
+
+ File usjJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/java/plexus-compiler-api.jar");
+ assertNotNull(usjJar);
+ File versionedUsjJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/java/plexus-compiler-api-1.8.2.jar");
+ assertNotNull(versionedUsjJar);
+ assertEquals(usjJar, versionedUsjJar.getCanonicalFile());
+
+ File versionedRepoJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-api/1.8.2/plexus-compiler-api-1.8.2.jar");
+ assertNotNull(versionedRepoJar);
+ assertEquals(usjJar, versionedRepoJar.getCanonicalFile());
+ File versionedRepoPom = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-api/1.8.2/plexus-compiler-api-1.8.2.pom");
+ assertNotNull(versionedRepoPom);
+
+ File debianRepoJar = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-api/1.x/plexus-compiler-api-1.x.jar");
+ assertNotNull(debianRepoJar);
+ assertEquals(usjJar, debianRepoJar.getCanonicalFile());
+ File debianRepoPom = getFileInClasspath("plexus-compiler/debian/libplexus-compiler-java/usr/share/maven-repo/org/codehaus/plexus/plexus-compiler-api/1.x/plexus-compiler-api-1.x.pom");
+ assertNotNull(debianRepoPom);
+
+ }
+
+ @Test
+ public void testInstallJarToLocalRepo() throws Exception {
+ mojo = new InstallMojo();
+ mojo.setMavenRepoLocal(new File(testDir, "repo"));
+ mojo.setUseMavenRepoLocal(true);
+ mojo.setBasedir(getFileInClasspath("plexus-compiler/plexus-compiler-test/pom.xml").getParentFile());
+ mojo.setDebianDir(getFileInClasspath("plexus-compiler/debian/maven.rules").getParentFile());
+ mojo.setDestGroupId("org.codehaus.plexus");
+ mojo.setGroupId("org.codehaus.plexus");
+ mojo.setArtifactId("plexus-compiler-test");
+ mojo.setDestArtifactId("plexus-compiler-test");
+ mojo.setInstallToUsj(false);
+ mojo.setJarDir(getFileInClasspath("plexus-compiler/plexus-compiler-test/target/plexus-compiler-test-1.8.2.jar").getParentFile().getAbsolutePath());
+ mojo.setMavenRules("maven.rules");
+ mojo.setNoUsjVersionless(false);
+ mojo.setDebianPackage("libplexus-compiler-java");
+ mojo.setDestPackage("libplexus-compiler-java");
+ mojo.setVersion("1.8.2");
+ mojo.setDebianVersion("1.x");
+
+ mojo.execute();
+
+ File versionedRepoJar = new File(testDir, "repo/org/codehaus/plexus/plexus-compiler-test/1.8.2/plexus-compiler-test-1.8.2.jar");
+ assertNotNull(versionedRepoJar);
+ File versionedRepoPom = new File(testDir, "repo/org/codehaus/plexus/plexus-compiler-test/1.8.2/plexus-compiler-test-1.8.2.pom");
+ assertNotNull(versionedRepoPom);
+
+ File debianRepoJar = new File(testDir, "repo/org/codehaus/plexus/plexus-compiler-test/1.x/plexus-compiler-test-1.x.jar");
+ assertNotNull(debianRepoJar);
+ assertEquals(versionedRepoJar.getAbsoluteFile(), debianRepoJar.getCanonicalFile());
+ File debianRepoPom = new File(testDir, "repo/org/codehaus/plexus/plexus-compiler-test/1.x/plexus-compiler-test-1.x.pom");
+ assertNotNull(debianRepoPom);
+ }
+
+
+ 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;
+ }
+
+}
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/libplexus-compiler-java.poms
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/libplexus-compiler-java.poms (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/libplexus-compiler-java.poms 2012-05-02 22:28:55 UTC (rev 16036)
@@ -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
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/debian/maven.rules
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/debian/maven.rules (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/debian/maven.rules 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,14 @@
+junit junit jar s/3\..*/3.x/ * *
+org.codehaus.plexus plexus-compiler-api jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-aspectj jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-csharp jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-eclipse jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-javac jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-jikes jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-manager jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler-test jar s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compiler pom s/1\..*/1.x/ * *
+org.codehaus.plexus plexus-compilers pom s/1\..*/1.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/ * *
+s/org.eclipse.jdt/org.eclipse.jdt.core.compiler/ s/core/ecj/ jar s/.*/debian/ * *
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,25 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-api</artifactId>
+
+ <name>Plexus Compiler Api</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-api/target/plexus-compiler-api-1.8.2.jar
===================================================================
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-manager/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,21 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-manager</artifactId>
+
+ <name>Plexus Compiler Manager</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,57 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-test</artifactId>
+
+ <name>Plexus Compiler Test Harness</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact-test</artifactId>
+ <version>2.0.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact-manager</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <!-- This just needs to be present in the local repository for tests to pass. It would be preferable for the tests to resolve it directly -->
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compiler-test/target/plexus-compiler-test-1.8.2.jar
===================================================================
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-aspectj/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,27 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-aspectj</artifactId>
+
+ <name>Plexus AspectJ Compiler</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-csharp/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,21 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-csharp</artifactId>
+
+ <name>Plexus C# Compiler</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-eclipse/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,44 @@
+<?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>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-eclipse</artifactId>
+
+ <name>Plexus Eclipse Compiler</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt</groupId>
+ <artifactId>core</artifactId>
+ <version>3.3.0-v_771</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>resources</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>runtime</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.core</groupId>
+ <artifactId>filesystem</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse</groupId>
+ <artifactId>text</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-javac/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,22 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-javac</artifactId>
+
+ <name>Plexus Javac Component</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/plexus-compiler-jikes/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,57 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <artifactId>plexus-compiler-jikes</artifactId>
+
+ <name>Plexus Jikes Compiler</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>jikes-enabled</id>
+ <activation>
+ <property>
+ <name>jikes-enabled</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/plexus-compilers/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler</artifactId>
+ <version>1.8.2</version>
+ </parent>
+
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compilers</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Plexus Compilers</name>
+
+ <modules>
+ <module>plexus-compiler-aspectj</module>
+ <module>plexus-compiler-csharp</module>
+ <module>plexus-compiler-eclipse</module>
+ <module>plexus-compiler-jikes</module>
+ <module>plexus-compiler-javac</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/pom.xml
===================================================================
--- trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/pom.xml (rev 0)
+++ trunk/maven-debian-helper/debian-maven-plugin/src/test/resources/plexus-compiler/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,119 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-components</artifactId>
+ <version>1.1.18</version>
+ </parent>
+
+ <artifactId>plexus-compiler</artifactId>
+ <version>1.8.2</version>
+ <packaging>pom</packaging>
+
+ <name>Plexus Compiler</name>
+
+ <modules>
+ <module>plexus-compiler-api</module>
+ <module>plexus-compiler-test</module>
+ <module>plexus-compiler-manager</module>
+ <module>plexus-compilers</module>
+ </modules>
+
+ <scm>
+ <connection>scm:git:git at github.com:sonatype/plexus-compiler.git</connection>
+ <developerConnection>scm:git:git at github.com:sonatype/plexus-compiler.git</developerConnection>
+ <url>http://github.com/sonatype/plexus-compiler</url>
+ </scm>
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.codehaus.org/browse/PLXCOMP/component/12541</url>
+ </issueManagement>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-compiler-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9-stable-1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <version>1.5.1</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ <goal>merge-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.2</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <!--
+ Make sure maven.repo.local is passed through to the tests if set or the tests will fail to resolve artifacts
+ (c.f. SUREFIRE-491).
+ -->
+ <id>maven.repo.local</id>
+ <activation>
+ <property>
+ <name>maven.repo.local</name>
+ </property>
+ </activation>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties combine.children="append">
+ <property>
+ <name>maven.repo.local</name>
+ <value>${maven.repo.local}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
+</project>
Modified: trunk/maven-debian-helper/etc/fake-poms.conf
===================================================================
--- trunk/maven-debian-helper/etc/fake-poms.conf 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/etc/fake-poms.conf 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,9 +1,6 @@
commons-el commons-el
easymock easymock
gnu-getopt getopt /usr/share/java/gnu-getopt.jar
-javax.activation activation /usr/share/java/glassfish-activation.jar
-javax.ejb ejb-api /usr/share/java/glassfish-ejb-api.jar
-javax.mail mail /usr/share/java/glassfish-mail.jar
jboss.common jboss-common
jmock jmock
org.apache.geronimo.specs specs
Modified: trunk/maven-debian-helper/maven-build-nodocs/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-build-nodocs/pom.xml 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-build-nodocs/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.debian.maven</groupId>
<artifactId>maven-debian</artifactId>
- <version>1.5</version>
+ <version>1.5.1</version>
</parent>
<artifactId>maven-build-nodocs</artifactId>
Modified: trunk/maven-debian-helper/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/pom.xml 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-debian-helper/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.debian.maven</groupId>
<artifactId>maven-debian</artifactId>
- <version>1.5</version>
+ <version>1.5.1</version>
</parent>
<artifactId>maven-debian-helper</artifactId>
Modified: trunk/maven-debian-helper/maven-packager-utils/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/pom.xml 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -6,7 +6,7 @@
<parent>
<artifactId>maven-debian</artifactId>
<groupId>org.debian.maven</groupId>
- <version>1.5</version>
+ <version>1.5.1</version>
</parent>
<artifactId>maven-packager-utils</artifactId>
Modified: trunk/maven-debian-helper/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-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -17,7 +17,6 @@
* limitations under the License.
*/
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
@@ -27,10 +26,6 @@
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;
@@ -38,6 +33,7 @@
import javax.xml.stream.XMLStreamException;
+import org.debian.maven.packager.util.*;
import org.debian.maven.repo.Dependency;
import org.debian.maven.repo.DependencyNotFoundException;
import org.debian.maven.repo.DependencyRule;
@@ -49,6 +45,8 @@
import org.debian.maven.repo.Repository;
import org.debian.maven.repo.Rule;
+import static org.debian.maven.packager.util.IOUtil.readLine;
+
/**
* Analyze the Maven dependencies and extract the Maven rules to use
* as well as the list of dependent packages.
@@ -170,13 +168,14 @@
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
+ // Keep the original POMs for reference
+ private Map<String, POMInfo> originalPomInfoCache = 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>();
+ private PackageScanner scanner = new PackageScanner();
public DependenciesSolver() {
pomTransformer.setVerbose(true);
@@ -230,6 +229,7 @@
public void setOffline(boolean offline) {
this.offline = offline;
+ scanner.setOffline(offline);
}
public boolean isGenerateJavadoc() {
@@ -351,8 +351,10 @@
public void resolve() {
try {
resolveDependencies(sourcePom, listType, buildTime, mavenExtension, management);
- } catch (Exception e) {
+ } catch (DependencyNotFoundException e) {
log.log(Level.SEVERE, "Cannot resolve dependencies in " + sourcePom + ": " + e.getMessage());
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "Cannot resolve dependencies in " + sourcePom + ": " + e.getMessage(), e);
}
}
}
@@ -407,7 +409,7 @@
if (runtimeDependency != null && "pom".equals(runtimeDependency.getType())) {
continue;
}
- String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
+ String docPkg = scanner.searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
if (docPkg != null) {
docRuntimeDepends.add(docPkg);
}
@@ -421,7 +423,7 @@
if (optionalDependency != null && "pom".equals(optionalDependency.getType())) {
continue;
}
- String docPkg = searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
+ String docPkg = scanner.searchPkg(new File("/usr/share/doc/" + dependency + "/api/index.html"));
if (docPkg != null) {
docOptionalDepends.add(docPkg);
}
@@ -698,6 +700,7 @@
if (interactive && !explicitlyMentionedInRules && !"maven-plugin".equals(pom.getThisPom().getType())) {
String version = pom.getThisPom().getVersion();
+ System.out.println();
System.out.println("Version of " + pom.getThisPom().getGroupId() + ":"
+ pom.getThisPom().getArtifactId() + " is " + version);
System.out.println("Choose how it will be transformed:");
@@ -836,6 +839,17 @@
return info;
}
+ private POMInfo getOriginalPOM(File projectPom) throws XMLStreamException, IOException {
+ POMInfo info = originalPomInfoCache.get(projectPom.getAbsolutePath());
+ if (info != null) {
+ return info;
+ }
+
+ info = pomTransformer.readPom(projectPom);
+ originalPomInfoCache.put(projectPom.getAbsolutePath(), info);
+ return info;
+ }
+
private ListOfPOMs.POMOptions getPOMOptions(File pom) {
return pomTransformer.getListOfPOMs().getOrCreatePOMOptions(pom);
}
@@ -844,16 +858,6 @@
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();
@@ -991,7 +995,8 @@
} 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());
+ Dependency originalParent = getOriginalPOM(sourcePom).getParent();
+ 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 " + originalParent);
}
}
}
@@ -1132,11 +1137,11 @@
}
return null;
} else {
- String pkg = searchPkg(new File("/usr/share/maven-repo/"
+ String pkg = scanner.searchPkg(new File("/usr/share/maven-repo/"
+ dependency.getGroupId().replace('.', '/')
+ "/" + dependency.getArtifactId()), ".pom");
if (pkg != null) {
- String installedVersion = getPackageVersion(pkg, true);
+ String installedVersion = scanner.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.");
@@ -1148,7 +1153,7 @@
}
}
if (interactive && pkg == null) {
- pkg = searchPkg(new File("/usr/share/java/" + dependency.getArtifactId() + ".jar"));
+ pkg = scanner.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");
@@ -1163,13 +1168,24 @@
}
} 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.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()) {
+ while (!newRule.isEmpty()) {
DependencyRule userRule = new DependencyRule(newRule);
- pomTransformer.getRules().add(userRule);
- return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
+ Dependency newDependency = dependency.applyRules(Arrays.asList(userRule));
+ if (newDependency.equals(dependency)) {
+ System.out.println("Your rule doesn't seem to apply on " + dependency);
+ System.out.println("Please enter a substitution rule of the form s/groupId/newGroupId/ s/artifactId/newArtifactId/ jar s/version/newVersion/ here,");
+ System.out.println("or press <Enter> to give up");
+ System.out.print("> ");
+ newRule = readLine().trim();
+ } else {
+ pomTransformer.getRules().add(userRule);
+ System.out.println("Rescanning /usr/share/maven-repo...");
+ pomTransformer.getRepository().scan();
+ return resolveDependency(dependency.applyRules(Arrays.asList(userRule)), sourcePom, buildTime, mavenExtension, management);
+ }
}
}
}
@@ -1181,7 +1197,9 @@
System.out.println("Rescanning /usr/share/maven-repo...");
pomTransformer.getRepository().scan();
// Clear caches
- filesInPackages.clear();
+ scanner = new PackageScanner();
+ scanner.setOffline(offline);
+
return resolveDependency(dependency, sourcePom, buildTime, mavenExtension, management);
}
}
@@ -1276,27 +1294,11 @@
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);
+ pkg = scanner.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)) {
@@ -1306,102 +1308,6 @@
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();) {
@@ -1414,111 +1320,6 @@
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).");
@@ -1626,6 +1427,7 @@
solver.saveSubstvars();
if (!solver.getIssues().isEmpty()) {
+ System.err.println("Some problems where found in this project, exiting...");
System.exit(1);
}
}
Modified: trunk/maven-debian-helper/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-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -28,8 +28,14 @@
import org.apache.maven.project.MavenProject;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
+import org.debian.maven.packager.util.LicensesScanner;
+import org.debian.maven.packager.util.NoOutputHandler;
+import org.debian.maven.packager.util.OutputHandler;
+import org.debian.maven.packager.util.PackageScanner;
import org.debian.maven.repo.ListOfPOMs;
+import static org.debian.maven.packager.util.IOUtil.readLine;
+
/**
* Generate the Debian files for packaging the current Maven project.
*
@@ -122,6 +128,9 @@
*/
protected boolean generateJavadoc;
+ private PackageScanner scanner = new PackageScanner();
+ private LicensesScanner licensesScanner = new LicensesScanner();
+
public void execute()
throws MojoExecutionException {
File f = outputDirectory;
@@ -165,7 +174,7 @@
project.setUrl(readLine());
}
- Set licenses = discoverLicenses();
+ Set licenses = licensesScanner.discoverLicenses(project.getLicenses());
context.put("licenses", licenses);
if (licenses.size() == 1) {
@@ -321,13 +330,13 @@
Set compileJars = new TreeSet();
for (Iterator i = compileDepends.iterator(); i.hasNext();) {
String library = (String) i.next();
- compileJars.addAll(listSharedJars(library));
+ compileJars.addAll(scanner.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));
+ testJars.addAll(scanner.listSharedJars(library));
}
context.put("testJars", testJars);
}
@@ -396,7 +405,7 @@
generateFile(context, "watch.svn.vm", outputDirectory, "watch");
generateFile(context, "orig-tar.svn.vm", outputDirectory, "orig-tar.sh");
- makeExecutable("debian/orig-tar.sh");
+ scanner.makeExecutable("debian/orig-tar.sh");
} else {
System.err.println("Cannot locate the version in the download url (" +
@@ -416,7 +425,7 @@
generateFile(context, "compat.vm", outputDirectory, "compat");
generateFile(context, rulesTemplate, outputDirectory, "rules");
- makeExecutable("debian/rules");
+ scanner.makeExecutable("debian/rules");
String debianVersion = projectVersion.replace("-alpha-", "~alpha");
debianVersion = debianVersion.replace("-beta-", "~beta");
@@ -517,118 +526,6 @@
}
}
- 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));
@@ -637,46 +534,6 @@
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) {
@@ -688,10 +545,6 @@
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;
@@ -727,34 +580,6 @@
}
}
- 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;
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetChangelogVersionResult.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetChangelogVersionResult.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetChangelogVersionResult.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,55 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class GetChangelogVersionResult implements OutputHandler {
+
+ private String result;
+ private final Pattern pattern;
+ private boolean failed;
+
+ 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 void failure() {
+ failed = true;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public boolean isFailed() {
+ return failed;
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageContainingPatternResult.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageContainingPatternResult.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageContainingPatternResult.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,67 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class GetPackageContainingPatternResult implements OutputHandler {
+ private final String extension;
+ private final Map<String, String> result = new HashMap<String, String>();
+
+ public GetPackageContainingPatternResult(String extension) {
+ this.extension = extension;
+ }
+
+ public void newLine(String line) {
+ // Clean up lines of the form <pkg>: <file>
+ int colon = line.indexOf(':');
+ if (colon > 0 && line.indexOf(' ') > colon) {
+ String candidatePkg = line.substring(0, colon);
+ // Ignore lines such as 'dpkg : xxx'
+ if (candidatePkg.equals(candidatePkg.trim()) && !candidatePkg.startsWith("dpkg")) {
+ String match = matchFile(line.substring(colon + 1).trim(), candidatePkg);
+ if (match != null) {
+ result.put(match, candidatePkg);
+ }
+ }
+ }
+ }
+
+ protected String matchFile(String potentialMatch, String candidatePkg) {
+ if (potentialMatch.endsWith(extension)) {
+ System.out.println("Found " + potentialMatch + " in " + candidatePkg);
+ return potentialMatch;
+ } else {
+ return null;
+ }
+ }
+
+ public void failure() {
+ }
+
+ public Map<String, String> getPackagesAndFiles() {
+ return result;
+ }
+
+ public Set<String> getPackages() {
+ return new HashSet(result.values());
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageResult.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageResult.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageResult.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,47 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.Set;
+import java.util.TreeSet;
+
+public class GetPackageResult implements OutputHandler {
+
+ private final Set<String> result = new TreeSet<String>();
+
+ public void newLine(String line) {
+ // Clean up lines of the form <pkg>: <file>
+ int colon = line.indexOf(':');
+ if (colon > 0 && line.indexOf(' ') > colon) {
+ String candidatePkg = line.substring(0, colon);
+ // Ignore lines such as 'dpkg : xxx'
+ if (candidatePkg.equals(candidatePkg.trim()) && !candidatePkg.startsWith("dpkg")) {
+ System.out.println("Found " + candidatePkg);
+ result.add(candidatePkg);
+ }
+ }
+ }
+
+ public void failure() {
+ }
+
+ public Set<String> getResult() {
+ return result;
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageVersionResult.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageVersionResult.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/GetPackageVersionResult.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,61 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class GetPackageVersionResult implements OutputHandler {
+
+ private static final Pattern APT_VERSION_PATTERN = Pattern.compile("^\\s+.*\\s\\((.+)-.+?\\)$");
+ private String result;
+ private boolean failed;
+
+ 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();
+ int dash = result.lastIndexOf('-');
+ if (dash > 0) {
+ result = result.substring(0, dash);
+ }
+ result = result.replace('~', '-');
+ } else {
+ Matcher matcher = APT_VERSION_PATTERN.matcher(line);
+ if (matcher.find()) {
+ result = matcher.group(1);
+ result = result.replace('~', '-');
+ }
+ }
+ }
+
+ public void failure() {
+ failed = true;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public boolean isFailed() {
+ return failed;
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IOUtil.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IOUtil.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IOUtil.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,96 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+public class IOUtil {
+
+ public static String readLine() {
+ LineNumberReader consoleReader = new LineNumberReader(new InputStreamReader(System.in));
+ try {
+ return consoleReader.readLine().trim();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ 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) {
+ System.out.println(cmd[0] + " failed to execute successfully");
+ handler.failure();
+ }
+ process.destroy();
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ Thread.interrupted();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ handler.failure();
+ }
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicenseCheckResult.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicenseCheckResult.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicenseCheckResult.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,52 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.Set;
+import java.util.TreeSet;
+
+public class LicenseCheckResult implements OutputHandler {
+
+ private final Set licenses = new TreeSet();
+ private final 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 void failure() {
+ }
+
+ public Set getLicenses() {
+ return licenses;
+ }
+
+ public Set getCopyrightOwners() {
+ return copyrightOwners;
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicensesScanner.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicensesScanner.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/LicensesScanner.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,143 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.License;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import static org.debian.maven.packager.util.IOUtil.readLine;
+
+public class LicensesScanner {
+
+ public Set discoverLicenses(List projectLicenses) {
+ Set licenses = new TreeSet();
+ for (Iterator i = projectLicenses.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();
+ IOUtil.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;
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/NoOutputHandler.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/NoOutputHandler.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/NoOutputHandler.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,34 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.
+ */
+
+
+public class NoOutputHandler implements OutputHandler {
+
+ private boolean failed;
+
+ public void newLine(String line) {
+ }
+
+ public void failure() {
+ failed = true;
+ }
+
+ public boolean isFailed() {
+ return failed;
+ }
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/OutputHandler.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/OutputHandler.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/OutputHandler.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,26 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.
+ */
+
+
+public interface OutputHandler {
+
+ void newLine(String line);
+
+ void failure();
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/PackageScanner.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/PackageScanner.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/PackageScanner.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,143 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PackageScanner {
+
+ private boolean offline;
+ // Keep the list of known files and their package
+ private Map<File, String> filesInPackages = new HashMap<File, String>();
+ private Map<String, List<String>> cacheOfSharedJars = new HashMap<String, List<String>>();
+
+ public void setOffline(boolean offline) {
+ this.offline = offline;
+ }
+
+ public String searchPkg(File dir, String extension) {
+ GetPackageContainingPatternResult packageResult = new GetPackageContainingPatternResult(extension);
+ File cacheId = new File(dir, "<ANY>" + extension);
+
+ if (filesInPackages.containsKey(cacheId)) {
+ return filesInPackages.get(cacheId);
+ }
+
+ IOUtil.executeProcess(new String[]{"dpkg", "--search", dir.getAbsolutePath() + "/*/*"}, packageResult);
+
+ String pkg = null;
+ if (!packageResult.getPackages().isEmpty()) {
+ pkg = packageResult.getPackages().iterator().next();
+ filesInPackages.put(cacheId, pkg);
+ return pkg;
+ }
+
+ // Debian policy prevents the use of apt-file during a build
+ if (offline) {
+ System.err.println("Offline mode. Give up looking for package containing " + dir);
+ return null;
+ }
+
+ if (!new File("/usr/bin/apt-file").exists()) {
+ System.err.println("/usr/bin/apt-file not found. Give up looking for package containing " + dir);
+ return null;
+ }
+ IOUtil.executeProcess(new String[]{"apt-file", "search", dir.getAbsolutePath()}, packageResult);
+ if (!packageResult.getPackages().isEmpty()) {
+ pkg = packageResult.getPackages().iterator().next();
+ filesInPackages.put(cacheId, pkg);
+ }
+ return pkg;
+
+ }
+
+ public String searchPkg(File fileToSearch) {
+ GetPackageResult packageResult = new GetPackageResult();
+
+ if (filesInPackages.containsKey(fileToSearch)) {
+ return filesInPackages.get(fileToSearch);
+ }
+
+ String pkg = null;
+ IOUtil.executeProcess(new String[]{"dpkg", "--search", fileToSearch.getAbsolutePath()}, packageResult);
+ if (!packageResult.getResult().isEmpty()) {
+ pkg = packageResult.getResult().iterator().next();
+ filesInPackages.put(fileToSearch, pkg);
+ return pkg;
+ }
+
+ // Debian policy prevents the use of apt-file during a build
+ if (offline) {
+ System.err.println("Offline mode. Give up looking for package containing " + fileToSearch);
+ return null;
+ }
+
+ if (!new File("/usr/bin/apt-file").exists()) {
+ System.err.println("/usr/bin/apt-file not found. Give up looking for package containing " + fileToSearch);
+ return null;
+ }
+ IOUtil.executeProcess(new String[]{"apt-file", "search", fileToSearch.getAbsolutePath()}, packageResult);
+ if (!packageResult.getResult().isEmpty()) {
+ pkg = packageResult.getResult().iterator().next();
+ filesInPackages.put(fileToSearch, pkg);
+ }
+ return pkg;
+ }
+
+ public String getPackageVersion(String pkg, boolean onlyInstalled) {
+ GetPackageVersionResult packageResult = new GetPackageVersionResult();
+ IOUtil.executeProcess(new String[]{"dpkg", "--status", pkg}, packageResult);
+ if (packageResult.getResult() != null) {
+ return packageResult.getResult();
+ }
+ if (!onlyInstalled) {
+ GetChangelogVersionResult versionResult = new GetChangelogVersionResult(pkg);
+ IOUtil.executeProcess(new String[]{"apt-get", "--no-act", "--verbose-versions", "install", pkg}, versionResult);
+ if (versionResult.getResult() != null) {
+ return versionResult.getResult();
+ }
+ }
+ return null;
+ }
+
+ public 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 + "...");
+ IOUtil.executeProcess(new String[]{"dpkg", "--listfiles", library},
+ new SharedJarOutputHandler(jars));
+ cacheOfSharedJars.put(library, jars);
+ return jars;
+ }
+
+ public void makeExecutable(String file) {
+ IOUtil.executeProcess(new String[]{"chmod", "+x", file}, new NoOutputHandler());
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/SharedJarOutputHandler.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/SharedJarOutputHandler.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/util/SharedJarOutputHandler.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,42 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.util.List;
+
+public class SharedJarOutputHandler implements OutputHandler {
+ private final List<String> jars;
+
+ public SharedJarOutputHandler(List<String> jars) {
+ this.jars = jars;
+ }
+
+ 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");
+ }
+ }
+ }
+
+ public void failure() {
+ }
+}
Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/copyright.vm 2012-05-02 22:28:55 UTC (rev 16036)
@@ -18,7 +18,7 @@
#foreach ($license in $licenses)
License: $license
-#set ($knownLicenses = ["Apache-2.0", "BSD", "GFDL-1.2", "GPL-2", "LGPL-2.1", "Artistic", "GPL-3", "LGPL-2", "LGPL-3"])
+#set ($knownLicenses = ["Apache-2.0", "GFDL-1.2", "GPL-2", "LGPL-2.1", "Artistic", "GPL-3", "LGPL-2", "LGPL-3"])
#if ($knownLicenses.contains($license))
On Debian GNU/Linux system you can find the complete text of the
$license license in '/usr/share/common-licenses/$license'
Modified: trunk/maven-debian-helper/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-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/DependenciesSolverTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -9,7 +9,7 @@
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
+ * Unless required by applicab le 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
Deleted: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/GenerateDebianFilesMojoTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/GenerateDebianFilesMojoTest.java 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/GenerateDebianFilesMojoTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -1,30 +0,0 @@
-package org.debian.maven.packager;
-
-import junit.framework.TestCase;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Created by IntelliJ IDEA.
- * User: ludo
- * Date: Nov 18, 2010
- * Time: 11:56:33 PM
- * To change this template use File | Settings | File Templates.
- */
-public class GenerateDebianFilesMojoTest extends TestCase {
-
- public void testRecognizeLicense() throws Exception {
- GenerateDebianFilesMojo mojo = new GenerateDebianFilesMojo();
-
- Set licenses = new HashSet();
- assertTrue(mojo.recognizeLicense(licenses, "Apache (v2.0)", ""));
- assertEquals("Apache-2.0", licenses.iterator().next());
- licenses.clear();
-
- assertTrue(mojo.recognizeLicense(licenses, "", "http://www.apache.org/licenses/LICENSE-2.0"));
- assertEquals("Apache-2.0", licenses.iterator().next());
- licenses.clear();
-
- }
-}
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageContainingPatternResultTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageContainingPatternResultTest.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageContainingPatternResultTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,74 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+
+public class GetPackageContainingPatternResultTest {
+
+ private GetPackageContainingPatternResult result;
+
+ @Test
+ public void testFilterDpkgOutput() throws Exception {
+ // dpkg --search /usr/share/maven-repo/commons-lang/commons-lang/*/*
+ List<String> dpkgOut = new ArrayList<String>();
+
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar");
+ dpkgOut.add("libcommons-lang-java-doc: /usr/share/maven-repo/commons-lang/commons-lang/2.6/commons-lang-2.6-javadoc.jar");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.pom");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.jar");
+ dpkgOut.add("libcommons-lang-java-doc: /usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian-javadoc.jar");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.pom");
+
+ result = new GetPackageContainingPatternResult(".pom");
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+
+ assertEquals(2, result.getPackagesAndFiles().size());
+ assertEquals("libcommons-lang-java", result.getPackagesAndFiles().get("/usr/share/maven-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.pom"));
+ assertEquals("libcommons-lang-java", result.getPackagesAndFiles().get("/usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.pom"));
+ assertEquals("libcommons-lang-java", result.getPackages().iterator().next());
+ }
+
+ @Test
+ public void testFilterAptFileOutput() throws Exception {
+ // apt-file search /usr/share/maven-repo/commons-lang/commons-lang
+ List<String> dpkgOut = new ArrayList<String>();
+
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/2.4/commons-lang-2.4.jar");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/2.4/commons-lang-2.4.pom");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.jar");
+ dpkgOut.add("libcommons-lang-java: /usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.pom");
+
+ result = new GetPackageContainingPatternResult(".pom");
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+
+ assertEquals("libcommons-lang-java", result.getPackagesAndFiles().get("/usr/share/maven-repo/commons-lang/commons-lang/2.4/commons-lang-2.4.pom"));
+ assertEquals("libcommons-lang-java", result.getPackagesAndFiles().get("/usr/share/maven-repo/commons-lang/commons-lang/debian/commons-lang-debian.pom"));
+ assertEquals("libcommons-lang-java", result.getPackages().iterator().next());
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageResultTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageResultTest.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageResultTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,72 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+
+public class GetPackageResultTest {
+
+ private GetPackageResult result = new GetPackageResult();
+
+ @Test
+ public void testFilterDpkgOutputFindCommonsIoPom() throws Exception {
+ //dpkg --search /usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.pom
+ List<String> dpkgOut = new ArrayList<String>();
+ dpkgOut.add("libcommons-io-java: /usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.pom");
+
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+ assertEquals(1, result.getResult().size());
+ assertEquals("libcommons-io-java", result.getResult().iterator().next());
+ }
+
+ @Test
+ public void testFilterDpkgOutputFindAnyJavaccMavenPlugin() throws Exception {
+ //dpkg --search /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/*/*
+ List<String> dpkgOut = new ArrayList<String>();
+ dpkgOut.add("libjavacc-maven-plugin-java: /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/2.6/javacc-maven-plugin-2.6.jar");
+ dpkgOut.add("libjavacc-maven-plugin-java: /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/2.6/javacc-maven-plugin-2.6.pom");
+
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+ assertEquals(1, result.getResult().size());
+ assertEquals("libjavacc-maven-plugin-java", result.getResult().iterator().next());
+ }
+
+ @Test
+ public void testFilterAptFileOutput() throws Exception {
+ // apt-file search /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/
+ List<String> dpkgOut = new ArrayList<String>();
+ dpkgOut.add("libjavacc-maven-plugin-java: /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/2.6/javacc-maven-plugin-2.6.jar");
+ dpkgOut.add("libjavacc-maven-plugin-java: /usr/share/maven-repo/org/codehaus/mojo/javacc-maven-plugin/2.6/javacc-maven-plugin-2.6.pom");
+
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+ assertEquals(1, result.getResult().size());
+ assertEquals("libjavacc-maven-plugin-java", result.getResult().iterator().next());
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageVersionResultTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageVersionResultTest.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/GetPackageVersionResultTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,78 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+
+public class GetPackageVersionResultTest {
+
+ private GetPackageVersionResult result = new GetPackageVersionResult();
+
+ @Test
+ public void testFilterDpkgOutput() throws Exception {
+ //dpkg --status libjavacc-maven-plugin-java
+ List<String> dpkgOut = new ArrayList<String>();
+ dpkgOut.add("Package: libjavacc-maven-plugin-java");
+ dpkgOut.add("Status: install ok installed");
+ dpkgOut.add("Priority: optional");
+ dpkgOut.add("Section: java");
+ dpkgOut.add("Installed-Size: 144");
+ dpkgOut.add("Maintainer: Ubuntu Developers <ubuntu-devel-discuss at lists.ubuntu.com>");
+ dpkgOut.add("Architecture: all");
+ dpkgOut.add("Source: javacc-maven-plugin");
+ dpkgOut.add("Version: 2.6-1");
+ dpkgOut.add("Depends: javacc, jtb, libdoxia-java, libdoxia-sitetools-java, libmaven-reporting-impl-java, libmaven2-core-java, libplexus-utils-java");
+ dpkgOut.add("Description: maven plugin which uses JavaCC to process JavaCC grammar files");
+
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+ assertEquals("2.6", result.getResult());
+ }
+
+ @Test
+ public void testFilterAptFileOutput() throws Exception {
+ // apt-get --no-act --verbose-versions install libmaven-war-plugin-java
+ List<String> dpkgOut = new ArrayList<String>();
+ dpkgOut.add("NOTE: Ceci n'est qu'une simulation !");
+ dpkgOut.add(" apt-get a besoin des privilèges du superutilisateur");
+ dpkgOut.add(" pour pouvoir vraiment fonctionner.");
+ dpkgOut.add(" Veuillez aussi noter que le verrouillage est désactivé,");
+ dpkgOut.add(" et la situation n'est donc pas forcément représentative");
+ dpkgOut.add(" de la réalité !");
+ dpkgOut.add("Lecture des listes de paquets... Fait");
+ dpkgOut.add("Construction de l'arbre des dépendances");
+ dpkgOut.add("Lecture des informations d'état... Fait");
+ dpkgOut.add("Les NOUVEAUX paquets suivants seront installés :");
+ dpkgOut.add(" libmaven-war-plugin-java (2.1~beta1-1build1)");
+ dpkgOut.add("0 mis à jour, 1 nouvellement installés, 0 à enlever et 7 non mis à jour.");
+ dpkgOut.add("Inst libmaven-war-plugin-java (2.1~beta1-1build1 Ubuntu:11.10/oneiric [all])");
+ dpkgOut.add("Conf libmaven-war-plugin-java (2.1~beta1-1build1 Ubuntu:11.10/oneiric [all])");
+
+ for (String line : dpkgOut) {
+ result.newLine(line);
+ }
+ assertEquals("2.1-beta1", result.getResult());
+ }
+
+}
Added: trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/LicensesScannerTest.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/LicensesScannerTest.java (rev 0)
+++ trunk/maven-debian-helper/maven-packager-utils/src/test/java/org/debian/maven/packager/util/LicensesScannerTest.java 2012-05-02 22:28:55 UTC (rev 16036)
@@ -0,0 +1,41 @@
+package org.debian.maven.packager.util;
+
+/*
+ * Copyright 2012 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 junit.framework.TestCase;
+import org.debian.maven.packager.GenerateDebianFilesMojo;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class LicensesScannerTest extends TestCase {
+
+ public void testRecognizeLicense() throws Exception {
+ LicensesScanner scanner = new LicensesScanner();
+
+ Set licenses = new HashSet();
+ assertTrue(scanner.recognizeLicense(licenses, "Apache (v2.0)", ""));
+ assertEquals("Apache-2.0", licenses.iterator().next());
+ licenses.clear();
+
+ assertTrue(scanner.recognizeLicense(licenses, "", "http://www.apache.org/licenses/LICENSE-2.0"));
+ assertEquals("Apache-2.0", licenses.iterator().next());
+ licenses.clear();
+
+ }
+}
Modified: trunk/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/pom.xml 2012-05-02 22:28:55 UTC (rev 16036)
@@ -4,13 +4,13 @@
<groupId>org.debian.maven</groupId>
<artifactId>maven-debian</artifactId>
- <version>1.5</version>
+ <version>1.5.1</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>debian-maven-plugin</module>
<module>maven-build-nodocs</module>
<module>maven-packager-utils</module>
</modules>
@@ -68,7 +68,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.2</version>
+ <version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
Modified: trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk
===================================================================
--- trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk 2012-05-02 16:40:03 UTC (rev 16035)
+++ trunk/maven-debian-helper/share/cdbs/1/class/maven-vars.mk 2012-05-02 22:28:55 UTC (rev 16036)
@@ -103,10 +103,10 @@
# only called if the corresponding variable is set. You can also specify
# multiple targets for each step.
DEB_MAVEN_BUILD_TARGET = package
-DEB_MAVEN_INSTALL_TARGET = org.debian.maven:maven-debian-plugin:$(MAVEN_DEBIAN_VERSION):install
+DEB_MAVEN_INSTALL_TARGET = org.debian.maven:debian-maven-plugin:$(MAVEN_DEBIAN_VERSION):install
DEB_MAVEN_CHECK_TARGET =
DEB_MAVEN_CLEAN_TARGET = clean
DEB_MAVEN_DOC_TARGET = javadoc:jar
-DEB_MAVEN_INSTALL_DOC_TARGET = org.debian.maven:maven-debian-plugin:$(MAVEN_DEBIAN_VERSION):install-doc
+DEB_MAVEN_INSTALL_DOC_TARGET = org.debian.maven:debian-maven-plugin:$(MAVEN_DEBIAN_VERSION):install-doc
endif
More information about the pkg-java-commits
mailing list