7

私の状況についての簡単な説明-私は、コードファーストのwsdlを生成するJAX-WS注釈付きインターフェース/クラスを持つコードベースに取り組んでいます。CXFのcxf-java2ws-pluginを使用して、ビルド時にmaven内でwsdlを生成し、各モジュール用に生成された.jarに含めます。

mavenリポジトリは次のように機能できるため、これらのwsdlファイルをmavenリポジトリにデプロイします。

  • その場しのぎのサービスリポジトリ(ここで説明されているような)
  • wsdlファイル自体を管理する代わりに、wsdlのMaven座標をポイントすることにより、 cxfcodegenプラグインを使用する簡単な方法をクライアントに提供します

これまでに入手したのは、dependency:unpack-dependenciesを使用して、プロジェクト内のすべてのwsdlファイルをこのモジュール内の1つのディレクトリ$ {project.build.directory}(一般にtarget / toみんな)。

方法がわからないのは、これらの各ファイルをループして、各wsdlでdeploy:deploy- filemojoを呼び出すことです。これらのwsdlファイルをデプロイするプロセスを本当に自動化し、誰も手動でデプロイしたくないので、ここでのオプションは何ですか?

完全を期すために、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>

これは、target / wsdl内のwsdlを押し込みます(これらは、依存している各.jar内のwsdl /内に含まれています):

[whaley@sunspot ~/Repositories/Kuali/rice/dist-wsdl] 
> find . -iname '*.wsdl' | head -3
./target/wsdl/CampusService.wsdl
./target/wsdl/CountryService.wsdl
./target/wsdl/CountyService.wsdl

解決

私が実装したものはライアン・スチュワードによって提供された受け入れられた答えとは異なると思いましたが、それが私自身を書くように導いたので、私は彼の答えを受け入れました。

基本的に、これは上記のマルチモジュールプロジェクトのサブモジュールであるMavenPomです。私はdependency:unpack-dependenciesを使用してから、インラインgroovyスクリプトを使用して、これらの各wsdlファイルでdeploy:deploy-fileを呼び出しています。これはちょっとしたハックジョブですが、モジュール内のwsdlファイルへのパスをハードコーディングし、それらでdeploy:deploy-file mojoのいくつかの実行を呼び出すことなく、これを行うためのより良い方法を考えることはできませんでした。 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 &amp;&amp; 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>
4

2 に答える 2

2

別の可能性:MavenAntタスクはファイルをデプロイできます。私はこれを使用したことはありませんが、antrun構成といくつかのantパターンマッチングを使用して、すべてのWSDLを取得してデプロイできると思います。

于 2011-07-16T03:44:16.040 に答える
2

BuildHelperプラグインが役立つかもしれません。WSDLを公開することはできますが、それぞれを明示的にリストする必要があり、それらはすべて、名前にpomのartifactIdが含まれます。分類子のみを変更できます。例えば:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>attach-WSDLs</id>
            <phase>package</phase>
            <goals>
                <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                    <artifact>
                        <file>${project.build.directory}/foo.wsdl</file>
                        <classifier>foo</classifier>
                        <type>wsdl</type>
                    </artifact>
                    <artifact>
                        <file>${project.build.directory}/bar.wsdl</file>
                        <classifier>bar</classifier>
                        <type>wsdl</type>
                    </artifact>
                </artifacts>
            </configuration>
        </execution>
    </executions>
</plugin>

pomの座標がmyGroupId:myArtifactId:1.1.1の場合、この構成を使用してインストールおよびデプロイされたアーティファクトは、myArtifactId-1.1.1-foo.wsdlおよびmyArtifactId-1.1.1-bar.wsdlという名前になります。それは私が知っている最高です。

于 2011-07-16T02:33:35.687 に答える