Skip to content

Commit 41fe0b3

Browse files
authored
Merge pull request #699 from lciolecki/issue-698
[ISSUE-698] Ability to specify the JAXB package at the Maven plugin level
2 parents ad393a4 + 7141814 commit 41fe0b3

File tree

7 files changed

+260
-0
lines changed

7 files changed

+260
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.goals = clean compile
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.scalaxb</groupId>
6+
<artifactId>itp07-jakarta-package</artifactId>
7+
<version>0.1-SNAPSHOT</version>
8+
9+
<properties>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
<scala.version>@scala.version@</scala.version>
12+
<binary.version>@binary.version@</binary.version>
13+
</properties>
14+
15+
<dependencies>
16+
17+
<dependency>
18+
<groupId>org.scala-lang</groupId>
19+
<artifactId>scala-library</artifactId>
20+
<version>${scala.version}</version>
21+
</dependency>
22+
23+
<dependency>
24+
<groupId>org.scala-lang.modules</groupId>
25+
<artifactId>scala-xml_${binary.version}</artifactId>
26+
<version>@scala.xml.version@</version>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>org.scala-lang.modules</groupId>
31+
<artifactId>scala-parser-combinators_${binary.version}</artifactId>
32+
<version>@scala.parser.version@</version>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>org.dispatchhttp</groupId>
37+
<artifactId>dispatch-core_${binary.version}</artifactId>
38+
<version>1.0.1</version>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>jakarta.xml.bind</groupId>
43+
<artifactId>jakarta.xml.bind-api</artifactId>
44+
<version>4.0.4</version>
45+
</dependency>
46+
47+
</dependencies>
48+
49+
<build>
50+
<plugins>
51+
52+
<plugin>
53+
<groupId>@project.groupId@</groupId>
54+
<artifactId>@project.artifactId@</artifactId>
55+
<version>@project.version@</version>
56+
<executions>
57+
<execution>
58+
<id>scalaxb</id>
59+
<goals>
60+
<goal>generate</goal>
61+
</goals>
62+
<configuration>
63+
<async>false</async>
64+
<jaxbPackage>jakarta</jaxbPackage>
65+
</configuration>
66+
</execution>
67+
</executions>
68+
<configuration>
69+
<dispatchVersion>1.0.1</dispatchVersion>
70+
</configuration>
71+
</plugin>
72+
73+
<plugin>
74+
<groupId>org.scala-tools</groupId>
75+
<artifactId>maven-scala-plugin</artifactId>
76+
<executions>
77+
<execution>
78+
<goals>
79+
<goal>compile</goal>
80+
<goal>testCompile</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
86+
</plugins>
87+
</build>
88+
89+
</project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import org.scalaxb.maven.it.*;
2+
IntegrationTests.run(ITP07JakartaPackage.class, basedir);
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3+
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
4+
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
5+
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
6+
xmlns:tns="http://www.webserviceX.NET/"
7+
xmlns:s="http://www.w3.org/2001/XMLSchema"
8+
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
9+
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
10+
targetNamespace="http://www.webserviceX.NET/"
11+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
12+
<wsdl:import namespace="http://www.example.com/Report" location="report.xsd" />
13+
<wsdl:types>
14+
<s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">
15+
<s:element name="GetQuote">
16+
<s:complexType>
17+
<s:sequence>
18+
<s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string" />
19+
</s:sequence>
20+
</s:complexType>
21+
</s:element>
22+
<s:element name="GetQuoteResponse">
23+
<s:complexType>
24+
<s:sequence>
25+
<s:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type="s:string" />
26+
</s:sequence>
27+
</s:complexType>
28+
</s:element>
29+
<s:element name="string" nillable="true" type="s:string" />
30+
</s:schema>
31+
</wsdl:types>
32+
<wsdl:message name="GetQuoteSoapIn">
33+
<wsdl:part name="parameters" element="tns:GetQuote" />
34+
</wsdl:message>
35+
<wsdl:message name="GetQuoteSoapOut">
36+
<wsdl:part name="parameters" element="tns:GetQuoteResponse" />
37+
</wsdl:message>
38+
<wsdl:message name="GetQuoteHttpGetIn">
39+
<wsdl:part name="symbol" type="s:string" />
40+
</wsdl:message>
41+
<wsdl:message name="GetQuoteHttpGetOut">
42+
<wsdl:part name="Body" element="tns:string" />
43+
</wsdl:message>
44+
<wsdl:message name="GetQuoteHttpPostIn">
45+
<wsdl:part name="symbol" type="s:string" />
46+
</wsdl:message>
47+
<wsdl:message name="GetQuoteHttpPostOut">
48+
<wsdl:part name="Body" element="tns:string" />
49+
</wsdl:message>
50+
<wsdl:portType name="StockQuoteSoap">
51+
<wsdl:operation name="GetQuote">
52+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation>
53+
<wsdl:input message="tns:GetQuoteSoapIn" />
54+
<wsdl:output message="tns:GetQuoteSoapOut" />
55+
</wsdl:operation>
56+
</wsdl:portType>
57+
<wsdl:portType name="StockQuoteHttpGet">
58+
<wsdl:operation name="GetQuote">
59+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation>
60+
<wsdl:input message="tns:GetQuoteHttpGetIn" />
61+
<wsdl:output message="tns:GetQuoteHttpGetOut" />
62+
</wsdl:operation>
63+
</wsdl:portType>
64+
<wsdl:portType name="StockQuoteHttpPost">
65+
<wsdl:operation name="GetQuote">
66+
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</wsdl:documentation>
67+
<wsdl:input message="tns:GetQuoteHttpPostIn" />
68+
<wsdl:output message="tns:GetQuoteHttpPostOut" />
69+
</wsdl:operation>
70+
</wsdl:portType>
71+
<wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">
72+
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
73+
<wsdl:operation name="GetQuote">
74+
<soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
75+
<wsdl:input>
76+
<soap:body use="literal" />
77+
</wsdl:input>
78+
<wsdl:output>
79+
<soap:body use="literal" />
80+
</wsdl:output>
81+
</wsdl:operation>
82+
</wsdl:binding>
83+
<wsdl:binding name="StockQuoteSoap12" type="tns:StockQuoteSoap">
84+
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
85+
<wsdl:operation name="GetQuote">
86+
<soap12:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
87+
<wsdl:input>
88+
<soap12:body use="literal" />
89+
</wsdl:input>
90+
<wsdl:output>
91+
<soap12:body use="literal" />
92+
</wsdl:output>
93+
</wsdl:operation>
94+
</wsdl:binding>
95+
<wsdl:binding name="StockQuoteHttpGet" type="tns:StockQuoteHttpGet">
96+
<http:binding verb="GET" />
97+
<wsdl:operation name="GetQuote">
98+
<http:operation location="/GetQuote" />
99+
<wsdl:input>
100+
<http:urlEncoded />
101+
</wsdl:input>
102+
<wsdl:output>
103+
<mime:mimeXml part="Body" />
104+
</wsdl:output>
105+
</wsdl:operation>
106+
</wsdl:binding>
107+
<wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost">
108+
<http:binding verb="POST" />
109+
<wsdl:operation name="GetQuote">
110+
<http:operation location="/GetQuote" />
111+
<wsdl:input>
112+
<mime:content type="application/x-www-form-urlencoded" />
113+
</wsdl:input>
114+
<wsdl:output>
115+
<mime:mimeXml part="Body" />
116+
</wsdl:output>
117+
</wsdl:operation>
118+
</wsdl:binding>
119+
<wsdl:service name="StockQuote">
120+
<wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
121+
<soap:address location="http://www.webservicex.net/stockquote.asmx" />
122+
</wsdl:port>
123+
<wsdl:port name="StockQuoteSoap12" binding="tns:StockQuoteSoap12">
124+
<soap12:address location="http://www.webservicex.net/stockquote.asmx" />
125+
</wsdl:port>
126+
<wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet">
127+
<http:address location="http://www.webservicex.net/stockquote.asmx" />
128+
</wsdl:port>
129+
<wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost">
130+
<http:address location="http://www.webservicex.net/stockquote.asmx" />
131+
</wsdl:port>
132+
</wsdl:service>
133+
</wsdl:definitions>

mvn-scalaxb/src/main/java/org/scalaxb/maven/AbstractScalaxbMojo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ public abstract class AbstractScalaxbMojo extends AbstractMojo {
279279
@Parameter(property = "scalaxb.verbose")
280280
private boolean verbose;
281281

282+
/**
283+
* Specifies which JAXB package to use when generating code.
284+
* Use {@code "javax"} for environments based on Java EE (up to Java 8),
285+
* or {@code "jakarta"} for newer Jakarta EE–based environments (Java 11+).
286+
* Default is {@code "javax"} for back compability.
287+
*/
288+
@Parameter(property = "scalaxb.jaxbPackage", defaultValue = "javax")
289+
private String jaxbPackage;
290+
282291
/**
283292
* Returns the directory in which to search for XSD schema files.
284293
* @return The directory containing the XSD files.
@@ -357,6 +366,7 @@ protected List<String> arguments() {
357366
.flag("--no-dispatch-client", !generateDispatchClient)
358367
.flag("--dispatch-as", generateDispatchAs)
359368
.param("--dispatch-version", dispatchVersion)
369+
.param("--jaxb-package", jaxbPackage)
360370
.flag("--tagless-final-client", tagless)
361371
.flag("--mapK", mapK)
362372
.flag("--http4s-client", generateHttp4sClient)

mvn-scalaxb/src/test/java/org/scalaxb/maven/it/ITP06Blocking.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ITP06Blocking extends AbstractIT {
1616
"soapenvelope12/soapenvelope12_xmlprotocol.scala"
1717
};
1818

19+
1920
@Test
2021
public void filesAreGeneratedInCorrectLocation() {
2122
assertFilesGenerated("itp06-blocking", expected);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.scalaxb.maven.it;
2+
3+
import org.junit.Test;
4+
5+
public class ITP07JakartaPackage extends AbstractIT {
6+
7+
private String[] expected = new String[] {
8+
"generated/stockquote.scala",
9+
"generated/stockquote_type1.scala",
10+
"generated/xmlprotocol.scala",
11+
"scalaxb/httpclients_dispatch.scala",
12+
"scalaxb/httpclients.scala",
13+
"scalaxb/scalaxb.scala",
14+
"scalaxb/soap12.scala",
15+
"soapenvelope12/soapenvelope12.scala",
16+
"soapenvelope12/soapenvelope12_xmlprotocol.scala"
17+
};
18+
19+
@Test
20+
public void filesAreGeneratedInCorrectLocation() {
21+
assertFilesGenerated("itp07-jakarta-package", expected);
22+
}
23+
24+
}

0 commit comments

Comments
 (0)