`

Example: 使用maven plugin定制build

阅读更多

<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>
    <artifactId>RMDirectProject</artifactId>
    <groupId>RMDirect</groupId>
    <version>SNAPSHOT</version>
  </parent>
 
    <name>bbConfigsCommon</name>
    <groupId>bbConfigs</groupId>
    <artifactId>bbConfigsCommon</artifactId>
  <version>SNAPSHOT</version>
  
  <!-- TODO -->
  <!-- put build section to a parent project so that no duplicate script across multiple config projects -->
  <build>
   <resources>
     <resource>
       <directory>src/objectservice</directory>
     </resource>
   </resources>
   <plugins>
      <!-- copy resources in libConfig folder to META-INF/config -->
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <executions>
            <execution>
              <id>copy-resources</id>
              <phase>validate</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${basedir}/target/classes/META-INF/config</outputDirectory>
                <resources>         
                  <resource>
                    <directory>src/libConfig</directory>
                    <filtering>true</filtering>
                  </resource>
                </resources>             
              </configuration>           
            </execution>
          </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
              <id>create-transform-folder</id>
              <phase>process-sources</phase>
              <goals><goal>run</goal></goals>
              <configuration>
                  <tasks>
                     <mkdir dir="${basedir}/target/transformProducts"/>
                  </tasks>
              </configuration>
            </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
            <!--transfer xml files-->
            <execution>
               <id>transfer-config</id>
               <phase>process-sources</phase>
              <goals>
                <goal>java</goal>
              </goals>
               <configuration>
                  <includeProjectDependencies>false</includeProjectDependencies>
                  <includePluginDependencies>true</includePluginDependencies>
                  <executableDependency>
                    <groupId>AppDev</groupId>
                    <artifactId>configs-helper</artifactId>
                  </executableDependency>
                  <mainClass>com.riskmetrics.appdev.configs.tools.misc.TransformProductConfigs</mainClass>
                  <arguments>
                    <argument>${basedir}/src/configs/product</argument>
                    <argument>${basedir}/target/transformProducts</argument>
                  </arguments>
                </configuration>
             </execution>
            
             <!--build zip files -->
             <execution>
               <id>build-zip-files</id>
               <phase>prepare-package</phase>
              <goals>
                <goal>java</goal>
              </goals>
              <configuration>
                  <includeProjectDependencies>false</includeProjectDependencies>
                  <includePluginDependencies>true</includePluginDependencies>
                  <executableDependency>
                    <groupId>AppDev</groupId>
                    <artifactId>configs-helper</artifactId>
                  </executableDependency>
                  <mainClass>com.riskmetrics.appdev.configs.tools.misc.BuildZipFiles</mainClass>
                  <arguments>
                    <argument>${basedir}/target/classes</argument>
                  </arguments>
              </configuration>
            </execution>
           
           
             <!--generate meta data -->
             <execution>
               <id>generate-metadata</id>
               <phase>prepare-package</phase>
              <goals>
                <goal>java</goal>
              </goals>
              <configuration>
                  <includeProjectDependencies>false</includeProjectDependencies>
                  <includePluginDependencies>true</includePluginDependencies>
                  <executableDependency>
                    <groupId>AppDev</groupId>
                    <artifactId>configs-helper</artifactId>
                  </executableDependency>
                  <mainClass>com.riskmetrics.appdev.configs.tools.misc.WriteMimeTypeMetadata</mainClass>
                  <arguments>
                    <argument>${basedir}/target/classes/Configs</argument>
                    <argument>.*\.xml$|||text/xml|||Text File</argument>
                    <argument>.*\.xsl$|||text/xml|||Text File</argument>
                    <argument>.*\.rml$|||text/xml|||Text File</argument>
                    <argument>.*\.zip$|||application/octet-stream|||Binary Data</argument>
                    <argument>.*\.gif$|||image/gif|||GIF image</argument>
                    <argument>.*\.css$|||text/css|||CSS Text File</argument>
                    <argument>.*\.rcp$|||text/x-rmg-pns-recipe+rcp|||Recipe</argument>
                    <argument>.*\.search-folder$|||x-rmd-application/search-folder|||Search Folder</argument>
                    <argument>.*implicitFilter_.*|||x-rmd-filtergroup/filter-group|||Filter Group</argument>
                  </arguments>
              </configuration>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>AppDev</groupId>
              <artifactId>configs-helper</artifactId>
              <version>1.0-SNAPSHOT</version>
              <type>jar</type>
            </dependency>
        </dependencies>
       </plugin>
      
       <!-- copy config XML files to META-INF/config and replace $VERSION to the current pom version-->
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
              <id>copy-product-xml</id>
              <phase>process-sources</phase>
              <goals><goal>run</goal></goals>
              <configuration>
                  <tasks>
                     <copy todir="${basedir}/target/classes/META-INF/config">
                        <fileset dir="${basedir}/target/transformProducts">
                          <include name="**/*.xml"/>
                        </fileset>
                        <filterset>
                            <!-- replace CONFIG_VERSION to current version-->
                            <filter token="CONFIG_VERSION" value="${pom.name}-${project.version}"/>
                            <filter token="APP_VERSION" value=""/>
                        </filterset>
                      </copy>
                  </tasks>
              </configuration>
            </execution>
        </executions>
      </plugin>
   </plugins>
  </build>
   
  <properties>
    <buildGroup>bbConfigs</buildGroup>
    <buildName>common</buildName>
    <deployable>true</deployable>
   </properties>
</project>   

分享到:
评论

相关推荐

    maven plugin

    Maven插件的使用可以通过在pom.xml文件中配置插件的`&lt;build&gt;&lt;plugins&gt;`部分来实现,包括设置插件版本、执行目标、配置参数等。通过这种方式,开发者可以轻松地定制和扩展Maven的构建流程,以适应不同项目的需求。...

    jdk9-jlink-jmod-example:使用maven-jmod-plugin的示例maven-jlink-plugin

    标题"jdk9-jlink-jmod-example:使用maven-jmod-plugin的示例maven-jlink-plugin" 提到了一个基于Maven的项目,它展示了如何在Java 9及更高版本中利用`jmod`和`jlink`工具。`jmod`是Java开发工具包(JDK)的新特性,...

    Maven自定义plugin

    3. **配置构建**:使用Maven的生命周期来构建你的插件项目。这包括编译Java源代码、打包成JAR,并将其部署到本地或远程Maven仓库。 4. **编写插件元数据**:在你的项目中创建`META-INF/maven/plugin.xml`文件,这个...

    weblogic-maven-example:weblogic Maven示例(WLS 11g-10.3.6)

    通过这个示例项目,开发者可以学习如何配置Maven的`maven-war-plugin`或`maven-ejb-plugin`来打包应用,使用`maven-weblogic-plugin`或`maven-ear-plugin`进行部署,以及如何在WebLogic Server上执行生命周期操作...

    maven资料Maven Assembly Plugin

    下面是一个具体的配置示例,用于说明如何使用 Maven Assembly Plugin: ```xml &lt;build&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins &lt;artifactId&gt;maven-assembly-plugin &lt;version&gt;2.6 &lt;mainClass&gt;...

    terratest-maven-plugin-example:terratest-maven-plugin用法的示例存储库

    这个项目,"terratest-maven-plugin-example",提供了一个具体的例子,展示了如何在你的 Maven 项目中有效地使用该插件。Terraform 是一种流行的基础设施即代码(IAC)工具,它允许开发人员使用 HCL(HashiCorp ...

    Android代码-安卓应用更新

    uniauto-appupdate Add it to your build.gradle ...To enable installing into local maven repository and JitPack you need to add the android-maven plugin: Add classpath 'com.github.dcendents:android-maven

    在idea下使用maven的mybatis-generator-maven-plugin插件自动生成实体映射文件

    ### 使用Maven与MyBatis Generator插件自动生成实体映射文件详解 #### 一、概述 在实际项目开发过程中,频繁的手动编写实体类、Mapper接口及其对应的XML映射文件不仅耗时耗力,还容易出错。为了解决这一问题,...

    Windoiws的maven3.8.8

    在`pom.xml`的`build/plugins`部分定义插件,例如使用maven-jar-plugin生成JAR文件: ```xml &lt;build&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins &lt;artifactId&gt;maven-jar-plugin &lt;version&gt;3.2.0 &lt;!-- ...

    gatling-maven-plugin-demo:用于Maven的Gatling插件展示

    **Gatling-Maven-Plugin-Demo:Maven与Gatling的集成实践** 在现代软件开发中,性能测试是确保应用稳定性和可扩展性的重要环节。Gatling是一款高效、易用的开源负载测试工具,它允许开发者通过简单的脚本语言编写...

    echo-maven-plugin-0.2.zip

    在Maven项目中,我们可以将echo-maven-plugin集成到pom.xml文件中,通过配置执行目标来定制输出内容。例如,我们可以添加以下配置: ```xml &lt;build&gt; &lt;plugin&gt; &lt;groupId&gt;org.example &lt;artifactId&gt;echo-maven-...

    gradle-maven-plugin:Gradle 5.x Maven发布插件来部署工件

    1. **添加依赖**:首先,在你的Gradle项目的`build.gradle`文件中添加对`gradle-maven-plugin`的依赖。这通常在`buildscript`块的`dependencies`部分完成,如下所示: ```groovy buildscript { repositories { ...

    frontend.maven.plugin.console.support:前端Maven插件控制台支持

    &lt;groupId&gt;com.example.frontend-maven-plugin&lt;/groupId&gt; &lt;artifactId&gt;console-support &lt;version&gt;1.0.0 &lt;goal&gt;enhance-console &lt;/plugin&gt; &lt;/build&gt; ``` 请注意,你需要将`groupId`、`artifactId`...

    maven 自定义插件小示例

    package com.example.mavenplugin; import org.apache.maven.plugin.*; import org.apache.maven.project.MavenProject; import java.io.File; @Mojo(name = "printMessage", defaultPhase = ...

    local_maven_deploy:本地maven仓库建造,配置Gradle,上传自己的库到仓库内

    在Android开发中,我们经常需要将自定义的库或者组件发布到Maven仓库,以便于在其他项目中方便地依赖和使用。`local_maven_deploy`是一个针对此需求的解决方案,它指导我们如何构建本地Maven仓库,并配置Gradle来...

    dependencypath-maven-plugin-1.1.1.zip

    在项目中使用这些属性,可以通过Maven的表达式语法`${dependency.com.example.mylibrary.1.0.0}`获取到具体的路径。这样,我们就可以在测试或者构建脚本中灵活地引用这些依赖,提高代码的可维护性和可扩展性。 总的...

    Android代码-maven-git-commit-id-plugin

    git-commit-id-plugin is a plugin quite similar to https://fisheye.codehaus.org/browse/mojo/tags/buildnumber-maven-plugin-1.0-beta-4 for example but as buildnumber at the time when I started this ...

    Maven 入门指南.docx

    - Maven 提供了大量的插件来扩展其功能,例如:maven-compiler-plugin 用于编译源代码,maven-jar-plugin 用于打包 JAR 文件。 - 插件可以在 POM 文件中配置,并指定不同的构建阶段。 2. **资源文件处理**: - ...

    Android studio 配置gradle 2.2.3 插件所需pom、jar文件

    classpath 'com.android.tools.build:gradle:2.2.3' } } ``` 3. **同步Gradle**:完成上述配置后,点击Android Studio中的"File" -&gt; "Sync Project with Gradle Files",让Android Studio下载并应用新的Gradle...

    maven项目编译jar包

    本文将深入探讨如何使用Maven来编译并创建一个JAR(Java Archive)包,主要涉及以下几个方面: 1. **Maven简介**: Maven是Apache软件基金会开发的一个项目管理工具,它通过一个统一的方式来管理项目的构建、报告...

Global site tag (gtag.js) - Google Analytics