Tóm tắt nhanh về tình huống của tôi - Tôi đang làm việc trên cơ sở mã có giao diện/lớp chú thích JAX-WS chúng tôi tạo ra các wsdls mã đầu tiên. Chúng tôi đang sử dụng cxf-java2ws-plugin của CXF để tạo các wsdls tại thời gian xây dựng bên trong maven để đưa vào bên trong .jar được tạo cho mỗi mô-đun.
gì chúng tôi muốn làm là triển khai những tập tin này wsdl đến một kho maven từ kho maven thể hoạt động như
- một kho lưu trữ dịch vụ tạm thời (như mô tả here)
- cung cấp cho khách hàng một cách dễ dàng cách sử dụng cxf codegen plugin bằng cách chỉ đến maven phối cho một wsdl thay vì quản lý wsdl tập tin bản thân
những gì tôi đã có cho đến nay là một tập tin pom có sử dụng phụ thuộc: giải nén-phụ thuộc để có được tất cả của các tệp wsdl trong dự án vào một thư mục trong mô-đun này $ {project.build.directory} (thường được gọi là target/to everyone out there).
Điều tôi không biết phải làm là lặp qua từng tệp này và gọi deploy:deploy-file mojo trên mỗi wsdl. Các tùy chọn của tôi ở đây là gì vì tôi thực sự muốn tự động hóa quy trình triển khai các tệp wsdl này và không có ai từng triển khai chúng theo cách thủ công?
Đối với đầy đủ lợi ích, đây là tập tin pom:
<?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>
<!-- Depends on all API modules and modules that generate or contain wsdls -->
<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>
nào dìm các WSDLs trong mục tiêu/wsdl (họ được chứa trong wsdl/bên trong mỗi .jar bị phụ thuộc vào):
[[email protected] ~/Repositories/Kuali/rice/dist-wsdl]
> find . -iname '*.wsdl' | head -3
./target/wsdl/CampusService.wsdl
./target/wsdl/CountryService.wsdl
./target/wsdl/CountyService.wsdl
giải pháp
tưởng wha Tôi đã thực hiện khác với câu trả lời được chấp nhận do Ryan Steward cung cấp, tôi chấp nhận câu trả lời của anh ấy vì nó đã dẫn tôi viết câu trả lời của riêng tôi.
Về cơ bản, đây là một maven pom đó là một submodule trong dự án đa mô-đun được mô tả ở trên. Tôi đang sử dụng sự phụ thuộc: unpack-dependencies và sau đó sử dụng một kịch bản lệnh groovy trực tuyến để gọi deploy: deploy-file trên từng tệp wsdl đó. Đó là một chút của một hackjob, nhưng tôi không thể nghĩ ra một cách tốt hơn để làm điều này mà không cần hardcoding đường dẫn đến các tập tin wsdl trong mô-đun và gọi một số thực thi triển khai: triển khai tập tin mojo trên chúng, dẫn đến một rất tiết pom.
<?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>
<!-- Depends on all API modules and modules that generate or contain wsdls -->
<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>
Tôi thích điều này rất nhiều. Tôi cần phải làm một cái gì đó tương tự. –