[axmlrpc] 05/08: Adapt rules to fix build
Guillaume Turri
gturri-guest at moszumanska.debian.org
Tue Apr 12 20:08:50 UTC 2016
This is an automated email from the git hooks/post-receive script.
gturri-guest pushed a commit to tag temp
in repository axmlrpc.
commit 0b40aeea14f9586c4efdb543e028027a147a583b
Author: Guillaume Turri <guillaume.turri at gmail.com>
Date: Tue Apr 12 10:48:03 2016 +0200
Adapt rules to fix build
* remove the test which relies on wiremock since this test package
isn't available in debian
* embed the source of jISO8601: since this package only contains
one class, we'd rather bring this source here, then creating an
ad hoc debian package
---
debian/fr/turri/jiso8601/Iso8601Deserializer.java | 144 ++++++++++++++++++++++
debian/maven.ignoreRules | 11 ++
debian/pom.xml | 42 -------
debian/rules | 7 +-
4 files changed, 159 insertions(+), 45 deletions(-)
diff --git a/debian/fr/turri/jiso8601/Iso8601Deserializer.java b/debian/fr/turri/jiso8601/Iso8601Deserializer.java
new file mode 100644
index 0000000..034cec7
--- /dev/null
+++ b/debian/fr/turri/jiso8601/Iso8601Deserializer.java
@@ -0,0 +1,144 @@
+package fr.turri.jiso8601;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+public class Iso8601Deserializer {
+ private Iso8601Deserializer(){}
+
+ public static Date toDate(String toParse){
+ return toCalendar(toParse).getTime();
+ }
+
+ public static Calendar toCalendar(String toParse){
+ if ( toParse.indexOf('T') == -1 ){
+ return buildCalendarWithDateOnly(toParse, toParse);
+ }
+ int indexOfT = toParse.indexOf('T');
+ Calendar result = buildCalendarWithDateOnly(toParse.substring(0, indexOfT), toParse);
+ return parseHour(result, toParse.substring(indexOfT+1));
+ }
+
+ private static Calendar parseHour(Calendar result, String hourStr){
+ String basicFormatHour = hourStr.replace(":", "");
+
+ int indexOfZ = basicFormatHour.indexOf('Z');
+ if ( indexOfZ != -1 ){
+ parseHourWithoutHandlingTimeZone(result, basicFormatHour.substring(0, indexOfZ));
+ } else {
+ int indexOfSign = getIndexOfSign(basicFormatHour);
+ if ( indexOfSign == -1 ){
+ parseHourWithoutHandlingTimeZone(result, basicFormatHour);
+ result.setTimeZone(TimeZone.getDefault());
+ } else {
+ parseHourWithoutHandlingTimeZone(result, basicFormatHour.substring(0, indexOfSign));
+ result.setTimeZone(TimeZone.getTimeZone("GMT" + basicFormatHour.substring(indexOfSign)));
+ }
+ }
+ return result;
+ }
+
+ private static int getIndexOfSign(String str){
+ int index = str.indexOf('+');
+ return index != -1 ? index : str.indexOf('-');
+ }
+
+ private static void parseHourWithoutHandlingTimeZone(Calendar calendar, String basicFormatHour){
+ basicFormatHour = basicFormatHour.replace(',', '.');
+ int indexOfDot = basicFormatHour.indexOf('.');
+ double fractionalPart = 0;
+ if ( indexOfDot != -1 ){
+ fractionalPart = Double.parseDouble("0" + basicFormatHour.substring(indexOfDot));
+ basicFormatHour = basicFormatHour.substring(0, indexOfDot);
+ }
+
+ if ( basicFormatHour.length() >= 2 ){
+ calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(basicFormatHour.substring(0, 2)));
+ }
+
+ if ( basicFormatHour.length() > 2 ){
+ calendar.set(Calendar.MINUTE, Integer.parseInt(basicFormatHour.substring(2, 4)));
+ } else {
+ fractionalPart *= 60;
+ }
+
+ if ( basicFormatHour.length() > 4 ){
+ calendar.set(Calendar.SECOND, Integer.parseInt(basicFormatHour.substring(4, 6)));
+ } else {
+ fractionalPart *= 60;
+ }
+
+ calendar.set(Calendar.MILLISECOND, (int) (fractionalPart * 1000));
+ }
+
+ private static Calendar buildCalendarWithDateOnly(String dateStr, String originalDate){
+ Calendar result = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+ result.setMinimalDaysInFirstWeek(4);
+ result.setFirstDayOfWeek(Calendar.MONDAY);
+ result.set(Calendar.HOUR_OF_DAY, 0);
+ result.set(Calendar.MINUTE, 0);
+ result.set(Calendar.SECOND, 0);
+ result.set(Calendar.MILLISECOND, 0);
+ String basicFormatDate = dateStr.replaceAll("-", "");
+
+ if ( basicFormatDate.indexOf('W') != -1 ){
+ return parseWeekDate(result, basicFormatDate);
+ } else if ( basicFormatDate.length() == 7 ){
+ return parseOrdinalDate(result, basicFormatDate);
+ } else {
+ return parseCalendarDate(result, basicFormatDate, originalDate);
+ }
+ }
+
+ private static Calendar parseCalendarDate(Calendar result, String basicFormatDate, String originalDate){
+ if ( basicFormatDate.length() == 2 ){
+ return parseCalendarDateWithCenturyOnly(result, basicFormatDate);
+ } else if ( basicFormatDate.length() == 4){
+ return parseCalendarDateWithYearOnly(result, basicFormatDate);
+ } else {
+ return parseCalendarDateWithPrecisionGreaterThanYear(result, basicFormatDate, originalDate);
+ }
+ }
+
+ private static Calendar parseCalendarDateWithCenturyOnly(Calendar result, String basicFormatDate){
+ result.set(Integer.parseInt(basicFormatDate) * 100, 0, 1);
+ return result;
+ }
+
+ private static Calendar parseCalendarDateWithYearOnly(Calendar result, String basicFormatDate){
+ result.set(Integer.parseInt(basicFormatDate), 0, 1);
+ return result;
+ }
+
+ private static Calendar parseCalendarDateWithPrecisionGreaterThanYear(Calendar result, String basicFormatDate, String originalDate){
+ int year = Integer.parseInt(basicFormatDate.substring(0, 4));
+ int month = Integer.parseInt(basicFormatDate.substring(4, 6)) - 1;
+ if ( basicFormatDate.length() == 6 ){
+ result.set(year, month, 1);
+ return result;
+ }
+
+ if ( basicFormatDate.length() == 8 ){
+ result.set(year, month, Integer.parseInt(basicFormatDate.substring(6)));
+ return result;
+ }
+ throw new RuntimeException("Can't parse " + originalDate);
+ }
+
+ private static Calendar parseWeekDate(Calendar result, String basicFormatDate) {
+ result.set(Calendar.YEAR, Integer.parseInt(basicFormatDate.substring(0, 4)));
+ result.set(Calendar.WEEK_OF_YEAR, Integer.parseInt(basicFormatDate.substring(5, 7)));
+ result.set(Calendar.DAY_OF_WEEK, basicFormatDate.length() == 7
+ ? Calendar.MONDAY
+ : Calendar.SUNDAY + Integer.parseInt(basicFormatDate.substring(7)));
+ return result;
+ }
+
+ private static Calendar parseOrdinalDate(Calendar calendar, String basicFormatOrdinalDate) {
+ calendar.set(Calendar.YEAR, Integer.parseInt(basicFormatOrdinalDate.substring(0, 4)));
+ calendar.set(Calendar.DAY_OF_YEAR, Integer.parseInt(basicFormatOrdinalDate.substring(4)));
+ return calendar;
+ }
+}
diff --git a/debian/maven.ignoreRules b/debian/maven.ignoreRules
new file mode 100644
index 0000000..2d4381c
--- /dev/null
+++ b/debian/maven.ignoreRules
@@ -0,0 +1,11 @@
+
+com.github.tomakehurst wiremock * * * *
+fr.turri jISO8601 * * * *
+org.apache.maven.plugins maven-assembly-plugin * * * *
+org.apache.maven.plugins maven-dependency-plugin * * * *
+org.apache.maven.plugins maven-surefire-plugin * * * *
+org.codehaus.mojo cobertura-maven-plugin * * * *
+org.codehaus.mojo findbugs-maven-plugin * * * *
+org.mockito mockito-all * * * *
+org.pitest pitest-maven * * * *
+org.sonatype.plugins nexus-staging-maven-plugin * * * *
diff --git a/debian/pom.xml b/debian/pom.xml
deleted file mode 100644
index 81d0c5e..0000000
--- a/debian/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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>
- <groupId>de.timroes</groupId>
- <artifactId>aXMLRPC</artifactId>
- <version>1.8.1</version>
- <packaging>jar</packaging>
- <properties>
- <debian.hasPackageVersion>
- </debian.hasPackageVersion>
- <debian.originalVersion>1.8.0</debian.originalVersion>
- <debian.package>libaxmlrpc-java</debian.package>
- </properties>
- <name>aXMLRPC</name>
- <description>Lightweight Java XML-RPC working also on Android.</description>
- <url>https://github.com/timroes/aXMLRPC</url>
- <licenses>
- <license>
- <name>The MIT License (MIT)</name>
- </license>
- </licenses>
- <developers>
- <developer>
- <id>timroes</id>
- <name>Tim Roes</name>
- <email>mail at timroes.de</email>
- </developer>
- </developers>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <scm>
- <connection>scm:git at github.com:timroes/aXMLRPC.git</connection>
- <developerConnection>scm:git at github.com:timroes/aXMLRPC.git</developerConnection>
- <url>scm:git at github.com:timroes/aXMLRPC.git</url>
- </scm>
-</project>
diff --git a/debian/rules b/debian/rules
index 076313c..7888116 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,11 +6,12 @@ include /usr/share/cdbs/1/class/maven.mk
JAVA_HOME := /usr/lib/jvm/default-java
pre-build::
- cp debian/pom.xml .
- mh_patchpoms -plibaxmlrpc-java --keep-pom-version
+ cp -r debian/fr src/main/java
+ mv src/test/java/de/timeroes/axmlrpc/TestResponseParser.java debian || true
clean::
- rm -f pom.xml
+ rm -rf src/main/java/fr
+ cp debian/TestResponseParser.java src/test/java/de/timeroes/axmlrpc/
get-orig-source:
uscan --download-current-version --force-download --symlink
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/axmlrpc.git
More information about the pkg-java-commits
mailing list