2011-07-06 21 views
8

Tôi đang triển khai một kho lưu trữ Nexus cho Maven và các kiểu mẫu tùy chỉnh trên đó.Danh mục nguyên mẫu của Maven: chỉ định (các) vị trí tùy chỉnh

Tôi muốn thực thi mvn archetype:generate và được nhắc một danh sách các kiểu mẫu nội bộ + tùy chỉnh.

Cách duy nhất tôi tìm thấy để nhắc nguyên mẫu tùy chỉnh (theo cách tiện dụng, có nghĩa là không có URL) là để xác định đường dẫn danh mục nguyên mẫu làm thuộc tính trong cài đặt. Đây không phải là giải pháp hợp lệ vì tôi muốn một số danh mục (và thuộc tính này không thể được ghi đè lên trong CLI).

Có ai có manh mối về cách thực hiện điều đó không?

Cảm ơn trước,


[EDIT] Tôi tìm thấy một báo cáo vấn đề liên quan: http://jira.codehaus.org/browse/ARCHETYPE-273

Và tôi nhận thấy rằng trong archetype:generate, maven cố gắng để đạt được kho trung tâm:

[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml 
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2 

Kết thúc bằng "Kết nối đã hết thời gian" vì tôi không (và không muốn) chỉ định proxy ...

Tôi không hiểu tại sao maven không kiểm tra danh mục nexus ...

+0

tin nào? Tôi gặp vấn đề tương tự ở đây :( – Ruben

Trả lời

5

Tôi cũng có cấu hình Nexus để phản chiếu kho lưu trữ Maven và do đó cũng có danh mục từ xa.

<mirror> 
    <!--This sends everything else to /public --> 
    <id>nexus</id> 
    <mirrorOf>*</mirrorOf> 
    <url>http://afbwt03:8081/nexus/content/groups/JavaRepo/</url> 
</mirror> 

và:

<profile> 
    <id>nexus</id> 
    <repositories> 
     <repository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories> 
</profile> 

Tôi có thể truy cập vào các cửa hàng từ xa chỉ khi tôi sử dụng Maven dòng lệnh sau:

mvn archetype:generate -DarchetypeCatalog=http://afbwt03:8081/nexus/content/groups/JavaRepo 

Nếu tôi không xác định biến archetypeCatalog , Tôi nhận được hành vi tương tự như bạn làm: cố gắng truy cập vào repo1. ... mặc dù một số gương được cấu hình.

+0

Thật không may, như của Maven 3 (tôi tin) đi qua một URL hoặc tên tập tin của một cửa hàng trên dòng lệnh để 'mvn archetype: generate -DarchetypeCatalog = ...' không còn có thể Chỉ địa phương, từ xa và nội bộ được hỗ trợ và cấu hình phải [xảy ra trong tệp settings.xml] (https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html#archetypeCatalog) –

1

Bạn cần có

  • tài sản archetypeRepository quy định tại hồ sơ cá nhân tích cực trong .m2 bạn/settings.xml

  • kho và pluginRepositories chuyển đến gương của bạn, trên cùng một id "trung tâm".

  • và dĩ nhiên, gương được xác định

Apache tài liệu maven trên Plugin nguyên mẫu quy định rằng archetypeRepository là định nghĩa tài sản sử dụng: http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html

bạn .m2/cài đặt.xml phải có các yếu tố tối thiểu này

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

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


    <mirrors> 
     <mirror> 
     <id>central</id> 
     <name>Mirror for maven central</name> 
     <url>http://mymvnhost:8081/nexus/content/groups/public/</url> 
     <mirrorOf>*</mirrorOf> 
     </mirror> 

    </mirrors> 

    <profiles> 
    <profile> 
     <id>dev</id> 

     <properties> 
     <archetypeRepository>http://mymvnhost:8081/nexus/content/groups/public/</archetypeRepository> 
     </properties> 

     <repositories> 
      <repository> 
       <id>central</id> 
       <url>http://central</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </repository> 
     </repositories> 

     <pluginRepositories> 
      <pluginRepository> 
       <id>central</id> 
       <url>http://central</url> 
       <releases><enabled>true</enabled></releases> 
       <snapshots><enabled>true</enabled></snapshots> 
      </pluginRepository> 
     </pluginRepositories> 

    </profile> 
    </profiles> 

    <activeProfiles> 
    <activeProfile>dev</activeProfile> 
    </activeProfiles> 
</settings> 
+0

làm việc cho tôi! – Cheloute

Các vấn đề liên quan