|
Apache CXF example source code file (WSDL2JavaMojo.java)
The Apache CXF WSDL2JavaMojo.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.maven_plugin; import java.io.File; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.tools.common.ToolContext; import org.apache.cxf.tools.wsdlto.WSDLToJava; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.InvalidRepositoryException; import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectUtils; /** * @goal wsdl2java * @phase generate-sources * @description CXF WSDL To Java Tool * @requiresDependencyResolution test */ public class WSDL2JavaMojo extends AbstractMojo { /** * @parameter expression="${cxf.testSourceRoot}" */ File testSourceRoot; /** * Path where the generated sources should be placed * * @parameter expression="${cxf.sourceRoot}" * default-value="${project.build.directory}/generated-sources/cxf" * @required */ File sourceRoot; /** * @parameter expression="${project.build.outputDirectory}" * @required */ String classesDirectory; /** * @parameter expression="${project}" * @required */ MavenProject project; /** * Default options to be used when a wsdl has not had it's options explicitly specified. * * @parameter */ Option defaultOptions = new Option(); /** * @parameter */ WsdlOption wsdlOptions[]; /** * @parameter expression="${cxf.wsdlRoot}" default-value="${basedir}/src/main/resources/wsdl" */ File wsdlRoot; /** * @parameter expression="${cxf.testWsdlRoot}" default-value="${basedir}/src/test/resources/wsdl" */ File testWsdlRoot; /** * Directory in which the "DONE" markers are saved that * * @parameter expression="${cxf.markerDirectory}" * default-value="${project.build.directory}/cxf-codegen-plugin-markers" */ File markerDirectory; /** * Use the compile classpath rather than the test classpath for execution useful if the test dependencies * clash with those of wsdl2java * * @parameter expression="${cxf.useCompileClasspath}" default-value="false" */ boolean useCompileClasspath; /** * Disables the scanning of the wsdlRoot/testWsdlRoot directories configured above. * By default, we scan for *.wsdl (see include/exclude params as well) in the wsdlRoot * directories and run wsdl2java on all the wsdl's we find. This disables that scan * and requires an explicit wsdlOption to be set for each wsdl that needs to be processed. * @parameter expression="${cxf.disableDirectoryScan}" default-value="false" */ boolean disableDirectoryScan; /** * By default all maven dependencies of type "wsdl" are added to the effective wsdlOptions. Setting this * parameter to true disables this functionality * * @parameter expression="${cxf.disableDependencyScan}" default-value="false" */ boolean disableDependencyScan; /** * A list of wsdl files to include. Can contain ant-style wildcards and double wildcards. Defaults to * *.wsdl * * @parameter */ String includes[]; /** * A list of wsdl files to exclude. Can contain ant-style wildcards and double wildcards. * * @parameter */ String excludes[]; /** * The local repository taken from Maven's runtime. Typically $HOME/.m2/repository. * * @parameter expression="${localRepository}" * @readonly * @required */ private ArtifactRepository localRepository; /** * Artifact factory, needed to create artifacts. * * @component * @readonly * @required */ private ArtifactFactory artifactFactory; /** * The remote repositories used as specified in your POM. * * @parameter expression="${project.repositories}" * @readonly * @required */ private List repositories; /** * Artifact repository factory component. * * @component * @readonly * @required */ private ArtifactRepositoryFactory artifactRepositoryFactory; /** * The Maven session. * * @parameter expression="${session}" * @readonly * @required */ private MavenSession mavenSession; /** * @component * @readonly * @required */ private ArtifactResolver artifactResolver; /** * Merge WsdlOptions that point to the same file by adding the extraargs to the first option and deleting * the second from the options list * * @param options */ private void mergeOptions(List<WsdlOption> effectiveWsdlOptions) { if (wsdlOptions == null) { return; } File outputDirFile = testSourceRoot == null ? sourceRoot : testSourceRoot; for (WsdlOption o : wsdlOptions) { if (defaultOptions != null) { o.merge(defaultOptions); } if (o.getOutputDir() == null) { o.setOutputDir(outputDirFile); } File file = o.getWsdlFile(project.getBasedir()); if (file != null && file.exists()) { file = file.getAbsoluteFile(); for (WsdlOption o2 : effectiveWsdlOptions) { File file2 = o2.getWsdlFile(project.getBasedir()); if (file2 != null && file2.exists() && file2.getAbsoluteFile().equals(file)) { o.getExtraargs().addAll(0, o2.getExtraargs()); effectiveWsdlOptions.remove(o2); break; } } } effectiveWsdlOptions.add(o); } } /** * @return effective WsdlOptions * @throws MojoExecutionException */ private List<WsdlOption> createWsdlOptionsFromScansAndExplicitWsdlOptions() throws MojoExecutionException { List<WsdlOption> effectiveWsdlOptions = new ArrayList Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF WSDL2JavaMojo.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.