Merge branch 'arcticwaters/maven3'
Emmanuel Bourg
8 years ago
2 | 2 | MH_VERSION=$(ls /usr/share/maven-repo/org/debian/maven/maven-packager-utils/ | sed 's|/||') |
3 | 3 | . /usr/share/maven-repo-helper/mh_lib.sh |
4 | 4 | |
5 | CLASSPATH="/usr/share/java/maven-project.jar:/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar" | |
5 | CLASSPATH="/usr/share/java/maven-repo-helper.jar:/usr/share/java/maven-packager-utils.jar" | |
6 | 6 | |
7 | 7 | syntax() |
8 | 8 | { |
3 | 3 | # line in a similar way as our cdbs snippets work. Production use is |
4 | 4 | # not supported by the maintainer of maven-debian-helper. |
5 | 5 | |
6 | DEB_CLASSPATH=/usr/share/java/classworlds.jar | |
7 | JAVA_OPTS=-Dclassworlds.conf=/etc/maven2/m2-debian.conf | |
6 | DEB_CLASSPATH=/usr/share/java/plexus-classworlds2.jar | |
7 | JAVA_OPTS=-Dclassworlds.conf=/etc/maven/m2-debian.conf | |
8 | 8 | MAIN_CLASS=org.codehaus.classworlds.Launcher |
9 | MAVEN_OPTS=-s/etc/maven2/settings-debian.xml | |
9 | MAVEN_OPTS=-s/etc/maven/settings-debian.xml | |
10 | 10 | |
11 | 11 | TMP_DIR=$(mktemp -d ${TMP:-/tmp}/mvn-deb.XXXXXXXXXX) |
12 | 12 | /usr/share/maven-debian-helper/copy-repo.sh $TMP_DIR |
0 | build.directory=target | |
1 | build.javaVersion=1.6 | |
2 | javadoc.dir=target/api | |
3 | classpath.test=/usr/share/java/junit4.jar | |
4 | 0 | maven.test.skip=true |
5 | 1 |
0 | <?xml version="1.0"?> | |
1 | ||
2 | <project name="pkg-java" default="package" basedir=".."> | |
3 | ||
4 | <property file="debian/build.properties"/> | |
5 | <property name="maven.build" value="/usr/share/maven-ant-helper/maven-build.xml"/> | |
6 | <property file="/usr/share/maven-ant-helper/maven-defaults.properties"/> | |
7 | ||
8 | <macrodef name="cleanmodule"> | |
9 | <attribute name="dir"/> | |
10 | <sequential> | |
11 | <ant target="clean" antfile="${maven.build}" dir="@{dir}"> | |
12 | <property name="debian.dir" location="debian" /> | |
13 | <property name="project.dir" value="@{dir}" /> | |
14 | </ant> | |
15 | </sequential> | |
16 | </macrodef> | |
17 | ||
18 | <macrodef name="packagemodule"> | |
19 | <attribute name="dir"/> | |
20 | <sequential> | |
21 | <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}"> | |
22 | <property name="debian.dir" location="debian" /> | |
23 | <property name="project.dir" value="@{dir}" /> | |
24 | <property name="keep-cleaned-pom" value="true" /> | |
25 | </ant> | |
26 | </sequential> | |
27 | </macrodef> | |
28 | ||
29 | <macrodef name="package-plugin-module"> | |
30 | <attribute name="dir"/> | |
31 | <sequential> | |
32 | <ant target="package-and-local-install" antfile="${maven.build}" dir="@{dir}"> | |
33 | <property name="debian.dir" location="debian" /> | |
34 | <property name="project.dir" value="@{dir}" /> | |
35 | <property name="maven.generate.target" value="plugin:descriptor" /> | |
36 | <property name="keep-cleaned-pom" value="true" /> | |
37 | <property name="use-local-repo" value="true" /> | |
38 | </ant> | |
39 | </sequential> | |
40 | </macrodef> | |
41 | ||
42 | <target name="clean"> | |
43 | <cleanmodule dir=""/> | |
44 | <cleanmodule dir="maven-debian-helper"/> | |
45 | <cleanmodule dir="debian-maven-plugin"/> | |
46 | <cleanmodule dir="maven-build-nodocs"/> | |
47 | <cleanmodule dir="maven-packager-utils"/> | |
48 | </target> | |
49 | ||
50 | <target name="package"> | |
51 | <packagemodule dir=""/> | |
52 | <packagemodule dir="maven-debian-helper"/> | |
53 | <packagemodule dir="maven-build-nodocs"/> | |
54 | <package-plugin-module dir="debian-maven-plugin"/> | |
55 | <package-plugin-module dir="maven-packager-utils"/> | |
56 | </target> | |
57 | ||
58 | <target name="javadoc"> | |
59 | <javadoc destdir="${javadoc.dir}"> | |
60 | <packageset dir="maven-debian-helper/src/main/java/"/> | |
61 | <packageset dir="debian-maven-plugin/src/main/java/"/> | |
62 | <packageset dir="maven-packager-utils/src/main/java/"/> | |
63 | </javadoc> | |
64 | </target> | |
65 | ||
66 | </project> |
0 | maven-debian-helper (2.0) UNRELEASED; urgency=medium | |
1 | ||
2 | * Update Maven to version 3.0.5 | |
3 | * Build deb package using itself rather than maven-ant-helper | |
4 | * Update mojos to use annotations | |
5 | * Remove nodocs build due to Maven 3 update | |
6 | ||
7 | -- Andrew Schurman <arcticwaters@gmail.com> Mon, 16 Mar 2015 18:48:32 -0700 | |
8 | ||
0 | 9 | maven-debian-helper (1.7) unstable; urgency=medium |
1 | 10 | |
2 | 11 | * Ignore the 'maven clean' errors when building with debhelper |
7 | 7 | Thomas Koch <thomas@koch.ro>, |
8 | 8 | Emmanuel Bourg <ebourg@apache.org>, |
9 | 9 | Wolodja Wentland <debian@babilen5.org> |
10 | Build-Depends: cdbs, debhelper (>= 9), default-jdk, maven-ant-helper (>= 7.0), ant-optional, help2man | |
10 | Build-Depends: cdbs, debhelper (>= 9), default-jdk, help2man | |
11 | 11 | Build-Depends-Indep: junit4, |
12 | 12 | libcommons-io-java, |
13 | libmaven-install-plugin-java, | |
13 | 14 | libmaven-plugin-tools-java, |
14 | 15 | libplexus-velocity-java, |
15 | 16 | maven-repo-helper (>= 1.8.9) |
20 | 21 | |
21 | 22 | Package: maven-debian-helper |
22 | 23 | Architecture: all |
23 | Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.8.9), maven2 (>= 2.2.1-5), | |
24 | Depends: ${misc:Depends}, default-jdk, maven-repo-helper (>= 1.8.9), maven (>= 3.0.5-1), | |
24 | 25 | libmaven-clean-plugin-java, |
25 | libmaven-compiler-plugin-2.5-java | libmaven-compiler-plugin-java (<< 3.0~), | |
26 | libmaven-compiler-plugin-java, | |
26 | 27 | libmaven-jar-plugin-java, |
27 | 28 | libmaven-resources-plugin-java, |
28 | 29 | libmaven-site-plugin-java, |
29 | 30 | libplexus-velocity-java, |
30 | 31 | libsurefire-java, |
31 | velocity | |
32 | libxml2-utils, | |
33 | velocity, | |
34 | unzip | |
32 | 35 | Suggests: libmaven-javadoc-plugin-java, apt-file, devscripts, subversion |
33 | 36 | Description: Helper tools for building Debian packages with Maven |
34 | 37 | maven-debian-helper is a set of tools used to generate Debian packages from |
0 | 0 | bin/mh_* /usr/bin |
1 | 1 | bin/mvn-debian /usr/bin |
2 | etc/*.conf /etc/maven2/ | |
3 | etc/*.xml /etc/maven2/ | |
2 | etc/*.conf /etc/maven/ | |
3 | etc/*.xml /etc/maven/ | |
4 | 4 | share/cdbs/1/class/*.mk /usr/share/cdbs/1/class |
5 | 5 | share/maven-debian-helper/*.sh /usr/share/maven-debian-helper |
6 | 6 | usr/share/perl5 |
0 | 0 | pom.xml --no-parent --has-package-version |
1 | 1 | maven-debian-helper/pom.xml --has-package-version --artifact=maven-debian-helper/target/maven-debian-helper-*.jar --java-lib |
2 | 2 | debian-maven-plugin/pom.xml --has-package-version --artifact=debian-maven-plugin/target/debian-maven-plugin-*.jar --java-lib |
3 | maven-build-nodocs/pom.xml --has-package-version --artifact=maven-build-nodocs/target/maven-build-nodocs-*.jar --java-lib | |
4 | 3 | maven-packager-utils/pom.xml --has-package-version --artifact=maven-packager-utils/target/maven-packager-utils-*.jar --java-lib |
0 | 0 | junit junit jar s/4\..*/4.x/ |
1 | org.codehaus.plexus plexus-container-default jar s/1\.0-alpha-.*/1.0-alpha/ | |
1 | org.apache.maven maven-embedder * s/3\..*/3.x/ |
0 | 0 | #!/usr/bin/make -f |
1 | 1 | |
2 | ROOT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.. | |
3 | # ensure that maven.mk is able to include necessary files | |
4 | _cdbs_class_path = $(ROOT_DIR)/share/cdbs/1/class | |
5 | ||
2 | 6 | include /usr/share/cdbs/1/rules/debhelper.mk |
3 | include /usr/share/cdbs/1/class/ant.mk | |
7 | include $(ROOT_DIR)/share/cdbs/1/class/maven.mk | |
4 | 8 | |
5 | 9 | PACKAGE := $(DEB_SOURCE_PACKAGE) |
6 | 10 | VERSION := $(shell echo ${DEB_UPSTREAM_VERSION} | sed -r 's/([0-9\.]+).*/\1/') |
7 | 11 | JAVA_HOME := /usr/lib/jvm/default-java |
8 | DEB_JARS := ant-junit junit commons-io classworlds maven-core maven-artifact maven-artifact-manager maven-model \ | |
9 | maven-compat maven-plugin-api maven-project maven-scm-api velocity file-management plexus-utils \ | |
10 | plexus-container-default-alpha maven-repo-helper | |
11 | DEB_ANT_BUILD_TARGET := package #javadoc | |
12 | DEB_ANT_BUILDFILE := debian/build.xml | |
13 | DEB_ANT_ARGS := -Dpackage=$(PACKAGE) -Dbin.package=$(PACKAGE) | |
14 | API_DOCS := target/api | |
12 | MAVEN_CLASSCONF_ORIG := $(ROOT_DIR)/etc/m2-debian.conf | |
13 | MAVEN_CLASSCONF_REAL := $(ROOT_DIR)/debian/.mh/etc/m2-debian.conf | |
14 | MAVEN_CLASSCONF := $(MAVEN_CLASSCONF_REAL) | |
15 | MAVEN_SETTINGS := $(ROOT_DIR)/etc/settings-debian.xml | |
16 | DEB_MAVEN_PROPERTYFILE:= $(ROOT_DIR)/debian/build.properties | |
17 | DEB_MAVEN_SCRIPT_DIR := $(ROOT_DIR)/share/maven-debian-helper/ | |
18 | ||
19 | ||
20 | # clean happens before we get a chance to bootstrap (and we don't need sugar yet) | |
21 | clean:: override MAVEN_CLASSCONF=/etc/maven/m2.conf | |
22 | clean:: override JAVA_OPTS+="-Dmaven.home=$(MAVEN_HOME)" | |
23 | ||
24 | # bootstrap the build process | |
25 | before-mvn-build:: override MAVEN_CLASSCONF=/etc/maven/m2.conf | |
26 | before-mvn-build:: override JAVA_OPTS+="-Dmaven.home=$(MAVEN_HOME)" | |
27 | before-mvn-build:: | |
28 | $(DEB_MAVEN_INVOKE) -Dmaven.test.skip -Djar.finalName=maven-debian-helper install | |
29 | cp maven-debian-helper/target/maven-debian-helper.jar debian/.mh/ | |
30 | sed 's|load .*/maven-debian-helper.jar|load $(ROOT_DIR)/debian/.mh/maven-debian-helper.jar|g' $(MAVEN_CLASSCONF_ORIG) > $(MAVEN_CLASSCONF_REAL) | |
31 | $(DEB_MAVEN_INVOKE) clean | |
32 | ||
15 | 33 | |
16 | 34 | debian/.mh: |
17 | 35 | mkdir -p debian/.mh |
58 | 76 | # Helper target, to use when updating the version of this package |
59 | 77 | update-package-version: |
60 | 78 | perl -p -i -e "s/^ <version>([0-9\.]+<)/ <version>${VERSION}</" pom.xml |
61 | 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 | |
79 | perl -p -i -e "s/^ <version>([0-9\.]+<)/ <version>${VERSION}</" maven-debian-helper/pom.xml debian-maven-plugin/pom.xml | |
62 | 80 | 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 |
63 | 81 | |
64 | 82 |
5 | 5 | <parent> |
6 | 6 | <artifactId>maven-debian</artifactId> |
7 | 7 | <groupId>org.debian.maven</groupId> |
8 | <version>1.7</version> | |
8 | <version>2.0</version> | |
9 | 9 | </parent> |
10 | 10 | |
11 | 11 | <artifactId>debian-maven-plugin</artifactId> |
18 | 18 | <artifactId>maven-repo-helper</artifactId> |
19 | 19 | </dependency> |
20 | 20 | <dependency> |
21 | <groupId>commons-io</groupId> | |
22 | <artifactId>commons-io</artifactId> | |
23 | <scope>test</scope> | |
21 | <groupId>org.apache.maven</groupId> | |
22 | <artifactId>maven-core</artifactId> | |
23 | </dependency> | |
24 | <dependency> | |
25 | <groupId>junit</groupId> | |
26 | <artifactId>junit</artifactId> | |
27 | </dependency> | |
28 | <dependency> | |
29 | <groupId>org.apache.maven.plugin-tools</groupId> | |
30 | <artifactId>maven-plugin-annotations</artifactId> | |
24 | 31 | </dependency> |
25 | 32 | </dependencies> |
26 | 33 | </project> |
17 | 17 | |
18 | 18 | import java.io.File; |
19 | 19 | |
20 | import org.apache.maven.plugins.annotations.Mojo; | |
21 | import org.apache.maven.plugins.annotations.Parameter; | |
22 | ||
20 | 23 | /** |
21 | 24 | * Install the javadoc jar files into the debian/ directory |
22 | 25 | * |
23 | 26 | * @author Ludovic Claude |
24 | * @goal install-doc | |
25 | 27 | */ |
28 | @Mojo(name = "install-doc") | |
26 | 29 | public class InstallDocMojo extends SysInstallDocMojo { |
27 | 30 | |
28 | 31 | /** |
29 | 32 | * Maven repository root |
30 | * | |
31 | * @parameter expression="${maven.repo.local}" | |
32 | 33 | */ |
34 | @Parameter(property = "maven.repo.local") | |
33 | 35 | private File mavenRepoLocal; |
34 | 36 | |
35 | 37 | /** |
36 | 38 | * If true, use local Maven repository for installation |
37 | * | |
38 | * @parameter expression="${use.maven.repo.local}" | |
39 | 39 | */ |
40 | @Parameter(property = "use.maven.repo.local") | |
40 | 41 | private boolean useMavenRepoLocal; |
41 | 42 | |
42 | 43 | // ---------------------------------------------------------------------- |
17 | 17 | |
18 | 18 | import java.io.File; |
19 | 19 | |
20 | import org.apache.maven.plugins.annotations.Mojo; | |
21 | import org.apache.maven.plugins.annotations.Parameter; | |
22 | ||
20 | 23 | /** |
21 | 24 | * Install pom and jar files into the debian/ directory |
22 | * | |
23 | * @goal install | |
24 | 25 | */ |
26 | @Mojo(name = "install") | |
25 | 27 | public class InstallMojo extends SysInstallMojo { |
26 | 28 | |
27 | 29 | /** |
28 | 30 | * Maven repository root |
29 | * | |
30 | * @parameter expression="${maven.repo.local}" | |
31 | 31 | */ |
32 | @Parameter(property = "maven.repo.local") | |
32 | 33 | private File mavenRepoLocal; |
33 | 34 | |
34 | 35 | /** |
35 | 36 | * If true, use local Maven repository for installation |
36 | * | |
37 | * @parameter expression="${use.maven.repo.local}" | |
38 | 37 | */ |
38 | @Parameter(property = "use.maven.repo.local") | |
39 | 39 | private boolean useMavenRepoLocal; |
40 | 40 | |
41 | 41 | // ---------------------------------------------------------------------- |
15 | 15 | |
16 | 16 | package org.debian.maven.plugin; |
17 | 17 | |
18 | import org.apache.maven.plugins.annotations.Mojo; | |
19 | import org.apache.maven.plugins.annotations.ResolutionScope; | |
20 | ||
18 | 21 | /** |
19 | 22 | * Resolves compile dependencies |
20 | * | |
21 | * @goal resolve-compile | |
22 | * @requiresDependencyResolution compile | |
23 | * @aggregator true | |
24 | 23 | */ |
24 | @Mojo(name = "resolve-compile", aggregator = true, requiresDependencyResolution = ResolutionScope.COMPILE) | |
25 | 25 | public class ResolveCompileMojo extends ResolveNoneMojo |
26 | 26 | { |
27 | 27 | } |
17 | 17 | |
18 | 18 | import org.apache.maven.plugin.AbstractMojo; |
19 | 19 | import org.apache.maven.plugin.MojoExecutionException; |
20 | import org.apache.maven.plugins.annotations.Mojo; | |
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Dummy goal that just reads the pom.xml files including parents |
23 | * | |
24 | * @goal resolve-none | |
25 | * @aggregator true | |
26 | 24 | */ |
25 | @Mojo(name = "resolve-none", aggregator = true) | |
27 | 26 | public class ResolveNoneMojo extends AbstractMojo { |
28 | 27 | |
29 | 28 | public void execute() throws MojoExecutionException { |
15 | 15 | |
16 | 16 | package org.debian.maven.plugin; |
17 | 17 | |
18 | import org.apache.maven.plugins.annotations.Mojo; | |
19 | import org.apache.maven.plugins.annotations.ResolutionScope; | |
20 | ||
18 | 21 | /** |
19 | 22 | * Resolves runtime dependencies |
20 | * | |
21 | * @goal resolve-runtime | |
22 | * @requiresDependencyResolution runtime | |
23 | * @aggregator true | |
24 | 23 | */ |
24 | @Mojo(name = "resolve-runtime", aggregator = true, requiresDependencyResolution = ResolutionScope.RUNTIME) | |
25 | 25 | public class ResolveRuntimeMojo extends ResolveNoneMojo |
26 | 26 | { |
27 | 27 | } |
15 | 15 | |
16 | 16 | package org.debian.maven.plugin; |
17 | 17 | |
18 | import org.apache.maven.plugins.annotations.Mojo; | |
19 | import org.apache.maven.plugins.annotations.ResolutionScope; | |
20 | ||
18 | 21 | /** |
19 | 22 | * Resolves test dependencies |
20 | * | |
21 | * @goal resolve-test | |
22 | * @requiresDependencyResolution test | |
23 | * @aggregator true | |
24 | 23 | */ |
24 | @Mojo(name = "resolve-test", aggregator = true, requiresDependencyResolution = ResolutionScope.TEST) | |
25 | 25 | public class ResolveTestMojo extends ResolveNoneMojo |
26 | 26 | { |
27 | 27 | } |
17 | 17 | |
18 | 18 | import java.io.IOException; |
19 | 19 | |
20 | import org.apache.maven.plugins.annotations.Mojo; | |
21 | ||
20 | 22 | /** |
21 | 23 | * Install the javadoc jar. |
22 | 24 | * |
23 | 25 | * @author Ludovic Claude |
24 | * @goal sysinstall-doc | |
25 | 26 | */ |
27 | @Mojo(name = "sysinstall-doc") | |
26 | 28 | public class SysInstallDocMojo extends SysInstallMojo { |
27 | 29 | |
28 | 30 | { |
25 | 25 | |
26 | 26 | import org.apache.maven.plugin.AbstractMojo; |
27 | 27 | import org.apache.maven.plugin.MojoExecutionException; |
28 | import org.apache.maven.plugins.annotations.Mojo; | |
29 | import org.apache.maven.plugins.annotations.Parameter; | |
28 | 30 | import org.codehaus.plexus.util.FileUtils; |
29 | 31 | import org.debian.maven.repo.ListOfPOMs; |
30 | 32 | import org.debian.maven.repo.POMCleaner; |
32 | 34 | |
33 | 35 | /** |
34 | 36 | * Install pom and jar files into the /usr/share/hierarchy |
35 | * | |
36 | * @goal sysinstall | |
37 | 37 | */ |
38 | @Mojo(name = "sysinstall") | |
38 | 39 | public class SysInstallMojo extends AbstractMojo { |
39 | 40 | |
40 | 41 | /** Regex for detecting that package is a libXXX-java package */ |
49 | 50 | |
50 | 51 | /** |
51 | 52 | * groupId |
52 | * | |
53 | * @parameter expression="${project.groupId}" | |
54 | * @required | |
55 | * @readonly | |
56 | */ | |
53 | */ | |
54 | @Parameter(property = "project.groupId", required = true, readonly = true) | |
57 | 55 | private String groupId; |
58 | 56 | |
59 | 57 | /** |
60 | 58 | * artifactId |
61 | * | |
62 | * @parameter expression="${project.artifactId}" | |
63 | * @required | |
64 | * @readonly | |
65 | */ | |
59 | */ | |
60 | @Parameter(property = "project.artifactId", required = true, readonly = true) | |
66 | 61 | private String artifactId; |
67 | 62 | |
68 | 63 | /** |
69 | 64 | * destGroupId |
70 | * | |
71 | * @parameter expression="${project.groupId}" | |
72 | * @required | |
73 | */ | |
65 | */ | |
66 | @Parameter(property = "project.groupId", required = true) | |
74 | 67 | private String destGroupId; |
75 | 68 | |
76 | 69 | /** |
77 | 70 | * destArtifactId |
78 | * | |
79 | * @parameter expression="${project.artifactId}" | |
80 | * @required | |
81 | */ | |
71 | */ | |
72 | @Parameter(property = "project.artifactId", required = true) | |
82 | 73 | private String destArtifactId; |
83 | 74 | |
84 | 75 | /** |
85 | 76 | * version |
86 | * | |
87 | * @parameter expression="${project.version}" | |
88 | * @required | |
89 | * @readonly | |
90 | */ | |
77 | */ | |
78 | @Parameter(property = "project.version", required = true, readonly = true) | |
91 | 79 | private String version; |
92 | 80 | |
93 | 81 | /** |
94 | 82 | * debianVersion |
95 | * | |
96 | * @parameter | |
97 | */ | |
83 | */ | |
84 | @Parameter | |
98 | 85 | private String debianVersion; |
99 | 86 | |
100 | 87 | /** |
101 | 88 | * directory where the current pom.xml can be found |
102 | * | |
103 | * @parameter expression="${basedir}" | |
104 | * @required | |
105 | * @readonly | |
106 | */ | |
89 | */ | |
90 | @Parameter(property = "basedir", required = true, readonly = true) | |
107 | 91 | private File basedir; |
108 | 92 | |
109 | 93 | /** |
110 | 94 | * directory of the jar file |
111 | * | |
112 | * @parameter expression="${project.build.directory}" | |
113 | * @required | |
114 | * @readonly | |
115 | */ | |
95 | */ | |
96 | @Parameter(property = "project.build.directory", required = true, readonly = true) | |
116 | 97 | private String jarDir; |
117 | 98 | |
118 | 99 | /** |
119 | 100 | * finalname of the artifact |
120 | * | |
121 | * @parameter expression="${project.build.finalName}" | |
122 | * @required | |
123 | * @readonly | |
124 | */ | |
101 | */ | |
102 | @Parameter(property = "project.build.finalName", required = true, readonly = true) | |
125 | 103 | private String finalName; |
126 | 104 | |
127 | 105 | /** |
128 | 106 | * Debian directory |
129 | * | |
130 | * @parameter expression="${debian.dir}" | |
131 | */ | |
107 | */ | |
108 | @Parameter(property = "debian.dir") | |
132 | 109 | private File debianDir; |
133 | 110 | |
134 | 111 | /** |
135 | 112 | * Debian package (send from command line) |
136 | * | |
137 | * @parameter expression="${debian.package}" | |
138 | */ | |
113 | */ | |
114 | @Parameter(property = "debian.package") | |
139 | 115 | private String debianPackage; |
140 | 116 | |
141 | 117 | /** |
142 | 118 | * Debian package destination (set by xxx.poms file). |
143 | 119 | * By default, equals to <code>debianPackage</code> attribute. |
144 | * | |
145 | * @parameter expression="${debian.package}" | |
146 | */ | |
120 | */ | |
121 | @Parameter(property = "debian.package") | |
147 | 122 | private String destPackage; |
148 | 123 | |
149 | /** | |
150 | * @parameter expression="${maven.rules}" default-value="maven.rules" | |
151 | * @required | |
152 | */ | |
124 | @Parameter(property = "maven.rules", defaultValue = "maven.rules", required = true) | |
153 | 125 | private String mavenRules; |
154 | 126 | |
155 | /** | |
156 | * @parameter expression="${maven.ignoreRules}" default-value="maven.ignoreRules" | |
157 | * @required | |
158 | */ | |
127 | @Parameter(property = "maven.ignoreRules", defaultValue = "maven.ignoreRules", required = true) | |
159 | 128 | private String mavenIgnoreRules; |
160 | 129 | |
161 | /** | |
162 | * @parameter expression="${maven.publishedRules}" default-value="maven.publishedRules" | |
163 | * @required | |
164 | */ | |
130 | @Parameter(property = "maven.publishedRules", defaultValue = "maven.publishedRules", required = true) | |
165 | 131 | private String mavenPublishedRules; |
166 | 132 | |
167 | 133 | /** |
168 | 134 | * root directory of the Maven repository |
169 | * | |
170 | * @parameter expression="${basedir}" | |
171 | * @readonly | |
172 | */ | |
135 | */ | |
136 | @Parameter(defaultValue = "${basedir}", readonly = true) | |
173 | 137 | private File repoDir; |
174 | 138 | |
175 | 139 | /** |
176 | 140 | * Install the jar to /usr/share/java if true. Default is true |
177 | * | |
178 | * @parameter expression="${install.to.usj}" default-value="true" | |
179 | */ | |
141 | */ | |
142 | @Parameter(property = "install.to.usj", defaultValue = "true") | |
180 | 143 | private boolean installToUsj = true; |
181 | 144 | |
182 | 145 | /** |
570 | 533 | * command for creating the relative symlink |
571 | 534 | */ |
572 | 535 | private void link(String target, String linkName) throws IOException { |
536 | Process process; | |
573 | 537 | if (System.getProperty("os.name").contains("Windows")) { |
574 | 538 | File linkNameFile = new File(linkName).getAbsoluteFile(); |
575 | 539 | linkNameFile.getParentFile().mkdirs(); |
576 | Process process = new ProcessBuilder().command("cmd", "/C", "mklink", linkNameFile.getAbsolutePath(), target.replace('/', '\\')).start(); | |
577 | try { | |
578 | process.waitFor(); | |
579 | } catch (InterruptedException e) { | |
580 | throw new IOException(e); | |
581 | } | |
540 | process = new ProcessBuilder().command("cmd", "/C", "mklink", linkNameFile.getAbsolutePath(), target.replace('/', '\\')).start(); | |
582 | 541 | } else { |
583 | Runtime.getRuntime().exec(new String[]{"ln", "-s", target, linkName}, null); | |
542 | process = new ProcessBuilder().command("ln", "-s", target, linkName).start(); | |
543 | } | |
544 | ||
545 | try { | |
546 | process.waitFor(); | |
547 | } catch (InterruptedException e) { | |
548 | throw new IOException(e); | |
584 | 549 | } |
585 | 550 | } |
586 | 551 |
17 | 17 | |
18 | 18 | import java.io.IOException; |
19 | 19 | |
20 | import org.apache.maven.plugins.annotations.Mojo; | |
20 | 21 | import org.codehaus.plexus.util.FileUtils; |
21 | 22 | |
22 | 23 | /** |
23 | 24 | * Remove installed files and symlinks from the /usr/share hierarchy |
24 | * | |
25 | * @goal sysuninstall | |
26 | 25 | */ |
26 | @Mojo(name = "sysuninstall") | |
27 | 27 | public class SysUninstallMojo extends SysInstallMojo { |
28 | 28 | // ---------------------------------------------------------------------- |
29 | 29 | // Mojo parameters |
15 | 15 | |
16 | 16 | package org.debian.maven.plugin; |
17 | 17 | |
18 | import static org.junit.Assert.assertEquals; | |
19 | ||
18 | 20 | import org.junit.Test; |
19 | ||
20 | import static junit.framework.Assert.assertEquals; | |
21 | 21 | |
22 | 22 | public class DirectoryUtilsTest { |
23 | 23 |
15 | 15 | |
16 | 16 | package org.debian.maven.plugin; |
17 | 17 | |
18 | import static org.junit.Assert.assertEquals; | |
19 | import static org.junit.Assert.assertNotNull; | |
20 | ||
21 | import java.io.File; | |
22 | import java.io.IOException; | |
23 | import java.net.URISyntaxException; | |
24 | import java.net.URL; | |
25 | ||
26 | import org.codehaus.plexus.util.FileUtils; | |
18 | 27 | import org.junit.After; |
19 | 28 | import org.junit.Before; |
20 | 29 | import org.junit.Test; |
21 | 30 | |
22 | import java.io.File; | |
23 | import java.io.IOException; | |
24 | import java.io.Reader; | |
25 | import java.net.URISyntaxException; | |
26 | import java.net.URL; | |
27 | import java.util.ArrayList; | |
28 | import java.util.List; | |
29 | import java.util.logging.Level; | |
30 | import java.util.logging.Logger; | |
31 | import org.apache.commons.io.FileUtils; | |
32 | ||
33 | import static junit.framework.Assert.assertEquals; | |
34 | import static junit.framework.Assert.assertNotNull; | |
35 | 31 | |
36 | 32 | public class InstallMojoTest { |
37 | ||
38 | 33 | private File testDir = new File("tmp"); |
39 | 34 | private InstallMojo mojo; |
40 | 35 |
0 | main is org.debian.maven.Wrapper from debian | |
1 | ||
2 | set maven.home default /usr/share/maven2 | |
3 | ||
4 | [debian] | |
5 | load /usr/share/java/maven-debian-helper.jar | |
6 | load /usr/share/java/maven-build-nodocs.jar | |
7 | load ${maven.home}/lib/*.jar |
0 | 0 | main is org.debian.maven.Wrapper from debian |
1 | 1 | |
2 | set maven.home default /usr/share/maven2 | |
2 | set maven.home default /usr/share/maven | |
3 | 3 | |
4 | 4 | [debian] |
5 | 5 | load /usr/share/java/maven-debian-helper.jar |
6 | optionally ${maven.home}/lib/ext/*.jar | |
6 | 7 | load ${maven.home}/lib/*.jar |
0 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
1 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
2 | <modelVersion>4.0.0</modelVersion> | |
3 | ||
4 | <parent> | |
5 | <groupId>org.debian.maven</groupId> | |
6 | <artifactId>maven-debian</artifactId> | |
7 | <version>1.7</version> | |
8 | </parent> | |
9 | ||
10 | <artifactId>maven-build-nodocs</artifactId> | |
11 | <packaging>jar</packaging> | |
12 | <name>build with no docs patch for Maven</name> | |
13 | ||
14 | <description> | |
15 | Patch to prevent Maven from calling maven-site-plugin when | |
16 | we run a build that does not need to produce any documentation | |
17 | </description> | |
18 | ||
19 | </project> |
0 | <!-- | |
1 | Licensed to the Apache Software Foundation (ASF) under one | |
2 | or more contributor license agreements. See the NOTICE file | |
3 | distributed with this work for additional information | |
4 | regarding copyright ownership. The ASF licenses this file | |
5 | to you under the Apache License, Version 2.0 (the | |
6 | "License"); you may not use this file except in compliance | |
7 | with the License. You may obtain a copy of the License at | |
8 | ||
9 | http://www.apache.org/licenses/LICENSE-2.0 | |
10 | ||
11 | Unless required by applicable law or agreed to in writing, | |
12 | software distributed under the License is distributed on an | |
13 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | KIND, either express or implied. See the License for the | |
15 | specific language governing permissions and limitations | |
16 | under the License. | |
17 | --> | |
18 | ||
19 | <component-set> | |
20 | <components> | |
21 | ||
22 | <component> | |
23 | <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> | |
24 | <role-hint>pom</role-hint> | |
25 | <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> | |
26 | <configuration> | |
27 | <lifecycles> | |
28 | <lifecycle> | |
29 | <id>default</id> | |
30 | <!-- START SNIPPET: pom-lifecycle --> | |
31 | <phases> | |
32 | <package></package> | |
33 | <install>org.apache.maven.plugins:maven-install-plugin:install</install> | |
34 | <deploy></deploy> | |
35 | </phases> | |
36 | <!--optional-mojos> | |
37 | <optional-mojo>org.apache.maven.plugins:maven-site-plugin:attach-descriptor</optional-mojo> | |
38 | </optional-mojos--> | |
39 | <!-- END SNIPPET: pom-lifecycle --> | |
40 | </lifecycle> | |
41 | </lifecycles> | |
42 | </configuration> | |
43 | </component> | |
44 | ||
45 | </components> | |
46 | ||
47 | </component-set> |
4 | 4 | <parent> |
5 | 5 | <groupId>org.debian.maven</groupId> |
6 | 6 | <artifactId>maven-debian</artifactId> |
7 | <version>1.7</version> | |
7 | <version>2.0</version> | |
8 | 8 | </parent> |
9 | 9 | |
10 | 10 | <artifactId>maven-debian-helper</artifactId> |
13 | 13 | |
14 | 14 | <dependencies> |
15 | 15 | <dependency> |
16 | <groupId>classworlds</groupId> | |
17 | <artifactId>classworlds</artifactId> | |
16 | <groupId>org.codehaus.plexus</groupId> | |
17 | <artifactId>plexus-classworlds</artifactId> | |
18 | </dependency> | |
19 | <dependency> | |
20 | <groupId>org.apache.maven</groupId> | |
21 | <artifactId>maven-embedder</artifactId> | |
18 | 22 | </dependency> |
19 | 23 | </dependencies> |
20 | 24 | </project> |
20 | 20 | import java.util.Enumeration; |
21 | 21 | import java.util.Properties; |
22 | 22 | |
23 | import org.apache.maven.cli.compat.CompatibleMain; | |
24 | import org.codehaus.classworlds.ClassWorld; | |
23 | import org.apache.maven.cli.MavenCli; | |
24 | import org.codehaus.plexus.util.IOUtil; | |
25 | 25 | |
26 | 26 | /** |
27 | * This is a wrapper for Maven's main function that reads 2 property | |
28 | * files: debian/auto.properties and debian/manual.properties and adds | |
29 | * their content to maven's commandline. | |
27 | * This is a wrapper for Maven's main function that allows extra arguments | |
28 | * to be specified by a properties file. Properties are read from the file | |
29 | * specified by the system property {@value #EXTRA_PROPERTIES_PROPERTY}. | |
30 | 30 | */ |
31 | 31 | public class Wrapper { |
32 | ||
33 | /** Holds extra properties that are read from property files */ | |
34 | private static Properties extraProperties = new Properties(); | |
35 | ||
36 | /** The extended command line for maven's main function */ | |
37 | private static String[] newArgs; | |
38 | ||
39 | /** | |
40 | * Opens the filename specified by property 'key' and loads its | |
41 | * properties into extraProperties | |
32 | private static final String EXTRA_PROPERTIES_PROPERTY = "properties.file.manual"; | |
33 | ||
34 | /** | |
35 | * Reads the properties in the file specified by the given system property. | |
36 | * | |
37 | * @param property system property that specifies the location of the properties file | |
38 | * @return {@link Properties} provided by the file | |
42 | 39 | */ |
43 | public static void updateProperties(String key) throws IOException { | |
44 | String filename = System.getProperty(key); | |
40 | public static Properties readProperties(String property) throws IOException { | |
41 | String filename = System.getProperty(property); | |
42 | Properties result = new Properties(); | |
45 | 43 | if (filename == null) { |
46 | return; | |
44 | return result; | |
47 | 45 | } |
48 | 46 | FileInputStream stream = null; |
49 | 47 | try { |
50 | 48 | stream = new FileInputStream(filename); |
51 | extraProperties.load(stream); | |
49 | result.load(stream); | |
50 | return result; | |
52 | 51 | } finally { |
53 | if (stream != null) { | |
54 | stream.close(); | |
55 | } | |
52 | IOUtil.close(stream); | |
56 | 53 | } |
57 | 54 | } |
58 | 55 | |
59 | 56 | /** |
60 | * Fill new commandline array 'newArgs' with properties from | |
61 | * extraProperties and the current commandline array 'args. | |
57 | * Creates a new arguments array first using the given properties then the original arguments. | |
58 | * | |
59 | * @param properties additional properties to add | |
60 | * @param args original commandline arguments | |
61 | * @return new arguments to use | |
62 | 62 | */ |
63 | public static void updateCommandLine(String[] args) throws IOException { | |
63 | public static String[] updateCommandLine(Properties properties, String[] args) throws IOException { | |
64 | 64 | int argsSize = args.length; |
65 | int extraSize = extraProperties.size(); | |
65 | int extraSize = properties.size(); | |
66 | 66 | |
67 | newArgs = new String[argsSize + extraSize]; | |
67 | String[] newArgs = new String[argsSize + extraSize]; | |
68 | 68 | |
69 | 69 | int i = 0; |
70 | for (Enumeration e = extraProperties.propertyNames(); e.hasMoreElements(); ) { | |
70 | for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) { | |
71 | 71 | String key = (String) e.nextElement(); |
72 | String value = extraProperties.getProperty(key); | |
72 | String value = properties.getProperty(key); | |
73 | 73 | newArgs[i] = "-D" + key + "=" + value; |
74 | 74 | i++; |
75 | 75 | } |
76 | 76 | |
77 | 77 | System.arraycopy(args, 0, newArgs, extraSize, argsSize); |
78 | return newArgs; | |
78 | 79 | } |
79 | 80 | |
80 | 81 | /** |
81 | 82 | * Wraps maven's main function |
82 | 83 | */ |
83 | public static int main(String[] args, ClassWorld classWorld) throws IOException { | |
84 | updateProperties("properties.file.manual"); | |
84 | public static int main(String[] args) throws IOException { | |
85 | Properties extraArguments = readProperties(EXTRA_PROPERTIES_PROPERTY); | |
86 | String[] newArgs = updateCommandLine(extraArguments, args); | |
85 | 87 | |
86 | updateCommandLine(args); | |
87 | ||
88 | return CompatibleMain.main(newArgs, classWorld); | |
88 | MavenCli.main(newArgs); | |
89 | return 0; | |
89 | 90 | } |
90 | 91 | } |
5 | 5 | <parent> |
6 | 6 | <artifactId>maven-debian</artifactId> |
7 | 7 | <groupId>org.debian.maven</groupId> |
8 | <version>1.7</version> | |
8 | <version>2.0</version> | |
9 | 9 | </parent> |
10 | 10 | |
11 | 11 | <artifactId>maven-packager-utils</artifactId> |
19 | 19 | </dependency> |
20 | 20 | <dependency> |
21 | 21 | <groupId>org.apache.maven</groupId> |
22 | <artifactId>maven-artifact</artifactId> | |
23 | </dependency> | |
24 | <dependency> | |
25 | <groupId>org.apache.maven</groupId> | |
26 | <artifactId>maven-project</artifactId> | |
22 | <artifactId>maven-core</artifactId> | |
27 | 23 | </dependency> |
28 | 24 | <dependency> |
29 | 25 | <groupId>org.apache.velocity</groupId> |
36 | 32 | <dependency> |
37 | 33 | <groupId>junit</groupId> |
38 | 34 | <artifactId>junit</artifactId> |
39 | <scope>test</scope> | |
40 | 35 | </dependency> |
41 | 36 | <dependency> |
42 | <groupId>commons-io</groupId> | |
43 | <artifactId>commons-io</artifactId> | |
44 | <scope>test</scope> | |
37 | <groupId>org.apache.maven.plugin-tools</groupId> | |
38 | <artifactId>maven-plugin-annotations</artifactId> | |
45 | 39 | </dependency> |
46 | 40 | </dependencies> |
47 | 41 | </project> |
+19
-35
15 | 15 | |
16 | 16 | package org.debian.maven.packager; |
17 | 17 | |
18 | import org.apache.maven.plugin.AbstractMojo; | |
19 | import org.apache.maven.plugin.MojoExecutionException; | |
20 | ||
21 | 18 | import java.io.File; |
22 | 19 | import java.util.ArrayList; |
23 | 20 | import java.util.List; |
21 | ||
22 | import org.apache.maven.plugin.AbstractMojo; | |
23 | import org.apache.maven.plugin.MojoExecutionException; | |
24 | import org.apache.maven.plugins.annotations.LifecyclePhase; | |
25 | import org.apache.maven.plugins.annotations.Mojo; | |
26 | import org.apache.maven.plugins.annotations.Parameter; | |
27 | import org.apache.maven.plugins.annotations.ResolutionScope; | |
24 | 28 | import org.apache.maven.project.MavenProject; |
25 | 29 | import org.debian.maven.packager.util.PackageScanner; |
26 | 30 | import org.debian.maven.repo.DependencyRuleSetFiles.RulesType; |
29 | 33 | * Analyze the Maven dependencies and extract the list of dependent packages, |
30 | 34 | * reusable as subvars in the Debian control file and the list of POM files |
31 | 35 | * to use and the rules if they did not exist already. |
32 | * | |
33 | * @goal dependencies | |
34 | * @aggregator | |
35 | * @requiresDependencyResolution | |
36 | * @phase process-sources | |
37 | 36 | * |
38 | 37 | * @author Ludovic Claude |
39 | 38 | */ |
39 | @Mojo(name = "dependencies", aggregator = true, requiresDependencyResolution = ResolutionScope.RUNTIME, defaultPhase = LifecyclePhase.PROCESS_SOURCES) | |
40 | 40 | public class DependenciesMojo extends AbstractMojo { |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * The Maven Project Object |
44 | * | |
45 | * @parameter expression="${project}" | |
46 | * @readonly | |
47 | * @required | |
48 | 44 | */ |
45 | @Parameter(property = "project", readonly = true, required = true) | |
49 | 46 | protected MavenProject project; |
50 | 47 | |
51 | 48 | /** |
52 | 49 | * A list of every project in this reactor; provided by Maven |
53 | * | |
54 | * @parameter expression="${project.collectedProjects}" | |
55 | 50 | */ |
51 | @Parameter(property = "project.collectedProjects") | |
56 | 52 | protected List<MavenProject> collectedProjects; |
57 | 53 | |
58 | 54 | /** |
59 | 55 | * Location of the file. |
60 | * | |
61 | * @parameter expression="${debian.directory}" | |
62 | * default-value="debian" | |
63 | 56 | */ |
57 | @Parameter(property = "debian.directory", defaultValue = "debian") | |
64 | 58 | protected File outputDirectory; |
65 | 59 | |
66 | 60 | /** |
67 | 61 | * Name of the package (e.g. 'commons-lang') |
68 | * | |
69 | * @parameter expression="${package}" | |
70 | * @required | |
71 | 62 | */ |
63 | @Parameter(property = "package", required = true) | |
72 | 64 | protected String packageName; |
73 | 65 | |
74 | 66 | /** |
75 | 67 | * Type of the package (e.g. 'maven' or 'ant') |
76 | * | |
77 | * @parameter expression="${packageType}" default-value="maven" | |
78 | 68 | */ |
69 | @Parameter(property = "packageType", defaultValue = "maven") | |
79 | 70 | protected String packageType; |
80 | 71 | |
81 | 72 | /** |
82 | 73 | * Should we also resolve Javadoc dependencies |
83 | * | |
84 | * @parameter expression="${resolveJavadoc}" default-value="false" | |
85 | 74 | */ |
75 | @Parameter(property = "resolveJavadoc", defaultValue = "false") | |
86 | 76 | protected boolean resolveJavadoc; |
87 | 77 | |
88 | 78 | /** |
89 | 79 | * Location for the list of POMs file. |
90 | * | |
91 | * @required | |
92 | * @parameter expression="debian/${package}.poms" | |
93 | 80 | */ |
81 | @Parameter(defaultValue = "debian/${package}.poms", required = true) | |
94 | 82 | protected File listOfPoms; |
95 | 83 | |
96 | 84 | /** |
97 | 85 | * Location of the Maven repository |
98 | * | |
99 | * @parameter expression="${maven.repo.local}" default-value="/usr/share/maven-repo" | |
100 | 86 | */ |
87 | @Parameter(property = "maven.repo.local", defaultValue = "/usr/share/maven-repo") | |
101 | 88 | protected File mavenRepo; |
102 | 89 | |
103 | 90 | /** |
104 | 91 | * Interactive execution will ask questions to the user |
105 | * | |
106 | * @parameter expression="${interactive}" default-value="true" | |
107 | 92 | */ |
93 | @Parameter(property = "interactive", defaultValue = "true") | |
108 | 94 | protected boolean interactive; |
109 | 95 | |
110 | 96 | /** |
111 | 97 | * Offline prevents any download from Internet |
112 | * | |
113 | * @parameter expression="${offline}" default-value="false" | |
114 | 98 | */ |
99 | @Parameter(property = "offline", defaultValue = "false") | |
115 | 100 | protected boolean offline; |
116 | 101 | |
117 | 102 | /** |
118 | 103 | * Try to be verbose |
119 | * | |
120 | * @parameter expression="${verbose}" default-value="false" | |
121 | 104 | */ |
105 | @Parameter(property = "verbose", defaultValue = "false") | |
122 | 106 | protected boolean verbose; |
123 | 107 | |
124 | 108 | public void execute() throws MojoExecutionException { |
+30
-53
34 | 34 | import org.apache.maven.model.Developer; |
35 | 35 | import org.apache.maven.plugin.AbstractMojo; |
36 | 36 | import org.apache.maven.plugin.MojoExecutionException; |
37 | import org.apache.maven.plugins.annotations.LifecyclePhase; | |
38 | import org.apache.maven.plugins.annotations.Mojo; | |
39 | import org.apache.maven.plugins.annotations.Parameter; | |
40 | import org.apache.maven.plugins.annotations.ResolutionScope; | |
37 | 41 | import org.apache.maven.project.MavenProject; |
38 | 42 | import org.apache.velocity.VelocityContext; |
39 | 43 | import org.apache.velocity.app.Velocity; |
47 | 51 | /** |
48 | 52 | * Generate the Debian files for packaging the current Maven project. |
49 | 53 | * |
50 | * @goal generate | |
51 | * @aggregator | |
52 | * @requiresDependencyResolution | |
53 | * @phase process-sources | |
54 | * | |
55 | 54 | * @author Ludovic Claude |
56 | 55 | */ |
56 | @Mojo(name = "generate", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.RUNTIME, aggregator = true) | |
57 | 57 | public class GenerateDebianFilesMojo extends AbstractMojo { |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * The Maven Project Object |
61 | * | |
62 | * @parameter expression="${project}" | |
63 | * @readonly | |
64 | * @required | |
65 | */ | |
61 | */ | |
62 | @Parameter(property = "project", required = true, readonly = true) | |
66 | 63 | protected MavenProject project; |
67 | 64 | |
68 | 65 | /** |
69 | 66 | * A list of every project in this reactor; provided by Maven |
70 | * | |
71 | * @parameter expression="${project.collectedProjects}" | |
72 | */ | |
67 | */ | |
68 | @Parameter(property = "project.collectedProjects") | |
73 | 69 | protected List<MavenProject> collectedProjects; |
74 | 70 | |
75 | /** | |
76 | * @parameter expression="${localRepository}" | |
77 | * @required | |
78 | * @readonly | |
79 | */ | |
71 | @Parameter(property = "localRepository", required = true, readonly = true) | |
80 | 72 | protected ArtifactRepository localRepository; |
81 | 73 | |
82 | 74 | /** |
83 | 75 | * Location of the file. |
84 | * | |
85 | * @parameter expression="${debian.directory}" | |
86 | * default-value="debian" | |
87 | */ | |
76 | */ | |
77 | @Parameter(defaultValue = "debian", property = "debian.directory") | |
88 | 78 | protected File outputDirectory; |
89 | 79 | |
90 | 80 | /** |
91 | 81 | * Name of the packager (e.g. 'Ludovic Claude') |
92 | * | |
93 | * @parameter expression="${packager}" | |
94 | * @required | |
95 | */ | |
82 | */ | |
83 | @Parameter(required = true, property = "packager") | |
96 | 84 | protected String packager; |
97 | 85 | |
98 | 86 | /** |
99 | 87 | * Email of the packager (e.g. 'ludovic.claude@laposte.net') |
100 | * | |
101 | * @parameter expression="${email}" | |
102 | * @required | |
103 | */ | |
88 | */ | |
89 | @Parameter(required = true, property = "email") | |
104 | 90 | protected String email; |
105 | 91 | |
106 | 92 | /** |
107 | 93 | * License used by the packager (e.g. 'GPL-3' or 'Apache-2.0') |
108 | 94 | * See http://dep.debian.net/deps/dep5/ for the list of licenses. |
109 | * | |
110 | * @parameter expression="${packagerLicense}" default-value="GPL-3" | |
111 | * @required | |
112 | */ | |
95 | */ | |
96 | @Parameter(required = true, property = "packagerLicense", defaultValue = "GPL-3") | |
113 | 97 | protected String packagerLicense; |
114 | 98 | |
115 | 99 | /** |
116 | 100 | * Name of the source package (e.g. 'commons-lang') |
117 | * | |
118 | * @parameter expression="${package}" | |
119 | * @required | |
120 | */ | |
101 | */ | |
102 | @Parameter(required = true, property = "package") | |
121 | 103 | protected String packageName; |
122 | 104 | |
123 | 105 | /** |
124 | 106 | * Name of the binary package (e.g. 'libcommons-lang-java') |
125 | * | |
126 | * @parameter expression="${bin.package}" | |
127 | * @required | |
128 | */ | |
107 | */ | |
108 | @Parameter(required = true, property = "bin.package") | |
129 | 109 | protected String binPackageName; |
130 | 110 | |
131 | 111 | /** |
132 | 112 | * Type of the package (e.g. 'maven' or 'ant') |
133 | * | |
134 | * @parameter expression="${packageType}" default-value="maven" | |
135 | */ | |
113 | */ | |
114 | @Parameter(property = "packageType", defaultValue = "maven") | |
136 | 115 | protected String packageType; |
137 | 116 | |
138 | 117 | /** |
139 | 118 | * URL for downloading the source code, in the form scm:[svn|cvs]:http://xxx/ |
140 | 119 | * for downloads using a source code repository, |
141 | 120 | * or http://xxx.[tar|zip|gz|tgz] for downloads using source tarballs. |
142 | * | |
143 | * @parameter expression="${downloadUrl}" | |
144 | */ | |
121 | */ | |
122 | @Parameter(property = "downloadUrl") | |
145 | 123 | protected String downloadUrl; |
146 | 124 | |
147 | 125 | /** |
148 | 126 | * If true, include running the tests during the build. |
149 | * | |
150 | * @parameter expression="${runTests}" default-value="false" | |
151 | */ | |
127 | */ | |
128 | @Parameter(property = "runTests", defaultValue = "false") | |
152 | 129 | protected boolean runTests; |
153 | 130 | |
154 | 131 | /** |
155 | 132 | * If true, generate the Javadoc packaged in a separate package. |
156 | * @parameter expression="${generateJavadoc}" default-value="false" | |
157 | */ | |
133 | */ | |
134 | @Parameter(property = "generateJavadoc", defaultValue = "false") | |
158 | 135 | protected boolean generateJavadoc; |
159 | 136 | |
160 | 137 | /** |
+0
-1
18 | 18 | import java.io.BufferedReader; |
19 | 19 | import java.io.IOException; |
20 | 20 | import java.io.InputStreamReader; |
21 | import java.io.PrintStream; | |
22 | 21 | import java.io.PrintWriter; |
23 | 22 | |
24 | 23 | /** |
+5
-3
28 | 28 | import java.util.List; |
29 | 29 | import java.util.logging.Level; |
30 | 30 | import java.util.logging.Logger; |
31 | ||
31 | 32 | import junit.framework.TestCase; |
32 | import org.apache.commons.io.FileUtils; | |
33 | import org.apache.commons.io.IOUtils; | |
33 | ||
34 | import org.codehaus.plexus.util.FileUtils; | |
35 | import org.codehaus.plexus.util.IOUtil; | |
34 | 36 | import org.debian.maven.packager.util.PackageScanner; |
35 | 37 | import org.debian.maven.repo.DependencyRule; |
36 | 38 | |
342 | 344 | protected void useFile(String resource, File file) throws IOException { |
343 | 345 | final FileWriter out = new FileWriter(file); |
344 | 346 | final Reader in = read(resource); |
345 | IOUtils.copy(in,out); | |
347 | IOUtil.copy(in,out); | |
346 | 348 | in.close(); |
347 | 349 | out.close(); |
348 | 350 | } |
+2
-2
15 | 15 | |
16 | 16 | package org.debian.maven.packager.util; |
17 | 17 | |
18 | import org.junit.Test; | |
18 | import static org.junit.Assert.assertEquals; | |
19 | 19 | |
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.List; |
22 | 22 | |
23 | import static junit.framework.Assert.assertEquals; | |
23 | import org.junit.Test; | |
24 | 24 | |
25 | 25 | public class GetPackageContainingPatternResultTest { |
26 | 26 |
+2
-2
15 | 15 | |
16 | 16 | package org.debian.maven.packager.util; |
17 | 17 | |
18 | import org.junit.Test; | |
18 | import static org.junit.Assert.assertEquals; | |
19 | 19 | |
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.List; |
22 | 22 | |
23 | import static junit.framework.Assert.assertEquals; | |
23 | import org.junit.Test; | |
24 | 24 | |
25 | 25 | public class GetPackageResultTest { |
26 | 26 |
+2
-2
15 | 15 | |
16 | 16 | package org.debian.maven.packager.util; |
17 | 17 | |
18 | import org.junit.Test; | |
18 | import static org.junit.Assert.assertEquals; | |
19 | 19 | |
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.List; |
22 | 22 | |
23 | import static junit.framework.Assert.assertEquals; | |
23 | import org.junit.Test; | |
24 | 24 | |
25 | 25 | public class GetPackageVersionResultTest { |
26 | 26 |
3 | 3 | |
4 | 4 | <groupId>org.debian.maven</groupId> |
5 | 5 | <artifactId>maven-debian</artifactId> |
6 | <version>1.7</version> | |
6 | <version>2.0</version> | |
7 | 7 | <packaging>pom</packaging> |
8 | 8 | <description>Helper tools for using Maven to build Debian packages</description> |
9 | ||
10 | <properties> | |
11 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
12 | <maven-plugin-tools.version>3.2</maven-plugin-tools.version> | |
13 | </properties> | |
9 | 14 | |
10 | 15 | <modules> |
11 | 16 | <module>maven-debian-helper</module> |
12 | 17 | <module>debian-maven-plugin</module> |
13 | <module>maven-build-nodocs</module> | |
14 | 18 | <module>maven-packager-utils</module> |
15 | 19 | </modules> |
16 | ||
17 | <dependencies> | |
18 | <dependency> | |
19 | <groupId>org.apache.maven</groupId> | |
20 | <artifactId>maven-core</artifactId> | |
21 | <version>2.2.1</version> | |
22 | </dependency> | |
23 | <dependency> | |
24 | <groupId>org.apache.maven</groupId> | |
25 | <artifactId>maven-compat</artifactId> | |
26 | <version>2.2.1</version> | |
27 | </dependency> | |
28 | <dependency> | |
29 | <groupId>org.codehaus.plexus</groupId> | |
30 | <artifactId>plexus-utils</artifactId> | |
31 | <version>1.5.8</version> | |
32 | </dependency> | |
33 | </dependencies> | |
34 | 20 | |
35 | 21 | <dependencyManagement> |
36 | 22 | <dependencies> |
37 | 23 | <dependency> |
38 | 24 | <groupId>org.debian.maven</groupId> |
39 | 25 | <artifactId>maven-repo-helper</artifactId> |
40 | <version>1.8.9</version> | |
26 | <version>[1.8,2.0)</version> | |
41 | 27 | </dependency> |
42 | 28 | <dependency> |
43 | 29 | <groupId>org.apache.maven</groupId> |
44 | 30 | <artifactId>maven-plugin-api</artifactId> |
45 | <version>2.2.1</version> | |
31 | <version>3.0.5</version> | |
46 | 32 | </dependency> |
47 | 33 | <dependency> |
48 | 34 | <groupId>org.apache.maven</groupId> |
49 | <artifactId>maven-artifact</artifactId> | |
50 | <version>2.2.1</version> | |
51 | </dependency> | |
52 | <dependency> | |
53 | <groupId>classworlds</groupId> | |
54 | <artifactId>classworlds</artifactId> | |
55 | <version>1.1</version> | |
35 | <artifactId>maven-core</artifactId> | |
36 | <version>3.0.5</version> | |
56 | 37 | </dependency> |
57 | 38 | <dependency> |
58 | 39 | <groupId>org.apache.maven</groupId> |
59 | <artifactId>maven-project</artifactId> | |
60 | <version>2.2.1</version> | |
40 | <artifactId>maven-embedder</artifactId> | |
41 | <version>3.0.5</version> | |
42 | </dependency> | |
43 | <dependency> | |
44 | <groupId>org.codehaus.plexus</groupId> | |
45 | <artifactId>plexus-classworlds</artifactId> | |
46 | <version>2.5.1</version> | |
61 | 47 | </dependency> |
62 | 48 | <dependency> |
63 | 49 | <groupId>org.apache.velocity</groupId> |
71 | 57 | <scope>test</scope> |
72 | 58 | </dependency> |
73 | 59 | <dependency> |
74 | <groupId>commons-io</groupId> | |
75 | <artifactId>commons-io</artifactId> | |
76 | <version>2.4</version> | |
77 | <scope>test</scope> | |
60 | <groupId>org.apache.maven.plugin-tools</groupId> | |
61 | <artifactId>maven-plugin-annotations</artifactId> | |
62 | <version>${maven-plugin-tools.version}</version> | |
63 | <scope>provided</scope> | |
78 | 64 | </dependency> |
79 | 65 | </dependencies> |
80 | 66 | </dependencyManagement> |
84 | 70 | <plugins> |
85 | 71 | <plugin> |
86 | 72 | <artifactId>maven-compiler-plugin</artifactId> |
87 | <version>2.1</version> | |
73 | <version>2.5.1</version> | |
88 | 74 | <configuration> |
89 | 75 | <source>1.6</source> |
90 | 76 | <target>1.6</target> |
91 | 77 | </configuration> |
92 | 78 | </plugin> |
79 | <plugin> | |
80 | <artifactId>maven-jar-plugin</artifactId> | |
81 | <version>2.4</version> | |
82 | </plugin> | |
83 | <plugin> | |
84 | <artifactId>maven-plugin-plugin</artifactId> | |
85 | <version>${maven-plugin-tools.version}</version> | |
86 | <executions> | |
87 | <execution> | |
88 | <id>default-descriptor</id> | |
89 | <phase>process-classes</phase> | |
90 | <goals> | |
91 | <goal>descriptor</goal> | |
92 | </goals> | |
93 | </execution> | |
94 | </executions> | |
95 | </plugin> | |
93 | 96 | </plugins> |
94 | 97 | </pluginManagement> |
95 | 98 | </build> |
32 | 32 | |
33 | 33 | # Maven home directory. Doesn't need to be changed except when using |
34 | 34 | # nonstandard Maven installations. |
35 | MAVEN_HOME = /usr/share/maven2 | |
35 | MAVEN_HOME = /usr/share/maven | |
36 | 36 | |
37 | 37 | MAVEN_DEBIAN_VERSION = $(shell ls /usr/share/maven-repo/org/debian/maven/maven-packager-utils/ | sed 's|/||') |
38 | MAVEN_CLASSCONF = /etc/maven2/m2-debian.conf | |
38 | MAVEN_CLASSCONF = /etc/maven/m2-debian.conf | |
39 | MAVEN_SETTINGS = /etc/maven/settings-debian.xml | |
39 | 40 | |
40 | 41 | # The home directory of the Java Runtime Environment (JRE) or Java Development |
41 | 42 | # Kit (JDK). You can either directly set JAVA_HOME in debian/rules or set |
53 | 54 | # end of the class path if it exists in the JDK's lib directory. |
54 | 55 | # You can override the complete class path using DEB_CLASSPATH. |
55 | 56 | DEB_JARS_BASE = /usr/share/java |
56 | DEB_CLASSPATH = $(MAVEN_HOME)/boot/classworlds.jar:$(shell for jar in $(DEB_JARS); do \ | |
57 | DEB_CLASSPATH = $(MAVEN_HOME)/boot/plexus-classworlds-2.x.jar:$(shell for jar in $(DEB_JARS); do \ | |
57 | 58 | if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; \ |
58 | 59 | if [ -f "$$jar".jar ]; then echo -n "$${jar}.jar:"; fi; \ |
59 | 60 | if [ -f $(DEB_JARS_BASE)/"$$jar" ]; then echo -n "$(DEB_JARS_BASE)/$${jar}:"; fi; \ |
93 | 94 | DEB_MAVEN_INVOKE = cd $(DEB_BUILDDIR) && $(JAVACMD) -noverify -cp $(DEB_CLASSPATH) \ |
94 | 95 | $(JAVA_OPTS) -Dclassworlds.conf=$(MAVEN_CLASSCONF) \ |
95 | 96 | org.codehaus.classworlds.Launcher \ |
96 | -s/etc/maven2/settings-debian.xml \ | |
97 | -s$(MAVEN_SETTINGS) \ | |
97 | 98 | -Dmaven.repo.local=$(DEB_MAVEN_REPO) \ |
98 | 99 | $(if $(DEB_MAVEN_ARGS_$(cdbs_curpkg)),$(DEB_MAVEN_ARGS_$(cdbs_curpkg)),$(DEB_MAVEN_ARGS)) |
99 | 100 |
31 | 31 | include $(_cdbs_class_path)/maven-vars.mk$(_cdbs_makefile_suffix) |
32 | 32 | |
33 | 33 | DEB_MAVEN_REPO := $(CURDIR)/debian/maven-repo |
34 | DEB_MAVEN_SCRIPT_DIR := /usr/share/maven-debian-helper/ | |
34 | 35 | |
35 | 36 | JAVA_OPTS = \ |
36 | 37 | $(shell test -n "$(DEB_MAVEN_PROPERTYFILE)" && echo -Dproperties.file.manual=$(DEB_MAVEN_PROPERTYFILE)) |
52 | 53 | echo "You must specify a valid JAVA_HOME or JAVACMD!"; \ |
53 | 54 | exit 1; \ |
54 | 55 | fi |
55 | @if ! test -r "$(MAVEN_HOME)/boot/classworlds.jar"; then \ | |
56 | @if ! test -r "$(MAVEN_HOME)/boot/plexus-classworlds-2.x.jar"; then \ | |
56 | 57 | echo "You must specify a valid MAVEN_HOME directory!"; \ |
57 | 58 | exit 1; \ |
58 | 59 | fi |
65 | 66 | |
66 | 67 | ifeq (, $(DEB_DOC_PACKAGE)) |
67 | 68 | DEB_PATCHPOMS_ARGS += --build-no-docs |
68 | debian/stamp-maven-build: override MAVEN_CLASSCONF = /etc/maven2/m2-debian-nodocs.conf | |
69 | 69 | endif |
70 | 70 | |
71 | 71 | debian/stamp-poms-patched: debian/maven-repo |
79 | 79 | $(RM) -f debian/stamp-poms-patched |
80 | 80 | |
81 | 81 | debian/maven-repo: |
82 | /usr/share/maven-debian-helper/copy-repo.sh $(CURDIR)/debian | |
82 | $(DEB_MAVEN_SCRIPT_DIR)/copy-repo.sh $(CURDIR)/debian | |
83 | 83 | |
84 | 84 | post-patches:: patch-poms |
85 | 85 |
17 | 17 | |
18 | 18 | SRC_REPO="/usr/share/maven-repo" |
19 | 19 | DEST_REPO="$1/maven-repo" |
20 | PLUGIN_GROUPS="org.apache.maven.plugins org.codehaus.mojo" | |
21 | METADATA_NAME="maven-metadata-local.xml" | |
20 | 22 | |
21 | 23 | find_src_poms() { |
22 | 24 | find -L $SRC_REPO -name '*.pom' -printf '%P\n' |
23 | 25 | } |
24 | 26 | |
27 | find_group_artifact_ids() { | |
28 | find -L $SRC_REPO/$1/* -type d -prune -printf '%f\n' | |
29 | } | |
30 | ||
31 | read_maven_plugin_xpath() { | |
32 | unzip -q -c "$1" META-INF/maven/plugin.xml 2>/dev/null | xmllint --xpath "$2" - 2>/dev/null | |
33 | } | |
34 | ||
25 | 35 | list_fakes() |
26 | 36 | { |
27 | CONFFILES="/etc/maven2/fake-poms.conf" | |
37 | CONFFILES="/etc/maven/fake-poms.conf" | |
28 | 38 | if [ -r debian/fake-poms.conf ] |
29 | 39 | then |
30 | 40 | CONFFILES="$CONFFILES debian/fake-poms.conf" |
31 | 41 | fi |
32 | 42 | sed -e's,#.*,,' $CONFFILES |
33 | } | |
34 | ||
35 | find_all_meta() { | |
36 | find $DEST_REPO -name 'maven-metadata-tmp.xml' | |
37 | } | |
38 | ||
39 | header() { | |
40 | echo '<?xml version="1.0" encoding="UTF-8"?>' | |
41 | echo '<metadata>' | |
42 | echo ' <versioning>' | |
43 | echo ' <versions>' | |
44 | } | |
45 | ||
46 | footer() { | |
47 | echo ' </versions>' | |
48 | echo ' </versioning>' | |
49 | echo '</metadata>' | |
50 | } | |
51 | ||
52 | echo_meta() { | |
53 | header | |
54 | cat $META | |
55 | footer | |
56 | 43 | } |
57 | 44 | |
58 | 45 | if [ -z "$1" ]; then |
98 | 85 | .EOF |
99 | 86 | done |
100 | 87 | |
101 | find_all_meta | while read META; do | |
102 | DIR=$(dirname $META) | |
103 | echo_meta > $DIR/maven-metadata-local.xml | |
104 | rm -f $META | |
88 | # construct plugin metadata | |
89 | for groupId in $PLUGIN_GROUPS; do | |
90 | GROUP=$(echo $groupId | tr . \/) | |
91 | if test ! -d "$DEST_REPO/$GROUP"; then | |
92 | continue | |
93 | fi | |
94 | ||
95 | # plugin group metadata | |
96 | cat > $DEST_REPO/$GROUP/$METADATA_NAME <<EOF | |
97 | <metadata> | |
98 | <plugins> | |
99 | EOF | |
100 | find_group_artifact_ids $GROUP | while read artifactId; do | |
101 | for jar in $SRC_REPO/$GROUP/$artifactId/*/*.jar; do | |
102 | prefix=$(read_maven_plugin_xpath "$jar" '/plugin/goalPrefix/text()') | |
103 | if test -z "$prefix"; then | |
104 | continue | |
105 | fi | |
106 | name=$(read_maven_plugin_xpath "$jar" '/plugin/name/text()') | |
107 | cat >> $DEST_REPO/$GROUP/$METADATA_NAME <<EOF | |
108 | <plugin> | |
109 | <name>$name</name> | |
110 | <prefix>$prefix</prefix> | |
111 | <artifactId>$artifactId</artifactId> | |
112 | </plugin> | |
113 | EOF | |
114 | break | |
115 | done | |
116 | done | |
117 | cat >> $DEST_REPO/$GROUP/$METADATA_NAME <<EOF | |
118 | </plugins> | |
119 | </metadata> | |
120 | EOF | |
121 | ||
122 | # plugin version metadata | |
123 | find_group_artifact_ids $GROUP | while read artifactId; do | |
124 | cat > $DEST_REPO/$GROUP/$artifactId/$METADATA_NAME <<EOF | |
125 | <metadata> | |
126 | <groupId>$groupId</groupId> | |
127 | <artifactId>$artifactId</artifactId> | |
128 | <versioning> | |
129 | <versions> | |
130 | EOF | |
131 | find $SRC_REPO/$GROUP/$artifactId/*/*.jar | while read jar; do | |
132 | version=$(basename $(dirname $jar)) | |
133 | cat >> $DEST_REPO/$GROUP/$artifactId/$METADATA_NAME <<EOF | |
134 | <version>$version</version> | |
135 | EOF | |
136 | done | |
137 | cat >> $DEST_REPO/$GROUP/$artifactId/$METADATA_NAME <<EOF | |
138 | </versions> | |
139 | </versioning> | |
140 | </metadata> | |
141 | EOF | |
142 | done | |
105 | 143 | done |
106 |
25 | 25 | my @packages = @{$dh{DOPACKAGES}}; |
26 | 26 | $this->{package} = shift @packages; |
27 | 27 | $this->{doc_package} = (grep /-doc$/, @packages)[0]; |
28 | my $classconf = '/etc/maven2/m2-debian.conf'; | |
29 | if (!$this->{doc_package}) { | |
30 | $classconf = '/etc/maven2/m2-debian-nodocs.conf'; | |
31 | } | |
28 | my $classconf = '/etc/maven/m2-debian.conf'; | |
32 | 29 | |
33 | my @classpath = ('/usr/share/maven2/boot/classworlds.jar'); | |
30 | my @classpath = ('/usr/share/maven/boot/classworlds-2.x.jar'); | |
34 | 31 | if (-e "$java_home/lib/tools.jar") { |
35 | 32 | push(@classpath, "$java_home/lib/tools.jar"); |
36 | 33 | } |
44 | 41 | @{$this->{maven_cmd}} = ($java_home . '/bin/java', |
45 | 42 | @jvmopts, |
46 | 43 | "org.codehaus.classworlds.Launcher", |
47 | "-s/etc/maven2/settings-debian.xml", | |
44 | "-s/etc/maven/settings-debian.xml", | |
48 | 45 | "-Ddebian.dir=$this->{cwd}/debian", |
49 | 46 | "-Dmaven.repo.local=$this->{cwd}/debian/maven-repo"); |
50 | 47 | return $this; |
53 | 50 | sub configure { |
54 | 51 | my $this=shift; |
55 | 52 | my @patch_args; |
56 | if (! $this->{doc_package}) { | |
57 | push(@patch_args, "--build-no-docs"); | |
58 | } | |
59 | 53 | |
60 | 54 | doit("/usr/share/maven-debian-helper/copy-repo.sh", "$this->{cwd}/debian"); |
61 | 55 | $this->doit_in_sourcedir("mh_patchpoms", "-p$this->{package}", |