Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix maven plugin dependency version #39

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/http_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ xml_parse()
[ "$(http_code "/missing")" = "404" ] || die 'get /missing'

## validate webservice
[ "$(post broken)" = '500' ] || die 'Webservice broken'
[ "$(post xml/broken_req.xml)" = '500' ] || die 'Webservice broken'
xmllint --format out.xml | grep -q '<faultstring>' || die 'Webservice broken content'

[ "$(post xml/bare_req.xml)" = '200' ] || die 'webservice bare'
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${maven.version}</version>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
5 changes: 0 additions & 5 deletions unknow-server-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
<artifactId>unknow-server</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>unknow-server-test-tomcat</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>unknow-server-bench</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions unknow-server-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<artifactId>unknow-server-maven</artifactId>
<packaging>maven-plugin</packaging>

<properties>
<maven.version>[3.4,)</maven.version>
</properties>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ private ClassLoader getClassLoader() {
}

protected void process(TypeConsumer c) throws MojoExecutionException, MojoFailureException {

SrcWalker w = new SrcWalker();
for (String s : project.getCompileSourceRoots())
w.walk(s);
Expand All @@ -178,8 +179,8 @@ protected void process(TypeConsumer c) throws MojoExecutionException, MojoFailur
try {
for (String id : artifacts)
parseArtifact(id, c);
} catch (ArtifactResolutionException e) {
throw new MojoFailureException(e);
} catch (Exception e) {
throw new MojoExecutionException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.apache.maven.api.plugin.MojoException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -296,12 +295,12 @@ private void process(String defaultMethod, String basePath, String[] consume, St
if (method == null)
method = defaultMethod;
if (method == null)
throw new MojoException("no method mapped on " + errorName);
throw new RuntimeException("no method mapped on " + errorName);
List<JaxrsParam<?>> params = new ArrayList<>();
for (ParamModel<MethodModel> param : m.parameters()) {
List<AnnotationModel> l = param.annotations().stream().filter(v -> JARXS_PARAM.contains(v.name())).collect(Collectors.toList());
if (l.size() > 1)
throw new MojoException("Duplicate parameter annotation on " + errorName + " " + param.name());
throw new RuntimeException("Duplicate parameter annotation on " + errorName + " " + param.name());
params.add(l.isEmpty() ? new JaxrsBodyParam<>(param) : buildParam(param, l.get(0)));
}

Expand Down Expand Up @@ -364,11 +363,11 @@ private <T extends WithName & WithAnnotation & WithType> JaxrsParam<?> buildPara
if (l.isEmpty())
continue;
if (l.size() > 1)
throw new MojoException("Duplicate parameter annotation on " + f.parent() + "." + f.name());
throw new RuntimeException("Duplicate parameter annotation on " + f.parent() + "." + f.name());

Optional<MethodModel> s = getSetter(cl, f.name(), f.type());
if (!f.isPublic() && s.isEmpty())
throw new MojoException("Can't find setter for " + f + " in " + cl);
throw new RuntimeException("Can't find setter for " + f + " in " + cl);
params.add(new JaxrsBeanFieldParam(buildParam(f, l.get(0)), f, s.orElse(null)));
s.ifPresent(setters::add);
}
Expand All @@ -379,12 +378,12 @@ private <T extends WithName & WithAnnotation & WithType> JaxrsParam<?> buildPara
if (l.isEmpty())
continue;
if (l.size() > 1)
throw new MojoException("Duplicate parameter annotation on " + m.parent() + "." + m.name());
throw new RuntimeException("Duplicate parameter annotation on " + m.parent() + "." + m.name());
String n = m.name();
if (n.startsWith("get")) {
m = getSetter(cl, n.substring(3), m.type()).orElseThrow(() -> new MojoException("Can't find setter for " + n + " in " + cl));
m = getSetter(cl, n.substring(3), m.type()).orElseThrow(() -> new RuntimeException("Can't find setter for " + n + " in " + cl));
} else if (!n.startsWith("set")) {
m = getSetter(cl, n, m.type()).orElseThrow(() -> new MojoException("Can't find setter for " + n + " in " + cl));
m = getSetter(cl, n, m.type()).orElseThrow(() -> new RuntimeException("Can't find setter for " + n + " in " + cl));
}

setters.add(m);
Expand All @@ -409,7 +408,7 @@ private <T extends WithName & WithAnnotation & WithType> JaxrsParam<?> buildPara
if (MatrixParam.class.getName().equals(a.name()))
return new JaxrsMatrixParam<>(p, a.value().filter(v -> v.isSet()).map(v -> v.asLiteral()).orElse(""));

throw new MojoException("Unknow annotation " + a);
throw new RuntimeException("Unknow annotation " + a);
}

private void processParamConvert(TypeModel t) {
Expand Down Expand Up @@ -440,14 +439,14 @@ private String getMethod(WithAnnotation v, String name) {
for (AnnotationModel a : v.annotations()) {
if (HttpMethod.class.getName().equals(a.name())) {
if (m != null)
throw new MojoException("Duplicate mapping on " + name);
throw new RuntimeException("Duplicate mapping on " + name);
m = a.value().filter(n -> n.isSet()).map(n -> n.asLiteral()).orElse(null);
continue;
}
Optional<AnnotationModel> o = loader.get(a.name()).asClass().annotation(HttpMethod.class);
if (o.isPresent()) {
if (m != null)
throw new MojoException("Duplicate mapping on " + name);
throw new RuntimeException("Duplicate mapping on " + name);
m = o.flatMap(n -> n.value()).filter(n -> n.isSet()).map(n -> n.asLiteral()).orElse(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void appendType(XMLStreamWriter out, XmlType t) throws XMLStreamExceptio
out.writeAttribute("type", name(e.xmlType().name()));
out.writeEndElement();
}
if (o.getElements() == null && o.getValue() != null) {
if (!o.hasElements() && o.getValue() != null) {
out.writeEndElement();
out.writeEndElement();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

import javax.xml.namespace.QName;

import org.apache.maven.api.plugin.MojoException;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.jws.WebMethod;
Expand Down Expand Up @@ -78,10 +76,10 @@ public static Service build(ClassModel clazz, String basePath, ModelLoader loade
Optional<AnnotationModel> a = clazz.annotation(SOAPBinding.class);
Style style = a.flatMap(v -> v.member("style")).filter(v -> v.isSet()).map(v -> v.asEnum(Style.class)).orElse(Style.DOCUMENT);
if (style != Style.DOCUMENT)
throw new MojoException("Only Document style is managed " + clazz);
throw new RuntimeException("Only Document style is managed " + clazz);
Use use = a.flatMap(v -> v.member("use")).filter(v -> v.isSet()).map(v -> v.asEnum(Use.class)).orElse(Use.LITERAL);
if (use != Use.LITERAL)
throw new MojoException("Only literal use is managed " + clazz);
throw new RuntimeException("Only literal use is managed " + clazz);

ParameterStyle paramStyle = a.flatMap(v -> v.member("parameterStyle")).filter(v -> v.isSet()).map(s -> s.asEnum(ParameterStyle.class)).orElse(ParameterStyle.WRAPPED);

Expand All @@ -91,26 +89,26 @@ public static Service build(ClassModel clazz, String basePath, ModelLoader loade
if (!inter.isEmpty()) {
TypeModel typeModel = loader.get(inter);
if (typeModel == null)
throw new MojoException("can't find endpointInterface '" + inter + "'");
throw new RuntimeException("can't find endpointInterface '" + inter + "'");
if (!typeModel.isClass())
throw new MojoException("endpointInterface isn't an class or interface'" + inter + "'");
throw new RuntimeException("endpointInterface isn't an class or interface'" + inter + "'");
clazz = typeModel.asClass();
}
service.collectOp(clazz.asClass(), xmlLoader);

for (MethodModel m : clazz.methods()) {
if (m.annotation(PostConstruct.class).isPresent()) {
if (!m.parameters().isEmpty())
throw new MojoException("PostConstruct method can't have parameters on " + clazz.name());
throw new RuntimeException("PostConstruct method can't have parameters on " + clazz.name());
if (service.postConstruct != null)
throw new MojoException("only one method can be annoted with @PostConstruct on " + clazz.name());
throw new RuntimeException("only one method can be annoted with @PostConstruct on " + clazz.name());
service.postConstruct = m.name();
}
if (m.annotation(PreDestroy.class).isPresent()) {
if (!m.parameters().isEmpty())
throw new MojoException("@PreDestroy method can't have parameters on " + clazz.name());
throw new RuntimeException("@PreDestroy method can't have parameters on " + clazz.name());
if (service.postConstruct != null)
throw new MojoException("only one method can be annoted with @PreDestroy on " + clazz.name());
throw new RuntimeException("only one method can be annoted with @PreDestroy on " + clazz.name());
service.preDestroy = m.name();
}
}
Expand All @@ -132,10 +130,10 @@ private void collectOp(ClassModel cl, XmlLoader xmlLoader) {
a = m.annotation(SOAPBinding.class);
Style style = a.flatMap(v -> v.member("style")).filter(v -> v.isSet()).map(v -> v.asEnum(Style.class)).orElse(Style.DOCUMENT);
if (style != Style.DOCUMENT)
throw new MojoException("Only Document style is managed " + m);
throw new RuntimeException("Only Document style is managed " + m);
Use use = a.flatMap(v -> v.member("use")).filter(v -> v.isSet()).map(v -> v.asEnum(Use.class)).orElse(Use.LITERAL);
if (use != Use.LITERAL)
throw new MojoException("Only literal use is managed " + m);
throw new RuntimeException("Only literal use is managed " + m);
ParameterStyle paramStyle = a.flatMap(v -> v.member("parameterStyle")).filter(v -> v.isSet()).map(v -> v.asEnum(ParameterStyle.class)).orElse(defaultParamStyle);

Parameter r = null;
Expand Down