2014-10-24 2 views
-1

Команда развертывания требует, чтобы мы упаковывали наш сайт maven в качестве войны и публиковали его в репозитории Archiva.Сборка сайта, включая детей

Наша первая проблема, как собрать войну, с детскими сайтами внутри.

Я пробую это, но он не работает. Созданная война не включает детские сайты. Я изучаю документацию maven, google, в stackoverflow и т. Д., И я ничего не нашел.

папки Структура

проекта:

. 
├── child-yyyy-1 
│   ├── pom.xml 
│   └── src 
│    ├── main 
│    │   └── java 
│    │    └── com 
│    │     └── xxx 
│    │      └── App.java 
│    └── test 
│     └── java 
├── child-yyyy-2 
│   ├── pom.xml 
│   └── src 
│    ├── main 
│    │   └── java 
│    │    └── com 
│    │     └── xxx 
│    │      └── App.java 
│    └── test 
│     └── java 
└── parent-site 
    ├── assembly 
    │   └── api-site.xml 
    └── pom.xml 

родитель ПОМ:

<?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> 
    <groupId>com.xxx</groupId> 
    <artifactId>parent-yyyy</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <name>parent-yyyy</name> 

    <modules> 
    <module>../child-yyyy-1</module> 
    <module>../child-yyyy-2</module> 
    </modules> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <configuration> 
        <descriptors> 
         <descriptor>assembly/api-site.xml</descriptor> 
        </descriptors> 
       </configuration> 
       <executions> 
        <execution> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

апи-site.xml

<?xml version="1.0" encoding="UTF-8"?> 
<assembly 
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> 
    <id>api-site</id> 
    <formats> 
     <format>war</format> 
    </formats> 
    <baseDirectory>/</baseDirectory> 
    <fileSets> 
     <fileSet> 
      <outputDirectory>/</outputDirectory> 
      <directory>target/site</directory> 
     </fileSet> 
     <fileSet> 
      <outputDirectory>/child-yyyy-1/</outputDirectory> 
      <directory>child-yyyy-1/target/site</directory> 
     </fileSet> 
     <fileSet> 
      <outputDirectory>/child-yyyy-2/</outputDirectory> 
      <directory>child-yyyy-2/target/site</directory> 
     </fileSet> 
    </fileSets> 
</assembly> 

ребенок 1 ПОМ:

<?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> 
    <groupId>com.xxx</groupId> 
    <artifactId>parent-yyyy</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../site</relativePath> 
    </parent> 
    <groupId>com.xxx</groupId> 
    <artifactId>child-yyyy-1</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <name>child-yyyy-1</name> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
</project> 

ребенок 2 П:

<?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> 
    <groupId>com.xxx</groupId> 
    <artifactId>parent-yyyy</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../site</relativePath> 
    </parent> 
    <groupId>com.xxx</groupId> 
    <artifactId>child-yyyy-2</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <name>child-yyyy-2</name> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
</project> 
+0

Кто-то -1. Почему -1? Прокомментируйте, пожалуйста. – angelcervera

ответ

1

первый, у вас есть неправильная структура проекта, что означает, у вас есть родитель в подпапках ... лучше испытывают родитель, как это.

+-- parent (pom.xml) 
     +--- child1 (pom.xml) 
     +--- child2 (pom.xml) 
     .... 

Это позволит упростить родитель вам не нужно давать ../ для модулей ... и в Чайлдсе вам не нужно, чтобы дать relativePath элементов родителя.

Кроме того, что определение maven-assembly-plugin в родительском объекте не имеет смысла, потому что родитель будет выполнен первым, что означает, что в то время вы не создали сайты.

решение по умолчанию для этого создать отдельный дочерний

+-- parent (pom.xml) 
     +--- child1 (pom.xml) 
     +--- child2 (pom.xml) 
     +--- site-child (pom.xml) 

Определение Maven-сборочный-плагин, как вы делали и очень важно определять зависимости к Чайлдс своих сайтов, которые вы хотели бы включить ,

Из всего выше сайта генерируется с помощью:

mvn site 

, который означает, что вы находитесь в жизни сайта цикла, который означает, что вы должны packagage войны в жизни сайта цикла, а не в жизни по умолчанию цикл ОС вам необходимо изменить конфигурацию для Maven-сборки-плагин от этого:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptors> 
        <descriptor>assembly/api-site.xml</descriptor> 
       </descriptors> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

к следующему:

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <descriptors> 
        <descriptor>assembly/api-site.xml</descriptor> 
       </descriptors> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>site</phase> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

После этого должен быть в состоянии создать это с помощью:

mvn site