use of org.apache.cxf.maven_plugin.GenericWsdlOption in project cxf by apache.
the class WSDL2JavaMojo method mergeOptions.
/**
* 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 effectiveWsdlOptions
*/
protected void mergeOptions(List<GenericWsdlOption> effectiveWsdlOptions) {
File outputDirFile = getGeneratedTestRoot() == null ? getGeneratedSourceRoot() : getGeneratedTestRoot();
List<GenericWsdlOption> newList = new ArrayList<>();
for (GenericWsdlOption go : effectiveWsdlOptions) {
WsdlOption o = (WsdlOption) go;
if (defaultOptions != null) {
o.merge(defaultOptions);
}
/*
* If not output dir at all, go for tests, and failing that, source.
*/
if (o.getOutputDir() == null) {
o.setOutputDir(outputDirFile);
}
File file = o.getWsdlFile(project.getBasedir());
if (file != null && file.exists()) {
file = file.getAbsoluteFile();
boolean duplicate = false;
for (GenericWsdlOption o2w : newList) {
WsdlOption o2 = (WsdlOption) o2w;
File file2 = o2.getWsdlFile(project.getBasedir());
if (file2 != null && file2.exists() && file2.getAbsoluteFile().equals(file)) {
o2.getExtraargs().addAll(0, o.getExtraargs());
duplicate = true;
break;
}
}
if (!duplicate) {
newList.add(o);
}
} else {
newList.add(o);
}
}
effectiveWsdlOptions.clear();
effectiveWsdlOptions.addAll(newList);
}
use of org.apache.cxf.maven_plugin.GenericWsdlOption in project cxf by apache.
the class WsdlOptionLoader method loadWsdlOptionsFromDependencies.
public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project, File outputDir) {
List<GenericWsdlOption> options = new ArrayList<>();
Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
for (Artifact artifact : dependencies) {
WsdlOption option = generateWsdlOptionFromArtifact(artifact, outputDir);
if (option != null) {
options.add(option);
}
}
return options;
}
use of org.apache.cxf.maven_plugin.GenericWsdlOption in project cxf by apache.
the class WSDL2JavaScriptMojo method shouldRun.
@Override
protected boolean shouldRun(GenericWsdlOption genericWsdlOption, File doneFile, URI wsdlURI) {
WsdlOption wsdlOption = (WsdlOption) genericWsdlOption;
long timestamp = 0;
if ("file".equals(wsdlURI.getScheme())) {
timestamp = new File(wsdlURI).lastModified();
} else {
try {
timestamp = wsdlURI.toURL().openConnection().getDate();
} catch (Exception e) {
// ignore
}
}
boolean doWork = false;
if (!doneFile.exists()) {
doWork = true;
} else if (timestamp > doneFile.lastModified()) {
doWork = true;
} else {
File[] files = wsdlOption.getDependencies();
if (files != null) {
for (int z = 0; z < files.length; ++z) {
if (files[z].lastModified() > doneFile.lastModified()) {
doWork = true;
}
}
}
}
return doWork;
}
use of org.apache.cxf.maven_plugin.GenericWsdlOption in project cxf by apache.
the class WSDL2JavaScriptMojo method loadWsdlOptionsFromDependencies.
public static List<GenericWsdlOption> loadWsdlOptionsFromDependencies(MavenProject project, Option defaultOptions, File outputDir) {
List<GenericWsdlOption> options = new ArrayList<>();
Set<Artifact> dependencies = CastUtils.cast(project.getDependencyArtifacts());
for (Artifact artifact : dependencies) {
WsdlOption option = new WsdlOption();
if (WsdlUtilities.fillWsdlOptionFromArtifact(option, artifact, outputDir)) {
if (defaultOptions != null) {
option.merge(defaultOptions);
}
options.add(option);
}
}
return options;
}
use of org.apache.cxf.maven_plugin.GenericWsdlOption in project cxf by apache.
the class WSDL2JavaScriptMojo method loadWsdlOptionsFromFiles.
private List<GenericWsdlOption> loadWsdlOptionsFromFiles(File wsdlBasedir, File defaultOutputDir) throws MojoExecutionException {
if (wsdlBasedir == null) {
return Collections.emptyList();
}
if (!wsdlBasedir.exists()) {
throw new MojoExecutionException(wsdlBasedir + " does not exist");
}
List<File> wsdlFiles = WsdlUtilities.getWsdlFiles(wsdlBasedir, includes, excludes);
List<GenericWsdlOption> options = new ArrayList<>();
for (File wsdl : wsdlFiles) {
WsdlOption wsdlOption = new WsdlOption();
wsdlOption.setOutputDir(defaultOutputDir);
wsdlOption.setUri(wsdl.toURI().toString());
options.add(wsdlOption);
}
return options;
}
Aggregations