2011-07-15 8 views
6

Durumum hakkında hızlı brifing - JAX-WS açıklamalı arayüzleri/sınıfları olan bir kod tabanı üzerinde çalışıyorum kod ilk wsdls üretiyoruz. Biz her modül için üretilen .jar içinde dahil etmek için maven içinde inşa zamanında wsdls üretmek için CXF's cxf-java2ws-eklenti kullanıyoruz. Yapmamız istiyoruz ne

maven depo

  • olarak eğreti bir hizmet deposu hareket edebilir beri
  • müşterilerine kolay vermek (örneğin anlatıldığı here gibi) bir maven deposuna bu wsdl dosyaları dağıtmak olduğunu maven işaret ederek cxf codegen plugin kullanmak yolu yerine wsdl yönetmenin wsdl koordinatlarını dosyalarının kendilerini

şimdiye kadar var bağımlılığı kullanan bir pom dosyasıdır ettik ne: paketten-bağımlılıklar tüm almak için Projedeki wsdl dosyalarının bu modüller içindeki bir dizine $ {project.build.directory} (yaygın olarak herkes tarafından hedef olarak bilinir).

Ne yapmamayı bilmiyorum, bu dosyaların her birine döngü yapmak ve her wsdl'ye deploy:deploy-file mojo çağırmaktır. Gerçekten bu wsdl dosyalarını dağıtma işlemini otomatikleştirmek istediğimden ve hiç kimsenin el ile dağıtmasını istemediğim için seçeneklerim nedir? (Her biri bağlıydı olan Jar içinde de/WSDL içinde bulunan) hedef/WSDL wsdls shoves

<?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> 

:

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

tamlık olması için

, burada pom dosyasıdır


Çözüm

Düşünce wha Uyguladığım Ryan Ryan tarafından sağlanan kabul edilen cevaptan farklıydı, kendi yanıtımı yazmamdan dolayı cevabını kabul ettim. Temel olarak, burada yukarıda açıklanan çok modüllü projede bir alt modüle sahip bir maven pomdırdır. Bağımlılık kullanıyorum: paket-bağımlılıkları ve dağıtımı çağırmak için bir in-line groovy komut dosyası kullanıyorum: bu wsdl dosyalarının her birine dağıtım dosyası. Bu bir hackjob biraz, ama bu modülde wsdl dosyaları için kodlama yolları ve dağıtımı birkaç execations çağırmak için daha iyi bir yolu düşünemiyorum: dağıtmak-dosya mojo üzerlerine, çok bir verbose yol açan pon.

<?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> 
+0

Bunu çok beğeniyorum. Benzer bir şey yapmam gerek. –

cevap

2

Başka bir olasılık: Maven Ant görevleri deploy files olabilir. Onu hiç kullanmadım, ama bahse girerim ki tüm WSDL'leri almak ve dağıtmak için bir anten konfigürasyonu ve bazı karekök eşleme kullanabilirsiniz.

+1

Buna benzer bir şey yaptım ancak GMaven (groovy'nin maven eklentisi) ile wsdl dosya adlarını çevreleyen ve her birinde mvn konuşlandırma: konuşlandırma dosyasını çağırıyor. Cevabınız için teşekkürler ve bunu yapmayı düşünmemi sağlayın. – whaley

2

Yapı Yardımcısı eklentisi size yardımcı olabilir. WSDL'leri yayınlayabiliyorsunuz, ancak her birini açık bir şekilde listelemeniz gerekecek ve hepsinin kendi adınıza pompanızın artifaktı olacak. Sadece sınıflandırıcı değişebilir. Örneğin:

<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> 

Eğer pom en myGroupId olduğunu koordinat: sonra eserler yüklenmiş ve myArtifactId-1.1.1-foo.wsdl ve myArtifactId-1.1.1 adının verileceğini Bu yapılandırma kullanılarak yerleştirilen 1.1.1: myArtifactId -bar.wsdl. Bildiğim en iyisi bu.

+1

Bunu yapabilirim ... ama isimleri önceden bilinemediğim potansiyel olarak değişken bir .wsdl dosyasıyla uğraşıyorum. – whaley

İlgili konular