Quick briefing on my situation. I am working on a code base that has JAX-WS annotated interfaces / classes from which we generate the first wsdls with code. We use the CXF cxf-java2ws-plugin to generate wsdls during build in maven to include in the .jar created for each module.
What we need to do is deploy these wsdl files to the maven repository, since the maven repository can act as
- temporary service repository (e.g. described here )
- provide customers with an easy way to use the cxf codegen plugin by pointing to the maven coordinates for wsdl instead of managing the wsdl files themselves
What I still have is a pom file that uses the dependency: unpack-dependencies to get all the wsdl files in a project into one directory in these modules $ {project.build.directory} (usually known as target / to everyone there).
What I donβt know how to do is skip each of these files and call deploy: deploy-file mojo on each wsdl. What are my options here since I really want to automate the process of deploying these wsdl files and not use them manually manually?
For completeness, here is the pom file:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>rice</artifactId> <groupId>org.kuali.rice</groupId> <version>2.0.0-m7-SNAPSHOT</version> </parent> <artifactId>rice-dist-wsdl</artifactId> <name>Rice WSDL Distributions</name> <packaging>pom</packaging> <properties> <wsdl.location>${project.build.directory}/wsdl</wsdl.location> </properties> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-core-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-kew-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-kim-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-krms-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-ksb-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-shareddata-api</artifactId> <version>${project.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-wsdls</id> <phase>generate-resources</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includes>**\/*.wsdl</includes> <outputDirectory>${project.build.directory}</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
What forces wsdls to target / wsdl (they are contained inside wsdl / inside each .jar depends on):
[ whaley@sunspot ~/Repositories/Kuali/rice/dist-wsdl] > find . -iname '*.wsdl' | head -3 ./target/wsdl/CampusService.wsdl ./target/wsdl/CountryService.wsdl ./target/wsdl/CountyService.wsdl
Decision
The thought of what I realized was different from Ryan Steward's accepted answer, I accepted his answer because it made me write my own.
Basically, here is maven pom, which is a submodule in the multi-module project described above. I use the dependency: unpack-dependencies, and then using the built-in groovy script to call deploy: deploy-file in each of these wsdl files. This is a bit of a hack, but I could not think of a better way to do this without the hard-coding path to the wsdl files in the module and call several deployment executions: deploy-file mojo on them, which leads to a very detailed point.
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>rice</artifactId> <groupId>org.kuali.rice</groupId> <version>2.0.0-m7-SNAPSHOT</version> </parent> <artifactId>rice-dist-wsdl</artifactId> <name>Rice WSDL Distributions</name> <packaging>pom</packaging> <properties> <wsdl.location>${project.build.directory}/wsdl</wsdl.location> </properties> <dependencies> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-core-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-kew-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-kim-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-krms-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-ksb-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rice-shareddata-api</artifactId> <version>${project.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-wsdls</id> <phase>generate-resources</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includes>**\/*.wsdl</includes> <outputDirectory>${project.build.directory}</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>gmaven-plugin</artifactId> <executions> <execution> <phase>deploy</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> def repo_url def repo_id if ("${project.version}".endsWith("SNAPSHOT")) { repo_url = "${kuali.repository.snapshot.url}" repo_id = "${kuali.repository.snapshot.id}" } else { repo_url = "${kuali.repository.release.url}" repo_id = "${kuali.repository.release.id}" } def wsdlGroupId = "${project.groupId}.wsdl" new File("${wsdl.location}").eachFile() { file -> serviceName = file.name.split("\\.")[0] log.info("Deploying ${wsdlGroupId}:${serviceName}:wsdl:${project.version} to ${repo_id}") execString = "mvn deploy:deploy-file -Dfile=${file} -Durl=${repo_url} -DrepositoryId=${repo_id} " execString += "-DgroupId=${wsdlGroupId} -DartifactId=${serviceName} " execString += "-Dversion=${project.version} -Dpackaging=wsdl -Dclassifier=wsdl" def proc = execString.execute() proc.waitFor() err = proc.err.text if (err != null && err.length() > 0) { log.error(err) fail("Deployment failed for ${wsdlGroupId}:${serviceName}:wsdl:${project.version} to ${repo_id}. \n Run in verbose mode for full error.") } else { log.info("Successfully deployed ${wsdlGroupId}:${serviceName}:wsdl:${project.version} to ${repo_id}") } } </source> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>