commit
35426a28ad
BIN
0.9.5.tar.gz
Normal file
BIN
0.9.5.tar.gz
Normal file
Binary file not shown.
295
0001-Port-to-latest-version-of-javaparser.patch
Normal file
295
0001-Port-to-latest-version-of-javaparser.patch
Normal file
@ -0,0 +1,295 @@
|
||||
From f386ad4a22d650388b718aca4fea928f8d7ed04a Mon Sep 17 00:00:00 2001
|
||||
From: Mat Booth <mat.booth@redhat.com>
|
||||
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 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
- <groupId>com.google.code.javaparser</groupId>
|
||||
- <artifactId>javaparser</artifactId>
|
||||
+ <groupId>com.github.javaparser</groupId>
|
||||
+ <artifactId>javaparser-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jvnet.jaxb2.maven2</groupId>
|
||||
@@ -97,4 +97,4 @@
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
-</project>
|
||||
\ No newline at end of file
|
||||
+</project>
|
||||
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<TypeDeclaration> 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<ClassOrInterfaceType> _extended = classDeclaration
|
||||
- .getExtends();
|
||||
+ final NodeList<ClassOrInterfaceType> _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<Type> typeArgs = type.getTypeArgs();
|
||||
- if (typeArgs == null || typeArgs.isEmpty()) {
|
||||
+ if (!type.getTypeArguments().isPresent() || type.getTypeArguments().get().isEmpty()) {
|
||||
return jclass;
|
||||
} else {
|
||||
+ final NodeList<Type> typeArgs = type.getTypeArguments().get();
|
||||
final List<JClass> jtypeArgs = new ArrayList<JClass>(
|
||||
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<java.lang.Integer>{}";
|
||||
|
||||
final CompilationUnit compilationUnit = JavaParser.parse(
|
||||
- new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8");
|
||||
- final List<TypeDeclaration> typeDeclarations = compilationUnit
|
||||
+ new ByteArrayInputStream(text.getBytes("UTF-8")));
|
||||
+ final NodeList<TypeDeclaration<?>> 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<ClassOrInterfaceType> implementedInterfaces = classDeclaration
|
||||
- .getImplements();
|
||||
+ assertEquals("Dummy", classDeclaration.getName().asString());
|
||||
+ final NodeList<ClassOrInterfaceType> implementedInterfaces = classDeclaration
|
||||
+ .getImplementedTypes();
|
||||
assertEquals(1, implementedInterfaces.size());
|
||||
final ClassOrInterfaceType implementedInterface = implementedInterfaces
|
||||
.get(0);
|
||||
- assertEquals("Comparator", implementedInterface.getName());
|
||||
- final List<Type> typeArgs = implementedInterface.getTypeArgs();
|
||||
+ assertEquals("Comparator", implementedInterface.getName().asString());
|
||||
+ final NodeList<Type> 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 @@
|
||||
</dependency>
|
||||
<!-- Java Parser -->
|
||||
<dependency>
|
||||
- <groupId>com.google.code.javaparser</groupId>
|
||||
- <artifactId>javaparser</artifactId>
|
||||
- <version>1.0.11</version>
|
||||
+ <groupId>com.github.javaparser</groupId>
|
||||
+ <artifactId>javaparser-core</artifactId>
|
||||
+ <version>3.3.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
--
|
||||
2.20.1
|
||||
|
||||
67
jaxb2-common-basics.spec
Normal file
67
jaxb2-common-basics.spec
Normal file
@ -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 <chengzihan2@huawei.com> - 0.9.5-1
|
||||
- Package init
|
||||
4
jaxb2-common-basics.yaml
Normal file
4
jaxb2-common-basics.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
version_control: github
|
||||
src_repo: highsource/jaxb2-basics
|
||||
tag_prefix: "^"
|
||||
seperator: "."
|
||||
Loading…
x
Reference in New Issue
Block a user