2014-07-11 19 views
6

Projelerimden birine yönetilen bağımlılığı olan bir arketip hazırladım. Arketipim ile yeni bir proje oluşturulduğunda, her zaman bu bağımlılığın en son sürüm sürümünü kullanmak için arketipi anlatma olanağı var mı? RELEASE'u kullanmak benim için işe yaramıyor, çünkü projenin her kurulduğunda sürümü değiştirmek istemiyorum. Archetype her zaman bağımlılığın en son sürümünü kullanmalıdır

<?xml version="1.0" encoding="utf-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>${groupId}</groupId> 
    <artifactId>${artifactId}</artifactId> 
    <version>${version}</version> 
    <packaging>jar</packaging> 

    <dependencies> 
     <dependency> 
      <groupId>com.mycompany.someproject</groupId> 
      <artifactId>someDependency</artifactId> 
     </dependency> 
    </dependencies> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>com.mycompany.myproject</groupId> 
       <artifactId>myArtifact</artifactId> 

       <version>LATEST</version> 
       <type>pom</type> 
       <scope>import</scope> 
      </dependency> 
     </dependencies> 
    </dependencyManagement> 
</project> 

Ben this soru okudum ama maven-versiyonları-eklenti ile önerilen çözüm iki nedenden dolayı uygun görünmemektedir. Öncelikle, Proje'yi oluşturduğumda sürümü değiştirmek istiyorum ve ikincisi tüm bağımlılıkların versiyonlarını değiştirmek istemiyorum ama sadece bir tanesi.

Düzenleme: yukarıdaki archetype-kaynaklarından pom.xml olduğunu (güncellendi), aşağıda benim archetype-projenin kendisi pom.xml olduğunu.

<?xml version="1.0" encoding="UTF-8"?> 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <parent> 
     <groupId>com.mycompany.maven.archetype.be</groupId> 
     <artifactId>maven-archetype-be-_moduleList</artifactId> 
     <version>1.3-SNAPSHOT</version> 
     <relativePath>../maven-archetype-be</relativePath> 
    </parent> 
    <artifactId>archetype-be-api</artifactId> 
    <packaging>maven-archetype</packaging> 
    <dependencies /> 
    <name>archetype-be-api</name> 
</project> 

EDIT2: RELEASE ve LATEST yönetilen bağımlılıkları hiç çalışmıyor gibi. Bu ifadeyi herkes onaylayabilir veya devre dışı bırakabilir mi?

+0

için, hala SON belirtebilirsiniz sizin arketip projeden projeye oluşturmak için Farkında olmadığınız değişikliklerin. Ama yine de yapmak istiyorsan, bu bağlantıya bakabilirsin, soruyu çok iyi açıklıyor. http://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency – SerhatCan

cevap

1

Sen

<dependency> 
     <groupId>com.mycompany.myproject</groupId> 
     <artifactId>my-artifact</artifactId> 
     <version>LATEST</version> 
     <type>pom</type> 
     <scope>import</scope> 
    </dependency> 

LATEST son kullanılabilir sürümünü gidermek ve

inşa veya -U her zaman belirtmek istemiyorsanız eğer senin settings.xml~/.m2 içinde yapılandırabilirsiniz zaman -U geçecek koyabilirsiniz th'yi çalıştırdığınızda

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
         http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    ... 
    <profiles> 
    <profile> 
     ... 
     <repositories> 
     <repository> 
      <id>codehausSnapshots</id> 
      <name>Codehaus Snapshots</name> 
      <releases> 
      <enabled>false</enabled> 
      <updatePolicy>always</updatePolicy> // <-- this will update each release artifact from this repository each time 
      <checksumPolicy>warn</checksumPolicy> 
      </releases> 
      <url>http://snapshots.maven.codehaus.org/maven2</url> 
      <layout>default</layout> 
     </repository> 
     </repositories> 
     <pluginRepositories> 
     ... 
     </pluginRepositories> 
     ... 
    </profile> 
    </profiles> 
    ... 
</settings> 

Yalnızca bir bağımlılık için bunu yapmak isteseniz bile e mvn bazı ciddi problemler nedeniyle yol açtı çünkü bunu yeniden gözden geçirmek isteyebilirsiniz, örneğin

mvn archetype:generate 
    -DarchetypeGroupId=you_archetype_group_id 
    -DarchetypeArtifactId=sample-spring-mvc-archetype 
    -DarchetypeVersion=LATEST -DgroupId=new.project.id 
    -DartifactId=sample 
    -DarchetypeRepository=path_to_maven_repo_with_archetype_jar 
+0

Cevabınız için teşekkür ederim, ama istediğim bu değil yapmak. Bir proje ** oluşturulduğunda, en son sürümü kontrol etmek istiyorum. – Kayz

+0

, arcadeype rpoject –

+0

'unuzun pom.xml dosyanızı güncelleyebilir, lütfen güncellenmiş soruma bakın. – Kayz

İlgili konular