【问题标题】:Including another xml file in pom.xml在 pom.xml 中包含另一个 xml 文件
【发布时间】:2015-01-20 21:54:43
【问题描述】:

我正在尝试在 pom.xml (maven) 中包含 xml 文件。 我的 pom.xml 看起来有点像这个

<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- <xi:include href="minify.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
 -->  <modelVersion>4.0.0</modelVersion>
  <groupId>myproject</groupId>
  <artifactId>myproject</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <description></description>
  <build>
    <plugins>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    <!-- include plugin tag from other xml file -->
// I would like maintain one seperate xml file to hold all plugin tags (to reduce pom.xml //file content.
</plugins>

我正在使用 "com.samaxes.maven"minify css and js files 。 但我将我的 css 和 js 文件保存在许多单独的文件夹中。我需要在下面重复包含这个标签

<plugin>
    <groupId>com.samaxes.maven</groupId>
    <artifactId>minify-maven-plugin</artifactId>
    <version>1.7.4</version>
    <executions>
        <execution>
            <id>default-minify-1</id>
            <configuration>
                   <charset>utf-8</charset>
                   <jsEngine>CLOSURE</jsEngine>
                   <skipMerge>true</skipMerge>
                   <nosuffix>true</nosuffix>
                  <!--   <skipMinify>true</skipMinify>   -->   <!--skips already minfied css fiels -->

                    <cssSourceDir>inc/one/css</cssSourceDir>
                   <cssTargetDir>inc/one/css/mini</cssTargetDir>
                   <cssSourceIncludes>
                      <cssSourceInclude>*.css</cssSourceInclude>
                   </cssSourceIncludes>

                    <jsSourceDir>proj/platform/common/js/</jsSourceDir>
                   <jsTargetDir>proj/platform/common/js/mini</jsTargetDir>
                   <jsSourceIncludes>
                     <jsSourceInclude>*.js</jsSourceInclude>
                   </jsSourceIncludes>
                   <closureCreateSourceMap>true</closureCreateSourceMap>
            </configuration>
            <goals>
                <goal>minify</goal>
            </goals>
        </execution>
    </executions>
 </plugin>

我搜索了包含多个目录的可能方法,然后我决定通过重复上面的 sn-p 代码来包含所有目录。但后来虽然将所有 mifiy 包含到其他 xml 文件中。我正在寻找某种方法来在 tag 中包含 xml 文件。 有人请帮帮我。

【问题讨论】:

    标签: xml maven


    【解决方案1】:

    我认为这不是 maven 应该使用的方式..

    您可以做的是在 pluginManagement 部分中创建一个包含所有全局插件配置的父 pom.xml。然后您可以在您的所有子 pom.xml 中使用 id“default-minify-1”激活您配置的执行。但是配置只在父 pom.xml 中完成一次

    Reusing ant-snippets in multi-module maven build

    【讨论】:

    • 谢谢@StefanHeimberg。现在我正在使用 YUI 压缩器,它解决了我的问题。
    猜你喜欢
    • 2014-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-06
    • 2011-07-17
    相关资源
    最近更新 更多