From d7a64d712d1dfbe09d7c62fd6220673f3631b29f Mon Sep 17 00:00:00 2001 From: Daniel Pocock Date: Fri, 22 Aug 2014 14:44:19 +0000 Subject: [PATCH] Debian - Maven build. This adapts the Debian package to build all the Java tools and the library just using Maven, not using Ant any more. This depends on the patch submitted earlier in the email titled "build the tools and libraries all at once with Maven" Author: daniel@pocock.pro R=jia.shao.peng@gmail.com BUG= Review URL: https://codereview.appspot.com/126430044 --- debian/control | 42 +++++++++++++------- debian/libphonenumber6-java.poms | 39 ++++++++++++++++++ debian/maven.cleanIgnoreRules | 17 ++++++++ debian/maven.ignoreRules | 23 +++++++++++ debian/maven.properties | 4 ++ debian/maven.publishedRules | 19 +++++++++ debian/maven.rules | 31 +++++++++++++++ debian/patches/0003-maven-exclude-demo.patch | 13 ++++++ debian/patches/series | 1 + debian/rules | 42 +++++++++++++------- debian/source/format | 2 +- 11 files changed, 202 insertions(+), 31 deletions(-) create mode 100644 debian/libphonenumber6-java.poms create mode 100644 debian/maven.cleanIgnoreRules create mode 100644 debian/maven.ignoreRules create mode 100644 debian/maven.properties create mode 100644 debian/maven.publishedRules create mode 100644 debian/maven.rules create mode 100644 debian/patches/0003-maven-exclude-demo.patch create mode 100644 debian/patches/series diff --git a/debian/control b/debian/control index a85096660..7492220ca 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,10 @@ Source: libphonenumber Priority: optional Maintainer: Debian Java Maintainers Uploaders: Daniel Pocock , Fredrik Roubert -Build-Depends: ant, - ant-optional, +Build-Depends: cdbs, cmake, debhelper (>= 9), default-jdk | java-sdk, - javahelper (>= 0.34), - junit, libboost-dev (>= 1.40), libboost-system-dev (>= 1.40), libboost-thread-dev (>= 1.40), @@ -16,13 +13,38 @@ Build-Depends: ant, libicu-dev (>= 4.4), libprotobuf-dev (>= 2.4), libre2-dev, - protobuf-compiler + maven-debian-helper (>= 1.5), + protobuf-compiler, + default-jdk-doc, + junit4, + libbuild-helper-maven-plugin-java, + libmaven-antrun-plugin-java, + libmaven-assembly-plugin-java, + libmaven-compiler-plugin-java, + libmaven-exec-plugin-java, + libmaven-jar-plugin-java, + libmaven-javadoc-plugin-java, + libmaven-war-plugin-java, + libprotobuf-java, + libservlet2.5-java, + libservlet2.5-java-doc Standards-Version: 3.9.5 Section: libs Homepage: http://code.google.com/p/libphonenumber/ Vcs-Browser: http://code.google.com/p/libphonenumber/source/browse/ Vcs-Svn: http://libphonenumber.googlecode.com/svn/trunk/ +Package: libphonenumber6-java +Section: java +Architecture: all +Depends: ${misc:Depends}, ${maven:Depends} +Recommends: ${maven:OptionalDepends} +Description: parsing/formatting/validating phone numbers - java + Google's common C++ and Java library for parsing, formatting, storing and + validating international phone numbers. + . + This package contains the runtime library JARs for Java users. + Package: libphonenumber6-dev Section: libdevel Architecture: any @@ -45,13 +67,3 @@ Description: parsing/formatting/validating phone numbers validating international phone numbers. . This package contains the runtime libraries for C++ users. - -Package: libphonenumber6-java -Section: java -Architecture: all -Depends: ${java:Depends}, ${misc:Depends} -Description: parsing/formatting/validating phone numbers - java - Google's common C++ and Java library for parsing, formatting, storing and - validating international phone numbers. - . - This package contains the runtime library JARs for Java users. diff --git a/debian/libphonenumber6-java.poms b/debian/libphonenumber6-java.poms new file mode 100644 index 000000000..810889407 --- /dev/null +++ b/debian/libphonenumber6-java.poms @@ -0,0 +1,39 @@ +# List of POM files for the package +# Format of this file is: +# [option]* +# where option can be: +# --ignore: ignore this POM and its artifact if any +# --ignore-pom: don't install the POM. To use on POM files that are created +# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms] +# --no-parent: remove the tag from the POM +# --package=: an alternative package to use when installing this POM +# and its artifact +# --has-package-version: to indicate that the original version of the POM is the same as the upstream part +# of the version for the package. +# --keep-elements=: a list of XML elements to keep in the POM +# during a clean operation with mh_cleanpom or mh_installpom +# --artifact=: path to the build artifact associated with this POM, +# it will be installed when using the command mh_install. [mh_install] +# --java-lib: install the jar into /usr/share/java to comply with Debian +# packaging guidelines +# --usj-name=: name to use when installing the library in /usr/share/java +# --usj-version=: version to use when installing the library in /usr/share/java +# --no-usj-versionless: don't install the versionless link in /usr/share/java +# --dest-jar=: the destination for the real jar. +# It will be installed with mh_install. [mh_install] +# --classifier=: Optional, the classifier for the jar. Empty by default. +# --site-xml=: Optional, the location for site.xml if it needs to be installed. +# Empty by default. [mh_install] +# +pom.xml +tools/java/pom.xml +tools/java/common/pom.xml +tools/java/cpp-build/pom.xml +tools/java/data/pom.xml +tools/java/java-build/pom.xml +java/pom.xml +java/libphonenumber/pom.xml --java-lib +java/internal/prefixmapper/pom.xml --java-lib +java/carrier/pom.xml --java-lib +java/geocoder/pom.xml --java-lib +java/demo/pom.xml --ignore diff --git a/debian/maven.cleanIgnoreRules b/debian/maven.cleanIgnoreRules new file mode 100644 index 000000000..d9825b6cd --- /dev/null +++ b/debian/maven.cleanIgnoreRules @@ -0,0 +1,17 @@ +# Maven clean ignore rules - ignore some Maven dependencies and plugins +# during the clean phase of a Maven build +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., this dependency is then removed +# from the POM before mvn clean is called +# junit junit jar s/3\..*/3.x/ + diff --git a/debian/maven.ignoreRules b/debian/maven.ignoreRules new file mode 100644 index 000000000..835f560f8 --- /dev/null +++ b/debian/maven.ignoreRules @@ -0,0 +1,23 @@ +# Maven ignore rules - ignore some Maven dependencies and plugins +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., this dependency is then removed +# from the POM +# junit junit jar s/3\..*/3.x/ + +net.kindleit maven-gae-plugin * * * * +org.apache.maven.plugins maven-assembly-plugin * * * * +org.apache.maven.plugins maven-javadoc-plugin * * * * +org.apache.maven.plugins maven-release-plugin * * * * +org.apache.maven.plugins maven-source-plugin * * * * +org.mortbay.jetty maven-jetty-plugin * * * * +org.sonatype.oss oss-parent * * * * diff --git a/debian/maven.properties b/debian/maven.properties new file mode 100644 index 000000000..7c29bd777 --- /dev/null +++ b/debian/maven.properties @@ -0,0 +1,4 @@ +# Include here properties to pass to Maven during the build. +# For example: +# maven.test.skip=true + diff --git a/debian/maven.publishedRules b/debian/maven.publishedRules new file mode 100644 index 000000000..77aa245e7 --- /dev/null +++ b/debian/maven.publishedRules @@ -0,0 +1,19 @@ +# Maven published rules - additional rules to publish, to help +# the packaging work of Debian maintainers using mh_make +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# - a regular expression of the form s/match/replace/ +# in this case, elements that match are transformed using +# the regex rule. +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., replacing the version with 3.x +# junit junit jar s/3\..*/3.x/ + diff --git a/debian/maven.rules b/debian/maven.rules new file mode 100644 index 000000000..3c71dfa85 --- /dev/null +++ b/debian/maven.rules @@ -0,0 +1,31 @@ +# Maven rules - transform Maven dependencies and plugins +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# - a regular expression of the form s/match/replace/ +# in this case, elements that match are transformed using +# the regex rule. +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., replacing the version with 3.x +# junit junit jar s/3\..*/3.x/ + +com.google.i18n.phonenumbers data-tools jar s/1\..*/1.x/ * * +com.google.i18n.phonenumbers libphonenumber-build-parent pom s/1\..*/1.x/ * * +com.google.i18n.phonenumbers tools pom s/1\..*/1.x/ * * +com.google.i18n.phonenumbers.tools common-build jar s/1\..*/1.x/ * * +com.google.i18n.phonenumbers.tools cpp-build jar s/1\..*/1.x/ * * +com.google.i18n.phonenumbers.tools java-build jar s/1\..*/1.x/ * * +com.googlecode.libphonenumber carrier jar s/1\..*/1.x/ * * +com.googlecode.libphonenumber geocoder jar s/2\..*/2.x/ * * +com.googlecode.libphonenumber libphonenumber-parent pom s/6\..*/6.x/ * * +com.googlecode.libphonenumber libphonenumber jar s/6\..*/6.x/ * * +com.googlecode.libphonenumber prefixmapper jar s/2\..*/2.x/ * * +junit junit jar s/4\..*/4.x/ * * +s/org.apache.tomcat/javax.servlet/ servlet-api jar s/.*/2.5/ * * diff --git a/debian/patches/0003-maven-exclude-demo.patch b/debian/patches/0003-maven-exclude-demo.patch new file mode 100644 index 000000000..1713f9a10 --- /dev/null +++ b/debian/patches/0003-maven-exclude-demo.patch @@ -0,0 +1,13 @@ +diff --git a/java/pom.xml b/java/pom.xml +index 4e7cdb5..eb68bcc 100644 +--- a/java/pom.xml ++++ b/java/pom.xml +@@ -76,7 +76,7 @@ + internal/prefixmapper + carrier + geocoder +- demo ++ + + + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 000000000..b2aab4757 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0003-maven-exclude-demo.patch diff --git a/debian/rules b/debian/rules index 8beed531c..7e24879f5 100755 --- a/debian/rules +++ b/debian/rules @@ -18,9 +18,13 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -ANT ?= ant +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/maven.mk + +JAVA_HOME := /usr/lib/jvm/default-java +DEB_MAVEN_DOC_TARGET := javadoc:jar javadoc:aggregate + CMAKE ?= cmake -JAVA_HOME ?= /usr/lib/jvm/default-java CMAKE_FLAGS := -DCMAKE_INSTALL_PREFIX=/usr CPP_BUILD := cpp/build @@ -45,31 +49,39 @@ ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) MAKEFLAGS += -j$(NUMJOBS) endif -%: - dh $@ --with javahelper +#%: +# dh $@ --with javahelper -override_dh_auto_configure: +#override_dh_auto_configure: +configure/libphonenumber6:: mkdir -p $(CPP_BUILD) && cd $(CPP_BUILD) && $(CMAKE) $(CMAKE_FLAGS) .. -override_dh_auto_build: +#override_dh_auto_build: +# ( cd tools/java && $(MVN) package ) +# mkdir java/lib +# ln -s /usr/share/java/junit4.jar java/lib/junit-4.8.1.jar +# $(ANT) -f $(JAVA_BUILD).xml jar +build/libphonenumber6:: $(MAKE) -C $(CPP_BUILD) phonenumber phonenumber-shared - $(ANT) -f $(JAVA_BUILD).xml jar -override_dh_auto_test: -ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) - $(MAKE) -C $(CPP_BUILD) test - $(ANT) -f $(JAVA_BUILD).xml junit -endif +#override_dh_auto_test: +#ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) +# $(MAKE) -C $(CPP_BUILD) test +# $(ANT) -f $(JAVA_BUILD).xml junit +#endif # Hack for multiarch: CMake doesn't really support libdir so we just manually # move /usr/lib/* to a proper multiarch location. -override_dh_auto_install: +#override_dh_auto_install: +common-install-arch:: dh_auto_install --builddirectory=$(CPP_BUILD) mkdir -p debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH) mv debian/tmp/usr/lib/* debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH) mv debian/tmp/usr/lib-$(DEB_HOST_MULTIARCH) \ debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH) -override_dh_auto_clean: +#override_dh_auto_clean: +clean:: -test -d $(CPP_BUILD) && $(MAKE) -C $(CPP_BUILD) clean - -$(ANT) -f $(JAVA_BUILD).xml clean + #-$(ANT) -f $(JAVA_BUILD).xml clean + #-( cd tools/java && $(MVN) clean ) diff --git a/debian/source/format b/debian/source/format index 89ae9db8f..163aaf8d8 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt)