Skip to content

Commit

Permalink
Make the destination folder of wsdl2java configurable fix quarkiverse…
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Nov 2, 2023
1 parent 1b0d06f commit 4c51819
Show file tree
Hide file tree
Showing 102 changed files with 7,534 additions and 18 deletions.
46 changes: 46 additions & 0 deletions docs/modules/ROOT/pages/includes/quarkus-cxf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ endif::add-copy-button-to-env-var[]
|


a|icon:lock[title=Fixed at build time] [[quarkus-cxf_quarkus.cxf.codegen.wsdl2java.output-directory]]`link:#quarkus-cxf_quarkus.cxf.codegen.wsdl2java.output-directory[quarkus.cxf.codegen.wsdl2java.output-directory]`


[.description]
--
A directory into which the generated files will be written, either absolute or relative to the current Maven or Gradle module directory.

The default value is build tool dependent: for Maven, it is typically `target/generated-sources/wsdl2java`, while for Gradle it is `build/classes/java/quarkus-generated-sources/wsdl2java`.

Quarkus tooling is only able to set up the default value as a source folder for the given build tool. If you set this to a custom path it is up to you to make sure that your build tool recognizes the path a as source folder.

This will be passed as option `-d` to `wsdl2java`

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_CXF_CODEGEN_WSDL2JAVA_OUTPUT_DIRECTORY+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_CXF_CODEGEN_WSDL2JAVA_OUTPUT_DIRECTORY+++`
endif::add-copy-button-to-env-var[]
--|string
|


a|icon:lock[title=Fixed at build time] [[quarkus-cxf_quarkus.cxf.codegen.wsdl2java.package-names]]`link:#quarkus-cxf_quarkus.cxf.codegen.wsdl2java.package-names[quarkus.cxf.codegen.wsdl2java.package-names]`


Expand Down Expand Up @@ -554,6 +577,29 @@ endif::add-copy-button-to-env-var[]
|


a|icon:lock[title=Fixed at build time] [[quarkus-cxf_quarkus.cxf.codegen.wsdl2java.-named-parameter-sets-.output-directory]]`link:#quarkus-cxf_quarkus.cxf.codegen.wsdl2java.-named-parameter-sets-.output-directory[quarkus.cxf.codegen.wsdl2java."named-parameter-sets".output-directory]`


[.description]
--
A directory into which the generated files will be written, either absolute or relative to the current Maven or Gradle module directory.

The default value is build tool dependent: for Maven, it is typically `target/generated-sources/wsdl2java`, while for Gradle it is `build/classes/java/quarkus-generated-sources/wsdl2java`.

Quarkus tooling is only able to set up the default value as a source folder for the given build tool. If you set this to a custom path it is up to you to make sure that your build tool recognizes the path a as source folder.

