Author: ludovicc-guest Date: 2009-04-10 17:28:26 +0000 (Fri, 10 Apr 2009) New Revision: 8184
Added: trunk/maven-repo-helper/debian/maven-repo-helper.postinst trunk/maven-repo-helper/debian/maven-repo-helper.postrm trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java Modified: trunk/maven-repo-helper/debian/changelog trunk/maven-repo-helper/debian/control trunk/maven-repo-helper/debian/rules trunk/maven-repo-helper/pom.xml trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DebianPOM.java trunk/maven-repo-helper/src/main/share/postrm.tmpl trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/DebianPOMTest.java trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java Log: * Deploy the jar and the pom to the Maven repository Modified: trunk/maven-repo-helper/debian/changelog =================================================================== --- trunk/maven-repo-helper/debian/changelog 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/debian/changelog 2009-04-10 17:28:26 UTC (rev 8184) @@ -1,4 +1,4 @@ -maven-repo-helper (0.1) jaunty; urgency=low +maven-repo-helper (0.1) unstable; urgency=low * Initial release. (Closes: #521947) Modified: trunk/maven-repo-helper/debian/control =================================================================== --- trunk/maven-repo-helper/debian/control 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/debian/control 2009-04-10 17:28:26 UTC (rev 8184) @@ -7,10 +7,33 @@ Standards-Version: 3.8.1 Vcs-Bzr: lp:~ludovicc/maven-packaging-support/maven-repo-helper Vcs-Browser: http://bazaar.launchpad.net/~ludovicc/maven-packaging-support/maven-repo-helper/files -Homepage: https://code.launchpad.net/maven-packaging-support/ +Homepage: https://launchpad.net/maven-packaging-support Package: maven-repo-helper Architecture: all Depends: ${misc:Depends}, default-jre-headless | java2-runtime-headless -Description: Provides support for managing the Maven repository in a Debian distribution. +Suggests: maven-debian-helper +Description: Helper tools for including Maven metatada in Debian packages + Maven is a software project management and comprehension tool. Based on the + concept of a project object model (POM), Maven can manage a project's build, + reporting and documentation from a central piece of information. . + Maven's primary goal is to allow a developer to comprehend the complete + state of a development effort in the shortest period of time. In order to + attain this goal there are several areas of concern that Maven attempts + to deal with: + . + * Making the build process easy + * Providing a uniform build system + * Providing quality project information + * Providing guidelines for best practices development + * Allowing transparent migration to new features + . + This package enables Debian packages which are not using Maven in their + build process to provide and install Maven POMs and libraries in the + repository located in /usr/share/maven-repo. + . + Packages built with Maven (using maven-debian-helper) will benefit as + many of their dependencies are already packaged in Debian but they are + missing the necessary metadata (Maven POM) which is required by Maven + when its using dependencies. Added: trunk/maven-repo-helper/debian/maven-repo-helper.postinst =================================================================== --- trunk/maven-repo-helper/debian/maven-repo-helper.postinst (rev 0) +++ trunk/maven-repo-helper/debian/maven-repo-helper.postinst 2009-04-10 17:28:26 UTC (rev 8184) @@ -0,0 +1,45 @@ +#!/bin/sh -e + +DEBIAN_POM="/usr/share/maven-repo/org/debian/debian-parent/1.0-SNAPSHOT/debian-parent-1.0-SNAPSHOT.pom" + +LIBRARIES="org.debian.maven.maven-repo-helper 0.1" +PACKAGE="maven-repo-helper" + +if [ ! -f $DEBIAN_POM ]; then + mkdir -p $(dirname $DEBIAN_POM) + echo "<?xml version="1.0" encoding="UTF-8"?>" > $DEBIAN_POM + echo "<project>" >> $DEBIAN_POM + echo " <groupId>org.debian</groupId>" >> $DEBIAN_POM + echo " <artifactId>debian-parent</artifactId>" >> $DEBIAN_POM + echo " <version>1.0-SNAPSHOT</version>" >> $DEBIAN_POM + echo " <properties>" >> $DEBIAN_POM + echo " </properties>" >> $DEBIAN_POM + echo "</project>" >> $DEBIAN_POM +fi + +add_repo_property() { + VERSION_PROPERTY=$1 + LIBVER=$2 + if [ $(grep "<${VERSION_PROPERTY}\.version>" $DEBIAN_POM) ]; then + # Update version + cat $DEBIAN_POM | sed "s,<${VERSION_PROPERTY}\.version>.*</,<${VERSION_PROPERTY}.version>$LIBVER</," > pom.tmp + else + cat $DEBIAN_POM | grep -v "</properties>" | grep -v "</project>" > pom.tmp + echo " <${VERSION_PROPERTY}.package>$PACKAGE</${VERSION_PROPERTY}.package>" >> pom.tmp + echo " <${VERSION_PROPERTY}.version>$LIBVER</${VERSION_PROPERTY}.version>" >> pom.tmp + echo " </properties>" >> pom.tmp + echo "</project>" >> pom.tmp + fi + rm $DEBIAN_POM + mv pom.tmp $DEBIAN_POM +} + +if [ "$1" = "configure" ]; then + echo $LIBRARIES | tr ',' '\n' | while read VERSION_PROPERTY LIBVER; do + if [ ! -z "$VERSION_PROPERTY" ]; then + add_repo_property $VERSION_PROPERTY $LIBVER + fi + done +fi + +#DEBHELPER# \ No newline at end of file Added: trunk/maven-repo-helper/debian/maven-repo-helper.postrm =================================================================== --- trunk/maven-repo-helper/debian/maven-repo-helper.postrm (rev 0) +++ trunk/maven-repo-helper/debian/maven-repo-helper.postrm 2009-04-10 17:28:26 UTC (rev 8184) @@ -0,0 +1,48 @@ +#!/bin/sh -e + +DEBIAN_POM="/usr/share/maven-repo/org/debian/debian-parent/1.0-SNAPSHOT/debian-parent-1.0-SNAPSHOT.pom" + +LIBRARIES="org.debian.maven.maven-repo-helper 0.1" + +remove_repo_property() { + VERSION_PROPERTY=$1 + cat $DEBIAN_POM | grep -v "<$VERSION_PROPERTY" > pom.tmp + rm $DEBIAN_POM + mv pom.tmp $DEBIAN_POM +} + +properties_start_tag_line() { + grep -n "<properties>" $DEBIAN_POM | cut -d':' -f1 +} + +properties_end_tag_line() { + grep -n "</properties>" $DEBIAN_POM | cut -d':' -f1 +} + +case "$1" in + remove|purge) + echo $LIBRARIES | tr ',' '\n' | while read VERSION_PROPERTY LIBVER; do + if [ ! -z "$VERSION_PROPERTY" ]; then + remove_repo_property $VERSION_PROPERTY + fi + done + # Detect if DEBIAN_POM is empty + TAG_START=$(properties_start_tag_line) + TAG_END=$(properties_end_tag_line) + if [ $(($TAG_START+1)) -eq $TAG_END ]; then + rm $DEBIAN_POM + rmdir --ignore-fail-on-non-empty -p $(dirname $DEBIAN_POM) + fi + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + # Nothing to do here + ;; + + *) + echo "$0 called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# \ No newline at end of file Modified: trunk/maven-repo-helper/debian/rules =================================================================== --- trunk/maven-repo-helper/debian/rules 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/debian/rules 2009-04-10 17:28:26 UTC (rev 8184) @@ -30,14 +30,21 @@ build/$(PACKAGE):: man-pages binary-post-install/$(PACKAGE):: - dh_install -p$(PACKAGE) build/$(PACKAGE)-$(VERSION).jar /usr/share/java + dh_install -p$(PACKAGE) build/$(PACKAGE)-$(VERSION).jar /usr/share/maven-repo/org/debian/maven/$(PACKAGE)/$(VERSION) dh_install -p$(PACKAGE) src/main/bin /usr dh_install -p$(PACKAGE) src/main/share/* /usr/share/$(PACKAGE) - dh_link -p$(PACKAGE) /usr/share/java/$(PACKAGE)-$(VERSION).jar /usr/share/java/$(PACKAGE).jar + dh_link -p$(PACKAGE) /usr/share/maven-repo/org/debian/maven/$(PACKAGE)/$(VERSION)/$(PACKAGE)-$(VERSION).jar /usr/share/java/$(PACKAGE).jar dh_link -p$(PACKAGE) /usr/share/$(PACKAGE)/postinst.tmpl /usr/share/debhelper/autoscripts/postinst-maven-repo dh_link -p$(PACKAGE) /usr/share/$(PACKAGE)/postrm.tmpl /usr/share/debhelper/autoscripts/postrm-maven-repo dh_installman $(MAN_PAGES) + mkdir -p debian/tmp + java -cp build/$(PACKAGE)-$(VERSION).jar org.debian.maven.repo.POMCleaner --debian-parent pom.xml debian/tmp/$(PACKAGE)-$(VERSION).pom debian/tmp/pom.properties debian/tmp/versions.properties + dh_install -p$(PACKAGE) --sourcedir=debian/tmp $(PACKAGE)-$(VERSION).pom \ + usr/share/maven-repo/org/debian/maven/$(PACKAGE)/$(VERSION) +clean:: + -rm -r debian/tmp + $(SCRIPTS): help2man $(basename ) Modified: trunk/maven-repo-helper/pom.xml =================================================================== --- trunk/maven-repo-helper/pom.xml 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/pom.xml 2009-04-10 17:28:26 UTC (rev 8184) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.debian</groupId> + <groupId>org.debian.maven</groupId> <artifactId>maven-repo-helper</artifactId> <name>Maven Repo helper</name> <packaging>jar</packaging> @@ -10,7 +10,7 @@ Provides support for managing the Maven repository in a Debian distribution. </description> - <inceptionYear>2001</inceptionYear> + <inceptionYear>2009</inceptionYear> <url>https://code.launchpad.net/maven-packaging-support/</url> <licenses> <license> @@ -49,6 +49,14 @@ <target>1.5</target> </configuration> </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>**/*Test.java</include> + </includes> + </configuration> + </plugin> </plugins> </build> Modified: trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DebianPOM.java =================================================================== --- trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DebianPOM.java 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/src/main/java/org/debian/maven/repo/DebianPOM.java 2009-04-10 17:28:26 UTC (rev 8184) @@ -118,8 +118,8 @@ parser.close(); } - for (Iterator i = remainingProperties.entrySet().iterator(); i.hasNext(); ) { - Map.Entry entry = (Map.Entry)i.next(); + for (Iterator i = remainingProperties.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); writer.writeCharacters("\n\t\t"); writer.writeStartElement((String) entry.getKey()); writer.writeCharacters((String) entry.getValue()); @@ -258,31 +258,27 @@ } public static void main(String[] args) { - try { - DebianPOM dp = new DebianPOM(); - File pom = new File(args[1]); - File updatedPom = File.createTempFile("pom", "tmp"); + DebianPOM dp = new DebianPOM(); + File pom = new File(args[1]); + File updatedPom = new File(args[1] + ".tmp"); - if (args[0].equals("add")) { - String property = args[2]; - String version = args[3]; - String pkg = args[4]; + if (args[0].equals("add")) { + String property = args[2]; + String version = args[3]; + String pkg = args[4]; - Map properties = new HashMap(); - properties.put(property + ".version", version); - properties.put(property + ".package", pkg); - dp.addLibrary(pom, updatedPom, properties); + Map properties = new HashMap(); + properties.put(property + ".version", version); + properties.put(property + ".package", pkg); + dp.addLibrary(pom, updatedPom, properties); - } else if (args[0].equals("remove")) { - String property = args[2]; - dp.removeLibrary(pom, updatedPom, property + ".version", property + ".package"); - } else { - System.err.println("Invalid arguments. Syntax is"); - System.err.println("mvn-repo add <property> <version> <package>"); - System.err.println("mvn-repo remove <property>"); - } - } catch (IOException ex) { - log.log(Level.SEVERE, null, ex); + } else if (args[0].equals("remove")) { + String property = args[2]; + dp.removeLibrary(pom, updatedPom, property + ".version", property + ".package"); + } else { + System.err.println("Invalid arguments. Syntax is"); + System.err.println("mvn-repo add <property> <version> <package>"); + System.err.println("mvn-repo remove <property>"); } } } Modified: trunk/maven-repo-helper/src/main/share/postrm.tmpl =================================================================== --- trunk/maven-repo-helper/src/main/share/postrm.tmpl 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/src/main/share/postrm.tmpl 2009-04-10 17:28:26 UTC (rev 8184) @@ -17,7 +17,8 @@ grep -n "</properties>" $DEBIAN_POM | cut -d':' -f1 } -if [ "$1" = "remove" ]; then +case "$1" in + remove|purge) echo $LIBRARIES | tr ',' '\n' | while read VERSION_PROPERTY LIBVER; do if [ ! -z "$VERSION_PROPERTY" ]; then remove_repo_property $VERSION_PROPERTY @@ -30,5 +31,15 @@ rm $DEBIAN_POM rmdir --ignore-fail-on-non-empty -p $(dirname $DEBIAN_POM) fi -fi + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + # Nothing to do here + ;; + + *) + echo "$0 called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/DebianPOMTest.java =================================================================== --- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/DebianPOMTest.java 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/DebianPOMTest.java 2009-04-10 17:28:26 UTC (rev 8184) @@ -14,7 +14,7 @@ * * @author ludo */ -public class DebianPOMTest extends BaseTest { +public class DebianPOMTest extends TestBase { Map<String, String> libraryProperties; Modified: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java =================================================================== --- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java 2009-04-08 09:32:30 UTC (rev 8183) +++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/POMCleanerTest.java 2009-04-10 17:28:26 UTC (rev 8184) @@ -15,7 +15,7 @@ * * @author ludo */ -public class POMCleanerTest extends BaseTest { +public class POMCleanerTest extends TestBase { private File pomProperties; private File versionProperties; Added: trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java =================================================================== --- trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java (rev 0) +++ trunk/maven-repo-helper/src/test/java/org/debian/maven/repo/TestBase.java 2009-04-10 17:28:26 UTC (rev 8184) @@ -0,0 +1,95 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.debian.maven.repo; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.commons.io.IOUtils; +import org.custommonkey.xmlunit.XMLUnit; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + +/** + * + * @author ludo + */ +public class TestBase { + + protected static File testDir = new File("tmp"); + private List<Reader> openedReaders = new ArrayList(); + protected File pom; + protected File updatedPom; + + @BeforeClass + public static void setUpClass() throws Exception { + testDir.mkdir(); + XMLUnit.setIgnoreWhitespace(true); + } + + @AfterClass + public static void tearDownClass() throws Exception { + testDir.delete(); + } + + @Before + public void setUp() { + pom = new File(testDir, "original.pom"); + updatedPom = new File(testDir, "updated.pom"); + } + + @After + public void tearDown() { + if (pom.exists()) { + pom.delete(); + } + if (updatedPom.exists()) { + updatedPom.delete(); + } + for (Reader reader : openedReaders) { + try { + reader.close(); + } catch (IOException ex) { + Logger.getLogger(TestBase.class.getName()).log(Level.SEVERE, null, ex); + } + } + openedReaders.clear(); + } + + protected void useFile(String resource, File file) throws IOException { + final FileWriter out = new FileWriter(file); + final Reader in = read(resource); + IOUtils.copy( in,out); + in.close(); + out.close(); + } + + protected void usePom(String resource) throws IOException { + useFile(resource, pom); + } + + protected Reader read(String resource) { + Reader r = new InputStreamReader(this.getClass().getResourceAsStream("/" + resource)); + openedReaders.add(r); + return r; + } + + protected Reader read(File f) throws FileNotFoundException { + Reader r = new FileReader(f); + openedReaders.add(r); + return r; + } + +} \ No newline at end of file _______________________________________________ pkg-java-commits mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/pkg-java-commits

