2016-03-18 51 views
1

我正在使用Alfresco并使用maven覆盖功能将放大器模块包含到单个WAR文件中。如何从覆盖文件中排除lib文件WAR

这里是我的POM文件

<?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>repo</artifactId> 
    <name>Alfresco Repository WAR Aggregator</name> 
    <packaging>war</packaging> 
    <description>Alfresco Repository aggregator, installs your repository AMPs in the Alfresco WAR for aggregation and easy deployment purposes</description> 

    <parent> 
     <groupId>au.com.abc.alfresco</groupId> 
     <artifactId>enterprise-all-in-one</artifactId> 
     <version>1.1-SNAPSHOT</version> 
    </parent> 

    <properties> 
     <!-- During development we set log root level to Debug, 
      this will be applicable to the log configuration in 
      repo/src/main/resources/alfresco/extension/dev-log4j.properties, 
      such as DemoComponent logging. --> 
     <app.log.root.level>DEBUG</app.log.root.level> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>${alfresco.groupId}</groupId> 
      <artifactId>${alfresco.repo.artifactId}</artifactId> 
      <version>${alfresco.version}</version> 
      <type>war</type> 
     </dependency> 

     <!-- Demonstrating the dependency/installation of the repo AMP developed in the 'repo-amp' module --> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-common</artifactId> 
      <version>${abc.repo.common.parent.version}</version> 
      <type>amp</type> 
     </dependency> 
     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-common-classes</artifactId> 
      <version>${abc.repo.common.parent.version}</version> 
      <type>jar</type> 
     </dependency> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-bpmf</artifactId> 
      <version>${project.version}</version> 
      <type>amp</type> 
     </dependency> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-batp</artifactId> 
      <version>${project.version}</version> 
      <type>amp</type> 
     </dependency> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-ctp</artifactId> 
      <version>${project.version}</version> 
      <type>amp</type> 
     </dependency> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-life</artifactId> 
      <version>${project.version}</version> 
      <type>amp</type> 
     </dependency> 

     <dependency> 
      <groupId>au.com.abc.alfresco</groupId> 
      <artifactId>abc-repo-mpc</artifactId> 
      <version>${project.version}</version> 
      <type>amp</type> 
     </dependency> 

     <dependency> 
      <groupId>org.alfresco.aos-module</groupId> 
      <artifactId>alfresco-aos-module</artifactId> 
      <version>1.1-65</version> 
      <type>amp</type> 
     </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. This is normally empty, since customizations come from the AMPs --> 
         <overlay /> 
         <!-- The Alfresco WAR --> 
         <overlay> 
          <groupId>${alfresco.groupId}</groupId> 
          <artifactId>${alfresco.repo.artifactId}</artifactId> 
          <type>war</type> 
          <!-- To allow inclusion of META-INF --> 
          <excludes /> 
         </overlay> 

         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-bpmf</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-common</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-batp</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-ctp</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-life</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>${project.groupId}</groupId> 
          <artifactId>abc-repo-mpc</artifactId> 
          <type>amp</type> 
         </overlay> 
         <overlay> 
          <groupId>org.alfresco.aos-module</groupId> 
          <artifactId>alfresco-aos-module</artifactId> 
          <type>amp</type> 
         </overlay> 

        </overlays> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <profiles> 
     <!-- Overrides the run profile to disable securecomms and add rapid development configuration --> 
     <profile> 
      <id>run</id> 
      <build> 
       <plugins> 
        <plugin> 
         <artifactId>maven-war-plugin</artifactId> 
         <executions> 
          <execution> 
           <id>prepare-exploded-war</id> 
           <goals> 
            <goal>exploded</goal> 
           </goals> 
           <phase>prepare-package</phase> 
          </execution> 
          <execution> 
           <id>default-war</id> 
           <!--<configuration> 
            <webXml>${project.build.directory}/${project.build.finalName}-nossl/WEB-INF/web.xml</webXml> 
           </configuration> --> 
          </execution> 
         </executions> 
        </plugin> 
        <!-- Replaces web.xml where applicable, commenting out the security-constraints --> 
        <plugin> 
         <groupId>com.google.code.maven-replacer-plugin</groupId> 
         <artifactId>replacer</artifactId> 
         <executions> 
          <execution> 
           <id>disable-securecomms</id> 
           <phase>prepare-package</phase> 
           <goals> 
            <goal>replace</goal> 
           </goals> 
          </execution> 
         </executions> 
         <configuration> 
          <ignoreErrors>true</ignoreErrors> 
          <file>${project.build.directory}/${project.build.finalName}/WEB-INF/web.xml</file> 
          <outputDir>${project.build.directory}/${project.build.finalName}-nossl/WEB-INF/</outputDir> 
          <preserveDir>false</preserveDir> 
          <replacements> 
           <replacement> 
            <token> 
             <![CDATA[<!-- Toggle securecomms placeholder start -->]]> 
            </token> 
            <value> 
             <![CDATA[<!--]]> 
</value> 
           </replacement> 
           <replacement> 
            <token> 
<![CDATA[<!-- Toggle securecomms placeholder end -->]]> 
            </token> 
            <value> 
             <![CDATA[-->]]> 
            </value> 
           </replacement> 
          </replacements> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
      <dependencies> 
       <dependency> 
        <groupId>org.alfresco.maven</groupId> 
        <artifactId>alfresco-rad</artifactId> 
        <version>${maven.alfresco.version}</version> 
       </dependency> 
      </dependencies> 
     </profile> 
    </profiles> 
</project> 

我一直在使用<excludes><dependantWarExlcudes>尝试,但对我不起作用。

任何人都可以给我一些代码示例或提供一些指针?

+0

你确实拼写了'Excludes',对吧?这只是一个错字吗? –

回答

2

你这里来覆盖WAR排除罐一个例子:

<plugins> 
      <!-- put aside some unwanted jars from war...--> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <version>2.1.1</version> 
       <configuration> 
        <overlays> 
         <overlay> 
          <groupId>com.company.app</groupId> 
          <artifactId>web_app</artifactId> 
          <excludes> 
           <exclude>WEB-INF/lib/json-lib-2.2.2-jdk13.jar</exclude>         
          </excludes> 
         </overlay> 
        </overlays> 
       </configuration> 
      </plugin> 

让我知道,如果它的工作原理。根据你的情况代码来调整它。

+0

不,它不适用于我 – user327126

+0

如何为您调整此代码?能给我看看么? – PRVS