This will be passed as option `-d` to `wsdl2java`

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_CXF_CODEGEN_WSDL2JAVA__NAMED_PARAMETER_SETS__OUTPUT_DIRECTORY+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_CXF_CODEGEN_WSDL2JAVA__NAMED_PARAMETER_SETS__OUTPUT_DIRECTORY+++`
endif::add-copy-button-to-env-var[]
--|string
|


a|icon:lock[title=Fixed at build time] [[quarkus-cxf_quarkus.cxf.codegen.wsdl2java.-named-parameter-sets-.package-names]]`link:#quarkus-cxf_quarkus.cxf.codegen.wsdl2java.-named-parameter-sets-.package-names[quarkus.cxf.codegen.wsdl2java."named-parameter-sets".package-names]`


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,22 @@ public interface Wsdl2JavaParameterSet {
*/
public Optional<List<String>> excludes();

/**
* A directory into which the generated files will be written, either absolute or relative to the current Maven
* or Gradle module directory.
* <p>
* The default value is build tool dependent: for Maven, it is typically
* {@code target/generated-sources/wsdl2java}, while for Gradle it is
* {@code build/classes/java/quarkus-generated-sources/wsdl2java}.
* <p>
* Quarkus tooling is only able to set up the default value as a source folder for the given build tool.
* If you set this to a custom path it is up to you to make sure that your build tool recognizes the path
* a as source folder.
* <p>
* This will be passed as option {@code -d} to {@code wsdl2java}
*/
public Optional<String> outputDirectory();

/**
* A comma separated list of tokens; each token can be one of the following:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {

// TODO once https://github.com/quarkusio/quarkus/pull/35963 reaches us we can replace the above with
// final Wsdl2JavaConfig config = context.config().getValue("quarkus.cxf", CxfBuildTimeConfig.class)
// .codegen().wsdl2java();
// .codegen().wsdl2java();

if (!config.enabled()) {
log.info("Skipping " + this.getClass() + " invocation on user's request");
Expand Down Expand Up @@ -122,14 +122,13 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
}
}

static boolean wsdl2java(Path projectDir, Path inputDir, Wsdl2JavaParameterSet params, Path outDir, String prefix,
static boolean wsdl2java(Path projectDir, Path inputDir, Wsdl2JavaParameterSet params, Path defaultOutDir, String prefix,
Map<String, String> processedFiles) {

return scan(inputDir, params.includes(), params.excludes(), prefix, processedFiles, (Path wsdlFile) -> {
final Wsdl2JavaParams wsdl2JavaParams = new Wsdl2JavaParams(
projectDir,
inputDir, outDir, wsdlFile,
params);
defaultOutDir, wsdlFile, params);
if (log.isInfoEnabled()) {
log.info(wsdl2JavaParams.appendLog(new StringBuilder("Running wsdl2java")).toString());
}
Expand Down Expand Up @@ -199,16 +198,14 @@ static Path absModuleRoot(final Path inputDir) {

static class Wsdl2JavaParams {
private final Path projectDir;
private final Path inputDir;
private final Path outDir;
private final Path defaultOutDir;
private final Path wsdlFile;
private final Wsdl2JavaParameterSet params;

public Wsdl2JavaParams(Path projectDir, Path inputDir, Path outDir, Path wsdlFile, Wsdl2JavaParameterSet params) {
public Wsdl2JavaParams(Path projectDir, Path defaultOutDir, Path wsdlFile, Wsdl2JavaParameterSet params) {
super();
this.projectDir = projectDir;
this.inputDir = inputDir;
this.outDir = outDir;
this.defaultOutDir = defaultOutDir;
this.wsdlFile = wsdlFile;
this.params = params;
}
Expand Down Expand Up @@ -237,8 +234,8 @@ static List<String> absolutizeBindings(Path projectDir, List<String> additionalP
}

public StringBuilder appendLog(StringBuilder sb) {
// final Path moduleRoot = absModuleRoot(inputDir);
// render(path -> moduleRoot.relativize(path).toString(), value -> sb.append(' ').append(value));
// final Path moduleRoot = absModuleRoot(inputDir);
// render(path -> moduleRoot.relativize(path).toString(), value -> sb.append(' ').append(value));
render(Path::toString, value -> sb.append(' ').append(value));
return sb;
}
Expand All @@ -251,7 +248,12 @@ public String[] toParameterArray() {

void render(Function<Path, String> pathTransformer, Consumer<String> paramConsumer) {
paramConsumer.accept("-d");
paramConsumer.accept(pathTransformer.apply(outDir));
final Optional<String> outputDirectory = params.outputDirectory();
paramConsumer.accept(
pathTransformer.apply(
outputDirectory.isEmpty()
? defaultOutDir
: projectDir.resolve(outputDirectory.get())));

Stream.of(Wsdl2JavaParameterSet.class.getDeclaredMethods())
.sorted(Comparator.comparing(Method::getName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ void assertParams(Wsdl2JavaParameterSet params, String... expectedParams) {
Path outDir = projectDir.resolve("target/classes");
final Wsdl2JavaParams wsdl2JavaParams = new Wsdl2JavaParams(
projectDir,
inputDir, outDir, wsdlFile,
params);
outDir, wsdlFile, params);
Assertions.assertThat(wsdl2JavaParams.toParameterArray()).containsExactly(expectedParams);

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

package net.java.dev.jaxb.array;

import java.util.ArrayList;
import java.util.List;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;


/**
* <p>Java class for longArray complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>{@code
* <complexType name="longArray">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="item" type="{http://www.w3.org/2001/XMLSchema}long" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* }</pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "longArray", propOrder = {
"item"
})
public class LongArray {

@XmlElement(nillable = true)
protected List<Long> item;

/**
* Gets the value of the item property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the Jakarta XML Binding object.
* This is why there is not a {@code set} method for the item property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getItem().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Long }
*
*
* @return
* The value of the item property.
*/
public List<Long> getItem() {
if (item == null) {
item = new ArrayList<>();
}
return this.item;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

package net.java.dev.jaxb.array;

import jakarta.xml.bind.annotation.XmlRegistry;


/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the net.java.dev.jaxb.array package.
* <p>An ObjectFactory allows you to programmatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {


/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: net.java.dev.jaxb.array
*
*/
public ObjectFactory() {
}

/**
* Create an instance of {@link LongArray }
*
* @return
* the new instance of {@link LongArray }
*/
public LongArray createLongArray() {
return new LongArray();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://jaxb.dev.java.net/array")
package net.java.dev.jaxb.array;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.jboss.eap.quickstarts.wscalculator.barecalculator;

import jakarta.jws.WebMethod;
import jakarta.jws.WebParam;
import jakarta.jws.WebResult;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.xml.bind.annotation.XmlSeeAlso;

/**
* This class was generated by Apache CXF 4.0.3
* 2023-11-02T22:13:05.151+01:00
* Generated source version: 4.0.3
*
*/
@WebService(targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator", name = "BareCalculatorService")
@XmlSeeAlso({ObjectFactory.class, net.java.dev.jaxb.array.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface BareCalculatorService {

@WebMethod
@WebResult(name = "echoResponse", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator", partName = "echoResponse")
public int echo(

@WebParam(partName = "echo", name = "echo", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator")
int echo
);

@WebMethod
@WebResult(name = "addOperandsResponse", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator", partName = "addOperandsResponse")
public Result addOperands(

@WebParam(partName = "addOperands", name = "addOperands", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator")
Operands addOperands
);

@WebMethod
@WebResult(name = "addArrayResponse", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator", partName = "addArrayResponse")
public long addArray(

@WebParam(partName = "bareArray", name = "bareArray", targetNamespace = "http://www.jboss.org/eap/quickstarts/wscalculator/BareCalculator")
net.java.dev.jaxb.array.LongArray bareArray
);
}
Loading

0 comments on commit 4c51819

Please sign in to comment.