1

我目前正在使用 maven 构建 Alfresco。我的主 pom 里面有几个子 pom,每个里面都有一个现在只是 SNAPSHOT-1.0 的。

如果我从命令行执行 mvn 安装,我会在 /target/.war 中获得战争文件,但是当我在 Jenkins 中构建时,我会获得名为 -SNAPSHOT-1.0.war 的人工制品。在工作区中,它们仍然是 .war,但 Jenkins 出于某种原因通过附加 maven 版本来创建人工制品。

如果我想将这些战争部署到应用程序服务器(现在我仅限于 ssh 部署),我需要先重命名它们,以便使用正确的上下文根部署它们。

无论如何,是否可以将人工制品作为其正常名称提供给其他构建作业,而无需版本号?现在我只有一份工作,在部署之前复制人工制品并重命名它们,但我认为必须有一种更清洁的方式。

更新:主 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nz.net.example</groupId>
<artifactId>dept-alfresco</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Quickstart of Alfresco and Share with DB and runner embedded</name>
<description>This All-in-One project allows to manage all the components involved in Alfresco development (Repo, Share, Solr, AMPs) in one project</description>
<packaging>pom</packaging>    

<parent>
    <groupId>org.alfresco.maven</groupId>
    <artifactId>alfresco-sdk-parent</artifactId>
    <version>1.0</version>
</parent>

<!-- 
   | SDK properties have sensible defaults in the SDK parent,
   | but you can override the properties below to use another version. 
   | For more available properties see the alfresco-sdk-parent POM. 
   -->
<properties>
    <alfresco.groupId>org.alfresco</alfresco.groupId>
    <alfresco.version>4.2.c</alfresco.version>
    <app.log.root.level>WARN</app.log.root.level>
    <alfresco.data.location>alf_data_dev</alfresco.data.location>
    <alfresco.port>8080</alfresco.port> 
    <share.port>8080</share.port>
    <!-- This controls which properties will be picked in src/test/properties for embedded run -->
    <env>local</env>

    <!-- Build Information to be injected during Jenkins build process -->
    <build.date>Not Built with Jenkins</build.date>
    <jenkins.buildNo>Not Built with Jenkins</jenkins.buildNo>
    <jenkins.buildURL>Not Built with Jenkins</jenkins.buildURL>
    <jenkins.job>Not Built with Jenkins</jenkins.job>
    <git.branch>Not Built with Jenkins</git.branch>
    <git.commit>Not Built with Jenkins</git.commit>
</properties>

<!-- Here we realize the connection with the Alfresco selected platform (e.g.version and edition) -->
<dependencyManagement>
 <dependencies>
      <!-- This will import the dependencyManagement for all artifacts in the selected Alfresco plaftorm
           (see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies)
           NOTE: You still need to define dependencies in your POM, but you can omit version as it's enforced by this dependencyManagement.
           NOTE: It defaults to the latest version this SDK pom has been tested with, but alfresco version can/should be overridden in your project's pom   
       -->
      <dependency>
          <groupId>${alfresco.groupId}</groupId>
          <artifactId>alfresco-platform-distribution</artifactId>
          <version>${alfresco.version}</version>
          <type>pom</type>
          <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>
</dependencyManagement>

<!--
No more repos are needed since they will be inherited by the parent POM. 
This is needed to download the alfresco-plaftorm POM.
-->
<repositories>
    <repository>
        <id>alfresco-artifacts</id>
        <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
    </repository>
    <repository>
        <id>alfresco-artifacts-snapshots</id>
        <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
    </repository>
</repositories>
  <modules>
<module>amp</module>
<module>alfresco</module>
<module>solr</module>
<module>share</module>
<module>wcmqs</module>
<module>runner</module>
</modules>
</project>

这是subpom

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
license agreements. See the NOTICE file distributed with this work for additional 
information regarding copyright ownership. The ASF licenses this file to 
You under the Apache License, Version 2.0 (the "License"); you may not use 
this file except in compliance with the License. You may obtain a copy of 
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
by applicable law or agreed to in writing, software distributed under the 
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
OF ANY KIND, either express or implied. See the License for the specific 
language governing permissions and limitations under the License. -->
<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>
<artifactId>alfresco</artifactId>
<name>Alfresco Repository and Explorer Client</name>
<packaging>war</packaging>
<description>Alfresco Repository and Explorer Client</description>
<parent>
    <groupId>nz.net.example</groupId>
    <artifactId>dept-alfresco</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
    <dependency>
        <groupId>${alfresco.groupId}</groupId>
        <artifactId>alfresco</artifactId>
        <type>war</type>
    </dependency>
     <!--
     <dependency> 
        <groupId>${alfresco.groupId}</groupId>
        <artifactId>alfresco-repository</artifactId>
    </dependency>
     -->
</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <!--  Here is can control the order of overlay of your (WAR, AMP, etc.) dependencies
                    | NOTE: At least one WAR dependency must be uncompressed first
                    | NOTE: In order to have a dependency effectively added to the WAR you need to 
                    | explicitly mention it in the overlay section.
                    | NOTE: First-win resource strategy is used by the WAR plugin
                     -->
                <overlays>
                    <!-- Current project customizations -->
                    <overlay />
                    <!-- The Alfresco WAR -->
                    <overlay>
                        <groupId>${alfresco.groupId}</groupId>
                        <artifactId>alfresco</artifactId>
                        <type>war</type>
                        <!-- To allow inclusion of META-INF -->
                        <excludes />
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>
4

1 回答 1

0

(您可能应该粘贴您的 pom.xml 以获得更好的答案......)但这是“第一次努力/最佳猜测”

如果您使用maven-dependency-plugin将库复制到工作区中,则可以使用配置选项剥离版本。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.6</version>
    <executions>
      <execution>
        <id>copy</id>
        <phase>validate</phase>
        <goals>
          <goal>copy</goal>
        </goals>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>org.bouncycastle</groupId>
              <artifactId>bcprov-jdk16</artifactId>
            </artifactItem>
          </artifactItems>
          <outputDirectory>lib</outputDirectory>
          <overWriteReleases>true</overWriteReleases>
          <overWriteSnapshots>true</overWriteSnapshots>
          <overWriteIfNewer>true</overWriteIfNewer>
          <stripVersion>true</stripVersion>        <-------here
        </configuration>
      </execution>
    </executions>
  </plugin>
于 2013-05-30T05:07:41.987 回答