From 1bafc78fcc3ae34bf8d77b808947a3139d109ee71b563c371dd934945c09816c Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 1 Jan 2019 13:10:14 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/Java:packages/hamcrest?expand=0&rev=32 --- hamcrest-1.3-qdox-2.0.patch | 105 ++++++++++++++++++++++++++++++++++++ hamcrest.spec | 4 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 hamcrest-1.3-qdox-2.0.patch diff --git a/hamcrest-1.3-qdox-2.0.patch b/hamcrest-1.3-qdox-2.0.patch new file mode 100644 index 0000000..c28c762 --- /dev/null +++ b/hamcrest-1.3-qdox-2.0.patch @@ -0,0 +1,105 @@ +From 6d7da5456a7458a249bed9c4c1e768cc7cc2fe40 Mon Sep 17 00:00:00 2001 +From: Michael Simacek +Date: Wed, 1 Feb 2017 12:57:14 +0100 +Subject: [PATCH] Port to qdox 2.0 + +--- + .../src/main/java/org/hamcrest/generator/QDox.java | 4 ++-- + .../org/hamcrest/generator/QDoxFactoryReader.java | 26 ++++++++++++---------- + 2 files changed, 16 insertions(+), 14 deletions(-) + +diff --git a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java +index efaf615..338178d 100644 +--- a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java ++++ b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java +@@ -1,6 +1,6 @@ + package org.hamcrest.generator; + +-import com.thoughtworks.qdox.JavaDocBuilder; ++import com.thoughtworks.qdox.JavaProjectBuilder; + import com.thoughtworks.qdox.model.JavaClass; + + import java.io.File; +@@ -16,7 +16,7 @@ import java.io.Reader; + */ + public class QDox { + +- private final JavaDocBuilder javaDocBuilder = new JavaDocBuilder(); ++ private final JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder(); + + public void addSourceTree(File sourceDir) { + javaDocBuilder.addSourceTree(sourceDir); +diff --git a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java +index 5108140..97fce01 100644 +--- a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java ++++ b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java +@@ -4,8 +4,10 @@ import com.thoughtworks.qdox.model.DocletTag; + import com.thoughtworks.qdox.model.JavaClass; + import com.thoughtworks.qdox.model.JavaMethod; + import com.thoughtworks.qdox.model.JavaParameter; +-import com.thoughtworks.qdox.model.Type; ++import com.thoughtworks.qdox.model.JavaType; ++import com.thoughtworks.qdox.model.impl.DefaultJavaClass; + ++import java.util.ArrayList; + import java.util.Iterator; + import java.util.List; + import java.util.regex.Pattern; +@@ -56,15 +58,15 @@ public class QDoxFactoryReader implements Iterable { + JavaMethod methodSource = findMethodInSource(factoryMethod); + if (methodSource != null) { + factoryMethod.setJavaDoc(createJavaDocComment(methodSource)); +- JavaParameter[] parametersFromSource ++ List parametersFromSource + = methodSource.getParameters(); + List parametersFromReflection + = factoryMethod.getParameters(); + +- if (parametersFromReflection.size() == parametersFromSource.length) { +- for (int i = 0; i < parametersFromSource.length; i++) { ++ if (parametersFromReflection.size() == parametersFromSource.size()) { ++ for (int i = 0; i < parametersFromSource.size(); i++) { + parametersFromReflection.get(i).setName( +- parametersFromSource[i].getName()); ++ parametersFromSource.get(i).getName()); + } + } + } +@@ -79,18 +81,18 @@ public class QDoxFactoryReader implements Iterable { + // Note, this doesn't always work - it struggles with some kinds of generics. + // This seems to cover most cases though. + List params = factoryMethod.getParameters(); +- Type[] types = new Type[params.size()]; ++ List types = new ArrayList(params.size()); + boolean varArgs = false; +- for (int i = 0; i < types.length; i++) { ++ for (int i = 0; i < params.size(); i++) { + String type = params.get(i).getType(); + varArgs = VARARGS_REGEX.matcher(type).find(); + // QDox ignores varargs and generics, so we strip them out to help QDox. + type = GENERIC_REGEX.matcher(type).replaceAll(""); + type = VARARGS_REGEX.matcher(type).replaceAll(""); +- types[i] = new Type(type); ++ types.add(new DefaultJavaClass(type)); + } +- JavaMethod[] methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs); +- return methods.length == 1 ? methods[0] : null; ++ List methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs); ++ return methods.size() == 1 ? methods.get(0) : null; + } + + /** +@@ -98,8 +100,8 @@ public class QDoxFactoryReader implements Iterable { + */ + private static String createJavaDocComment(JavaMethod methodSource) { + String comment = methodSource.getComment(); +- DocletTag[] tags = methodSource.getTags(); +- if ((comment == null || comment.trim().length() == 0) && tags.length == 0) { ++ List tags = methodSource.getTags(); ++ if ((comment == null || comment.trim().length() == 0) && tags.size() == 0) { + return null; + } + StringBuilder result = new StringBuilder(); +-- +2.9.3 + diff --git a/hamcrest.spec b/hamcrest.spec index e067431..d8bf596 100644 --- a/hamcrest.spec +++ b/hamcrest.spec @@ -1,7 +1,7 @@ # # spec file for package hamcrest # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -51,6 +51,7 @@ Patch4: hamcrest-1.3-random-build-crash.patch Patch5: hamcrest-1.3-fork-javac.patch Patch6: hamcrest-1.3-javadoc9.patch Patch7: hamcrest-1.3-javadoc10.patch +Patch8: hamcrest-1.3-qdox-2.0.patch BuildRequires: ant >= 1.6.5 BuildRequires: java-devel >= 1.6.0 BuildRequires: javapackages-local @@ -100,6 +101,7 @@ ln -sf $(build-classpath qdox) lib/generator/ %patch5 -p1 %patch6 -p1 %patch7 -p1 +%patch8 -p1 perl -pi -e 's/\r$//g' LICENSE.txt