diff --git a/0.9.5.tar.gz b/0.9.5.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..84bf7cc3da616ba34452cd0b7b24dc6bbac4b022 Binary files /dev/null and b/0.9.5.tar.gz differ diff --git a/0001-Port-to-latest-version-of-javaparser.patch b/0001-Port-to-latest-version-of-javaparser.patch new file mode 100644 index 0000000000000000000000000000000000000000..842be5cf4973c0a8ec10804039e4dbe3f9da584a --- /dev/null +++ b/0001-Port-to-latest-version-of-javaparser.patch @@ -0,0 +1,295 @@ +From f386ad4a22d650388b718aca4fea928f8d7ed04a Mon Sep 17 00:00:00 2001 +From: Mat Booth +Date: Thu, 14 Feb 2019 10:40:37 +0000 +Subject: [PATCH] Port to latest version of javaparser + +--- + basic/pom.xml | 6 +- + .../inheritance/util/JavaTypeParser.java | 26 ++++----- + .../util/TypeToJTypeConvertingVisitor.java | 56 ++++++++++--------- + .../inheritance/tests/JavaTypeParserTest.java | 34 +++++------ + pom.xml | 6 +- + 5 files changed, 64 insertions(+), 64 deletions(-) + +diff --git a/basic/pom.xml b/basic/pom.xml +index ab5f477..37f9dda 100644 +--- a/basic/pom.xml ++++ b/basic/pom.xml +@@ -31,8 +31,8 @@ + provided + + +- com.google.code.javaparser +- javaparser ++ com.github.javaparser ++ javaparser-core + + + org.jvnet.jaxb2.maven2 +@@ -97,4 +97,4 @@ + + + +- +\ No newline at end of file ++ +diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java +index 2d5d07a..6e94f62 100644 +--- a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java ++++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/JavaTypeParser.java +@@ -1,16 +1,16 @@ + package org.jvnet.jaxb2_commons.plugin.inheritance.util; + +-import japa.parser.JavaParser; +-import japa.parser.ParseException; +-import japa.parser.ast.CompilationUnit; +-import japa.parser.ast.body.ClassOrInterfaceDeclaration; +-import japa.parser.ast.body.TypeDeclaration; +-import japa.parser.ast.type.ClassOrInterfaceType; ++import com.github.javaparser.JavaParser; ++import com.github.javaparser.ParseProblemException; ++import com.github.javaparser.ast.CompilationUnit; ++import com.github.javaparser.ast.NodeList; ++import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; ++import com.github.javaparser.ast.body.TypeDeclaration; ++import com.github.javaparser.ast.type.ClassOrInterfaceType; + + import java.io.ByteArrayInputStream; + import java.io.UnsupportedEncodingException; + import java.util.Collections; +-import java.util.List; + import java.util.Map; + + import org.apache.commons.lang3.Validate; +@@ -52,18 +52,16 @@ public class JavaTypeParser { + final String text = "public class Ignored extends " + type + " {}"; + try { + CompilationUnit compilationUnit = JavaParser.parse( +- new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8"); +- final List typeDeclarations = compilationUnit +- .getTypes(); +- final TypeDeclaration typeDeclaration = typeDeclarations.get(0); ++ new ByteArrayInputStream(text.getBytes("UTF-8"))); ++ final TypeDeclaration typeDeclaration = compilationUnit.getType(0); + final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration; +- final List _extended = classDeclaration +- .getExtends(); ++ final NodeList _extended = classDeclaration ++ .getExtendedTypes(); + final ClassOrInterfaceType classOrInterfaceType = _extended.get(0); + + return classOrInterfaceType.accept( + this.typeToJTypeConvertingVisitor, codeModel); +- } catch (ParseException pex) { ++ } catch (ParseProblemException pex) { + throw new IllegalArgumentException( + "Could not parse the type definition [" + type + "].", pex); + } catch (UnsupportedEncodingException uex) { +diff --git a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java +index 5b8a4b7..9f7ae21 100644 +--- a/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java ++++ b/basic/src/main/java/org/jvnet/jaxb2_commons/plugin/inheritance/util/TypeToJTypeConvertingVisitor.java +@@ -1,12 +1,15 @@ + package org.jvnet.jaxb2_commons.plugin.inheritance.util; + +-import japa.parser.ast.type.ClassOrInterfaceType; +-import japa.parser.ast.type.PrimitiveType; +-import japa.parser.ast.type.ReferenceType; +-import japa.parser.ast.type.Type; +-import japa.parser.ast.type.VoidType; +-import japa.parser.ast.type.WildcardType; +-import japa.parser.ast.visitor.GenericVisitorAdapter; ++import com.github.javaparser.ast.NodeList; ++import com.github.javaparser.ast.type.ArrayType; ++import com.github.javaparser.ast.type.ClassOrInterfaceType; ++import com.github.javaparser.ast.type.PrimitiveType; ++import com.github.javaparser.ast.type.PrimitiveType.Primitive; ++import com.github.javaparser.ast.type.ReferenceType; ++import com.github.javaparser.ast.type.Type; ++import com.github.javaparser.ast.type.VoidType; ++import com.github.javaparser.ast.type.WildcardType; ++import com.github.javaparser.ast.visitor.GenericVisitorAdapter; + + import java.util.ArrayList; + import java.util.List; +@@ -36,21 +39,21 @@ public class TypeToJTypeConvertingVisitor extends + @Override + public JType visit(PrimitiveType type, JCodeModel codeModel) { + switch (type.getType()) { +- case Boolean: ++ case BOOLEAN: + return codeModel.BOOLEAN; +- case Char: ++ case CHAR: + return codeModel.CHAR; +- case Byte: ++ case BYTE: + return codeModel.BYTE; +- case Short: ++ case SHORT: + return codeModel.SHORT; +- case Int: ++ case INT: + return codeModel.INT; +- case Long: ++ case LONG: + return codeModel.LONG; +- case Float: ++ case FLOAT: + return codeModel.FLOAT; +- case Double: ++ case DOUBLE: + return codeModel.DOUBLE; + default: + throw new AssertionError("Unknown primitive type [" +@@ -59,11 +62,11 @@ public class TypeToJTypeConvertingVisitor extends + } + + @Override +- public JType visit(ReferenceType type, JCodeModel codeModel) { +- final JType referencedType = type.getType().accept(this, codeModel); ++ public JType visit(ArrayType type, JCodeModel codeModel) { ++ final JType referencedType = type.getComponentType().accept(this, codeModel); + + JType referencedTypeArray = referencedType; +- for (int index = 0; index < type.getArrayCount(); index++) { ++ for (int index = 0; index < type.getArrayLevel(); index++) { + referencedTypeArray = referencedTypeArray.array(); + } + return referencedTypeArray; +@@ -72,8 +75,8 @@ public class TypeToJTypeConvertingVisitor extends + @Override + public JType visit(WildcardType type, JCodeModel codeModel) { + +- if (type.getExtends() != null) { +- final ReferenceType _extends = type.getExtends(); ++ if (type.getExtendedType().isPresent()) { ++ final ReferenceType _extends = type.getExtendedType().get(); + final JType boundType = _extends.accept(this, codeModel); + + if (!(boundType instanceof JClass)) { +@@ -83,7 +86,7 @@ public class TypeToJTypeConvertingVisitor extends + + final JClass boundClass = (JClass) boundType; + return boundClass.wildcard(); +- } else if (type.getSuper() != null) { ++ } else if (type.getSuperType().isPresent()) { + // TODO + throw new IllegalArgumentException( + "Wildcard types with super clause are not supported at the moment."); +@@ -99,10 +102,10 @@ public class TypeToJTypeConvertingVisitor extends + final JClass knownClass = this.knownClasses.get(name); + final JClass jclass = knownClass != null ? knownClass : codeModel + .ref(name); +- final List typeArgs = type.getTypeArgs(); +- if (typeArgs == null || typeArgs.isEmpty()) { ++ if (!type.getTypeArguments().isPresent() || type.getTypeArguments().get().isEmpty()) { + return jclass; + } else { ++ final NodeList typeArgs = type.getTypeArguments().get(); + final List jtypeArgs = new ArrayList( + typeArgs.size()); + for (Type typeArg : typeArgs) { +@@ -119,12 +122,11 @@ public class TypeToJTypeConvertingVisitor extends + } + + private String getName(ClassOrInterfaceType type) { +- final String name = type.getName(); +- final ClassOrInterfaceType scope = type.getScope(); +- if (scope == null) { ++ final String name = type.getName().asString(); ++ if (!type.getScope().isPresent()) { + return name; + } else { +- return getName(scope) + "." + name; ++ return getName(type.getScope().get()) + "." + name; + } + } + } +diff --git a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java +index 8566557..8903526 100644 +--- a/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java ++++ b/basic/src/test/java/org/jvnet/jaxb2_commons/plugin/inheritance/tests/JavaTypeParserTest.java +@@ -1,15 +1,15 @@ + package org.jvnet.jaxb2_commons.plugin.inheritance.tests; + +-import japa.parser.JavaParser; +-import japa.parser.ast.CompilationUnit; +-import japa.parser.ast.body.ClassOrInterfaceDeclaration; +-import japa.parser.ast.body.TypeDeclaration; +-import japa.parser.ast.type.ClassOrInterfaceType; +-import japa.parser.ast.type.ReferenceType; +-import japa.parser.ast.type.Type; ++import com.github.javaparser.JavaParser; ++import com.github.javaparser.ast.CompilationUnit; ++import com.github.javaparser.ast.NodeList; ++import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; ++import com.github.javaparser.ast.body.TypeDeclaration; ++import com.github.javaparser.ast.type.ClassOrInterfaceType; ++import com.github.javaparser.ast.type.ReferenceType; ++import com.github.javaparser.ast.type.Type; + + import java.io.ByteArrayInputStream; +-import java.util.List; + + import junit.framework.TestCase; + +@@ -20,29 +20,29 @@ public class JavaTypeParserTest extends TestCase { + final String text = "public class Dummy implements java.util.Comparator{}"; + + final CompilationUnit compilationUnit = JavaParser.parse( +- new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8"); +- final List typeDeclarations = compilationUnit ++ new ByteArrayInputStream(text.getBytes("UTF-8"))); ++ final NodeList> typeDeclarations = compilationUnit + .getTypes(); + assertEquals(1, typeDeclarations.size()); + final TypeDeclaration typeDeclaration = typeDeclarations.get(0); + assertTrue(typeDeclaration instanceof ClassOrInterfaceDeclaration); + final ClassOrInterfaceDeclaration classDeclaration = (ClassOrInterfaceDeclaration) typeDeclaration; +- assertEquals("Dummy", classDeclaration.getName()); +- final List implementedInterfaces = classDeclaration +- .getImplements(); ++ assertEquals("Dummy", classDeclaration.getName().asString()); ++ final NodeList implementedInterfaces = classDeclaration ++ .getImplementedTypes(); + assertEquals(1, implementedInterfaces.size()); + final ClassOrInterfaceType implementedInterface = implementedInterfaces + .get(0); +- assertEquals("Comparator", implementedInterface.getName()); +- final List typeArgs = implementedInterface.getTypeArgs(); ++ assertEquals("Comparator", implementedInterface.getName().asString()); ++ final NodeList typeArgs = implementedInterface.getTypeArguments().get(); + assertEquals(1, typeArgs.size()); + final Type typeArg = typeArgs.get(0); + assertTrue(typeArg instanceof ReferenceType); + final ReferenceType referenceTypeArg = (ReferenceType) typeArg; +- final Type referencedType = referenceTypeArg.getType(); ++ final Type referencedType = referenceTypeArg.getElementType(); + assertTrue(referencedType instanceof ClassOrInterfaceType); + final ClassOrInterfaceType typeArgType = (ClassOrInterfaceType) referencedType; +- assertEquals("Integer", typeArgType.getName()); ++ assertEquals("Integer", typeArgType.getName().asString()); + + } + } +diff --git a/pom.xml b/pom.xml +index a6c566e..4da4247 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -250,9 +250,9 @@ + + + +- com.google.code.javaparser +- javaparser +- 1.0.11 ++ com.github.javaparser ++ javaparser-core ++ 3.3.5 + + + +-- +2.20.1 + diff --git a/jaxb2-common-basics.spec b/jaxb2-common-basics.spec new file mode 100644 index 0000000000000000000000000000000000000000..ae400b50302389a74001adc56274be477280627b --- /dev/null +++ b/jaxb2-common-basics.spec @@ -0,0 +1,67 @@ +Name: jaxb2-common-basics +Version: 0.9.5 +Release: 1 +Summary: JAXB2 Basics +License: BSD +Url: https://github.com/highsource/jaxb2-basics +Source0: https://github.com/highsource/jaxb2-basics/archive/0.9.5.tar.gz +Patch0: 0001-Port-to-latest-version-of-javaparser.patch +BuildRequires: maven-local mvn(com.google.code.javaparser:javaparser) +BuildRequires: mvn(com.vividsolutions:jts) mvn(commons-beanutils:commons-beanutils) +BuildRequires: mvn(commons-io:commons-io) mvn(javax.xml.bind:jaxb-api) mvn(junit:junit) +BuildRequires: mvn(org.apache.ant:ant) mvn(org.apache.ant:ant-launcher) +BuildRequires: mvn(org.apache.commons:commons-lang3) mvn(org.apache.felix:maven-bundle-plugin) +BuildRequires: mvn(org.glassfish.jaxb:jaxb-runtime) mvn(org.glassfish.jaxb:jaxb-xjc) +BuildRequires: mvn(org.jvnet.jaxb2.maven2:maven-jaxb22-plugin) +BuildRequires: mvn(org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-testing) +BuildRequires: mvn(org.slf4j:jcl-over-slf4j) mvn(org.slf4j:slf4j-api) +BuildRequires: mvn(org.sonatype.oss:oss-parent:pom:) +BuildRequires: mvn(org.springframework:spring-context-support) mvn(xmlunit:xmlunit) +BuildArch: noarch +%description +JAXB2 Basics is a part of JAXB2 Commons project which +implements plugins and tools for JAXB 2.x reference +implementation. + +%package javadoc +Summary: Javadoc for %{name} +%description javadoc +This package contains javadoc for %{name}. + +%prep +%setup -q -n jaxb2-basics-%{version} +%patch0 -p1 +find -name "*.bat" -print -delete +find -name "*.class" -print -delete +find -name "*.jar" -print -delete +%pom_remove_plugin :maven-source-plugin +%pom_remove_plugin :maven-deploy-plugin plugins +%pom_remove_plugin :maven-shade-plugin plugins +%pom_disable_module dist +%pom_disable_module samples +%pom_disable_module tests +%pom_change_dep :ant-optional org.apache.ant:ant +%pom_change_dep -r org.springframework:spring org.springframework:spring-context-support +%pom_change_dep :maven-jaxb2-plugin :maven-jaxb22-plugin +%pom_xpath_set "pom:dependency[pom:artifactId = 'tools' ]/pom:groupId" com.sun +%pom_xpath_remove "pom:dependency[pom:artifactId = 'tools' ]/pom:scope" +%pom_xpath_remove "pom:dependency[pom:artifactId = 'tools' ]/pom:systemPath" +%pom_xpath_set "pom:plugin[pom:groupId = 'org.jvnet.jaxb2.maven2' ]/pom:artifactId" maven-jaxb22-plugin +sed -i -e 's/com\.vividsolutions\.jts/org.locationtech.jts/' $(find -name *.java) + +%build +%mvn_build + +%install +%mvn_install + +%files -f .mfiles +%doc README.md TODO.md +%license LICENSE + +%files javadoc -f .mfiles-javadoc +%license LICENSE + +%changelog +* Wed Aug 5 2020 chengzihan - 0.9.5-1 +- Package init diff --git a/jaxb2-common-basics.yaml b/jaxb2-common-basics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..585f473c01fa4777cc872835dc38e758fb10dc07 --- /dev/null +++ b/jaxb2-common-basics.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: highsource/jaxb2-basics +tag_prefix: "^" +seperator: "."