• Maven学习--------基础2



    继续学习Maven。

    4.2 变量

    1) 问:怎样使用变量替换?项目中的某个配置文件比方jdbc.properties使用了一些pom中的变量,怎样在公布中使用包括真实内容的终于结果文件?

    答:使用资源过滤功能,比方:

    <project>
        ... 
        <properties>
            <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
            <jdbc.url>jdbc:mysql://localhost:3306/development_db</jdbc.url>
            <jdbc.username>dev_user</jdbc.username>
            <jdbc.password>s3cr3tw0rd</jdbc.password>
        </properties>
        ... 
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                </resource>
            </resources>
        </build>
        ... 
        <profiles>
            <profile>
                <id>production</id>
                <properties>
                    <jdbc.driverClassName>oracle.jdbc.driver.OracleDriver</jdbc.driverClassName>
                    <jdbc.url>jdbc:oracle:thin:@proddb01:1521:PROD</jdbc.url>
                    <jdbc.username>prod_user</jdbc.username>
                    <jdbc.password>s00p3rs3cr3t</jdbc.password>
                </properties>
            </profile>
        </profiles>
    </project>

    2) 问: maven-svn-revision-number-plugin 插件说明

    答: maven-svn-revision-number-plugin 能够从 SVN 中获取版本,并将其变成环境变量,交由其它插件或者profile使用,具体帮助在这里 。一般和resource的filter机制同一时候使用

    <plugins>
        <plugin>
            <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
            <artifactId>maven-svn-revision-number-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>revision</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <entries>
                    <entry>
                        <prefix>prefix</prefix>
                    </entry>
                </entries>
            </configuration>
        </plugin>
    </plugins>

    这段代码负责把resource文件里的内容替换成适当内容

    repository = ${prefix.repository}
    path = ${prefix.path}
    revision = ${prefix.revision}
    mixedRevisions = ${prefix.mixedRevisions}
    committedRevision = ${prefix.committedRevision}
    status = ${prefix.status}
    specialStatus = ${prefix.specialStatus}

    3)我的程序有些单元測试有错误。怎样忽略測试步骤?

    有好几种方法都能够实现跳过单元測试步骤。一种是给mvn添加命令行參数 -Dmaven.test.skip=true 或者 -DskipTests=true 。第二种是给surefire插件添加參数。例如以下:

    <span class="kwrd"><</span><span class="html">project</span><span class="kwrd">></span>
      [...]
      <span class="kwrd"><</span><span class="html">build</span><span class="kwrd">></span>
        <span class="kwrd"><</span><span class="html">plugins</span><span class="kwrd">></span>
          <span class="kwrd"><</span><span class="html">plugin</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">groupId</span><span class="kwrd">></span>org.apache.maven.plugins<span class="kwrd"></</span><span class="html">groupId</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">artifactId</span><span class="kwrd">></span>maven-surefire-plugin<span class="kwrd"></</span><span class="html">artifactId</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">version</span><span class="kwrd">></span>2.8<span class="kwrd"></</span><span class="html">version</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">configuration</span><span class="kwrd">></span>
              <span class="kwrd"><</span><span class="html">skipTests</span><span class="kwrd">></span>true<span class="kwrd"></</span><span class="html">skipTests</span><span class="kwrd">></span>
            <span class="kwrd"></</span><span class="html">configuration</span><span class="kwrd">></span>
          <span class="kwrd"></</span><span class="html">plugin</span><span class="kwrd">></span>
        <span class="kwrd"></</span><span class="html">plugins</span><span class="kwrd">></span>
      <span class="kwrd"></</span><span class="html">build</span><span class="kwrd">></span>
      [...]
    <span class="kwrd"></</span><span class="html">project</span><span class="kwrd">></span>
    4) 假设仅仅想执行单个測试用例,是否能实现?

    能够,执行时候添加命令行參数 -Dtest=MyTest 就可以,当中MyTest是所须要执行的单元測试用例名称,可是不须要包括package部分。

    4.3 编译

    1) 问:怎样给插件指派參数?比方我要设置一些编译參数

    答:下面内容设定编译器编译java1.5的代码

    <project>
        ... 
        <build>
            ... 
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
            </plugins>
            ... 
        </build>
        ... 
    </project>

    要设置其它插件的參数也能够,请參考相应插件的帮助信息
    2) 问:我的文件夹是非标准的文件夹结构。怎样设置让maven支持?

    答:指定source文件夹和test-source文件夹就可以。

    <build>
        <directory>target</directory>
        <sourceDirectory>src</sourceDirectory>
        <scriptSourceDirectory>js/scripts</scriptSourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <outputDirectory>bin</outputDirectory>
        <testOutputDirectory>bin</testOutputDirectory>
    </build>

    这个样例把源码设置成了src文件夹,測试代码在test文件夹,所以输出到bin文件夹。

    这里要注意,directory假设也设置成bin文件夹的话,maven打包的时候会引起死循环,由于directory是全部工作存放的地方。默认包括outputDirectory定义的文件夹在内。

    3) 我源码是UTF8格式的,我怎样在maven中指定?

    设置一个变量就可以

    <project>
        ... 
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
        ... 
    </project>
    {color:blue}以上是官方给出的解决方式。可是经过尝试这样仅仅能影响到resource处理时候的编码{color},真正实用的是例如以下配置:
    {code:xml}
    <build>
      ...
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>
      ...
    </build>
    {code}
    . 问:我的项目除了main/java文件夹之外。还加了其它的c++文件夹,想要一并编译,怎样做?
    答:使用native插件,详细配置方法參考[http://mojo.codehaus.org/maven-native/native-maven-plugin/]
    {code:xml}
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>native-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
    </plugin>    
    {code}
    . 问:我想要把project的全部依赖的jar都一起打包,怎么办?
    答:首先改动maven的配置文件,给maven-assembly-plugin添加一个jar-with-dependencies的描写叙述。

    {code:xml}
    <project>
      [...]
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
            </configuration>
          </plugin>
        </plugins>
      </build>
      [...]
    </project>
    {code}
    然后使用命令打包就可以:
    mvn assembly:assembly
    . 问:我想把main/scripts中的内容一起打包公布,怎样做?
    答:在pom中配置额外的资源文件夹。假设须要的话。还能够指定资源文件夹的输出位置
    {code:xml}
    <build>
      ...
      <resources>
        <resource>
          <filtering>true</filtering>
          <directory>src/main/command</directory>
          <includes>
            <include>run.bat</include>
            <include>run.sh</include>
          </includes>
          <targetPath>/abc</targetPath>
        </resource>
        <resource>
          <directory>src/main/scripts</directory>
        </resource>
      </resources>
      ...
    </build>
    {code}
    . 问:我有多个源码文件夹,可是maven仅仅支持一个main src和一个test src,怎么办?
    答:使用另外一个插件,并仿照例如以下配置pom
    {code:xml}
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
              <execution>
                <id>add-source</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>src/config/java</source>
                    <source>src/main/java</source>
                    <source>src/member/java</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
    {code}
    . 问:我的源码文件夹中有一部分文件我不想让maven编译,怎么做?
    答:使用一个maven插件,然后使用includes和excludes。

    同理。也能够处理资源的过滤。

    {code:xml}
    <build>
      <sourceDirectory>http://www.cnblogs.com/src/java</sourceDirectory>
      <plugins>
        <plugin>
          <groupId>com.sun.enterprise</groupId>
          <artifactId>hk2-maven-plugin</artifactId>
          <configuration>
            <includes>
              <include>com/sun/logging/LogDomains.*</include>
              <include>com/sun/enterprise/util/OS.java</include>
              <include>com/sun/enterprise/util/io/FileUtils.java</include>
              <include>com/sun/enterprise/util/zip/**</include>
              <include>com/sun/enterprise/util/i18n/**</include>
              <include>com/sun/enterprise/deployment/backend/IASDeploymentException.java</include>
            </includes>
            <excludes>
              <exclude>com/sun/enterprise/config/ConfigBeansFactory.java</exclude>
              <exclude>com/sun/enterprise/config/clientbeans/**</exclude>
            </excludes>
          </configuration>
        </plugin>
      </plugins>
      <resources>
        <resource>
          <directory>http://www.cnblogs.com/src/java</directory>
          <includes>
            <include>**/*.properties</include>
          </includes>
        </resource>
      </resources>
    </build>
    {code}
    . 问:我的项目是一个纯的html组成的项目,没有不论什么的java代码,怎么跳过编译过程?
    答:配置例如以下
    {code:xml}
    <build>
      <sourceDirectory>src/java</sourceDirectory>
      <plugins>
        <plugin>
        <groupId>com.sun.enterprise</groupId>
        <artifactId>hk2-maven-plugin</artifactId>
        </plugin>
      </plugins>
    </build>
    {code}
    . 问:我的project里用hibernate,想在编译时候自己主动生成ddl,怎样做?
    答:加入插件
    hibernate3-maven-plugin
    。依照例如以下配置:
    {code:xml}
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>hibernate3-maven-plugin</artifactId>
              <version>2.1</version>
              <configuration>
                <components>
                  <component>
                    <name>hbm2ddl</name>
                    <implementation>annotationconfiguration</implementation>
                  </component>
                </components>
              </configuration>
              <dependencies>
                <dependency>
                  <groupId>hsqldb</groupId>
                  <artifactId>hsqldb</artifactId>
                  <version>${hsqldb.version}</version>
                </dependency>
              </dependencies>
            </plugin>
    {code}
    . 问:我能用maven支持eclipse RCP项目吗?

    答:当然能够,你能够使用插件 Tycho,具体内容能够參考这里[http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/].

     <plugin>
      <groupid>org.sonatype.tycho</groupid>
      <artifactid>target-platform-configuration</artifactid>
      <version>0.7.0</version>
      <configuration>
        <resolver>p2</resolver>
      </configuration>
    </plugin>
    另外。老牌的pde-maven-plugin就不要用了,已经好几年没见更新了。

    4.4 ant互动

    1) 怎样在maven编译时候执行ant脚本?

    使用专门的antrun插件,而且在target标签内部增加ant的代码

          <span class="kwrd"><</span><span class="html">plugin</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">artifactId</span><span class="kwrd">></span>maven-antrun-plugin<span class="kwrd"></</span><span class="html">artifactId</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">version</span><span class="kwrd">></span>1.6<span class="kwrd"></</span><span class="html">version</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">executions</span><span class="kwrd">></span>
              <span class="kwrd"><</span><span class="html">execution</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">phase</span><span class="kwrd">></span> <span class="rem"><!-- 生命周期阶段 --></span> <span class="kwrd"></</span><span class="html">phase</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">configuration</span><span class="kwrd">></span>
                  <span class="kwrd"><</span><span class="html">target</span><span class="kwrd">></span>
                    <span class="rem"><!-- 增加target内部的代码 --></span>
                  <span class="kwrd"></</span><span class="html">target</span><span class="kwrd">></span>
                <span class="kwrd"></</span><span class="html">configuration</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">goals</span><span class="kwrd">></span>
                  <span class="kwrd"><</span><span class="html">goal</span><span class="kwrd">></span>run<span class="kwrd"></</span><span class="html">goal</span><span class="kwrd">></span>
                <span class="kwrd"></</span><span class="html">goals</span><span class="kwrd">></span>
              <span class="kwrd"></</span><span class="html">execution</span><span class="kwrd">></span>
            <span class="kwrd"></</span><span class="html">executions</span><span class="kwrd">></span>
          <span class="kwrd"></</span><span class="html">plugin</span><span class="kwrd">></span>

    2)怎样在ant脚本中引用maven的classpath?

    maven给每个依赖都生成了一个属性,格式为"groupId:artifactId[:classifier]:type",比方,假设一下样例就显示依赖的org.apache.common-util的jar文件路径

    <span class="kwrd"><</span><span class="html">echo</span> <span class="attr">message</span><span class="kwrd">="Dependency JAR Path: ${org.apache:common-util:jar}"</span><span class="kwrd">/></span> 

    另外,maven还提前定义了四个classpath的引用。他们是

    • maven.compile.classpath
    • maven.runtime.classpath
    • maven.test.classpath
    • maven.plugin.classpath

    3)怎样使用antrun插件执行外部的build文件?

    非常easy,直接在antrun里边使用ant指令就可以。例如以下:

    <span class="kwrd"><</span><span class="html">plugin</span><span class="kwrd">></span>
        <span class="kwrd"><</span><span class="html">groupId</span><span class="kwrd">></span>org.apache.maven.plugins<span class="kwrd"></</span><span class="html">groupId</span><span class="kwrd">></span>
        <span class="kwrd"><</span><span class="html">artifactId</span><span class="kwrd">></span>maven-antrun-plugin<span class="kwrd"></</span><span class="html">artifactId</span><span class="kwrd">></span>
        <span class="kwrd"><</span><span class="html">version</span><span class="kwrd">></span>1.6<span class="kwrd"></</span><span class="html">version</span><span class="kwrd">></span>
        <span class="kwrd"><</span><span class="html">executions</span><span class="kwrd">></span>
            <span class="kwrd"><</span><span class="html">execution</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">id</span><span class="kwrd">></span>compile<span class="kwrd"></</span><span class="html">id</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">phase</span><span class="kwrd">></span>compile<span class="kwrd"></</span><span class="html">phase</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">configuration</span><span class="kwrd">></span>
                    <span class="kwrd"><</span><span class="html">target</span><span class="kwrd">></span>
                        <span class="rem"><!-- 同一时候传递内置的classpath给外部ant文件 --></span>
                        <span class="kwrd"><</span><span class="html">property</span> <span class="attr">name</span><span class="kwrd">="compile_classpath"</span> <span class="attr">refid</span><span class="kwrd">="maven.compile.classpath"</span><span class="kwrd">/></span>
                        <span class="kwrd"><</span><span class="html">property</span> <span class="attr">name</span><span class="kwrd">="runtime_classpath"</span> <span class="attr">refid</span><span class="kwrd">="maven.runtime.classpath"</span><span class="kwrd">/></span>
                        <span class="kwrd"><</span><span class="html">property</span> <span class="attr">name</span><span class="kwrd">="test_classpath"</span> <span class="attr">refid</span><span class="kwrd">="maven.test.classpath"</span><span class="kwrd">/></span>
                        <span class="kwrd"><</span><span class="html">property</span> <span class="attr">name</span><span class="kwrd">="plugin_classpath"</span> <span class="attr">refid</span><span class="kwrd">="maven.plugin.classpath"</span><span class="kwrd">/></span>
        
                        <span class="kwrd"><</span><span class="html">ant</span> <span class="attr">antfile</span><span class="kwrd">="${basedir}/build.xml"</span><span class="kwrd">></span>
                            <span class="kwrd"><</span><span class="html">target</span> <span class="attr">name</span><span class="kwrd">="test"</span><span class="kwrd">/></span>
                        <span class="kwrd"></</span><span class="html">ant</span><span class="kwrd">></span>
                    <span class="kwrd"></</span><span class="html">target</span><span class="kwrd">></span>
                <span class="kwrd"></</span><span class="html">configuration</span><span class="kwrd">></span>
                <span class="kwrd"><</span><span class="html">goals</span><span class="kwrd">></span>
                    <span class="kwrd"><</span><span class="html">goal</span><span class="kwrd">></span>run<span class="kwrd"></</span><span class="html">goal</span><span class="kwrd">></span>
                <span class="kwrd"></</span><span class="html">goals</span><span class="kwrd">></span>
            <span class="kwrd"></</span><span class="html">execution</span><span class="kwrd">></span>
        <span class="kwrd"></</span><span class="html">executions</span><span class="kwrd">></span>
    <span class="kwrd"></</span><span class="html">plugin</span><span class="kwrd">></span>
    . 问:怎样在ant中使用maven的功能?
    答:使用ant的[maven task|http://maven.apache.org/ant-tasks/index.html]。只是仅仅有ant 1.6以上和jdk 1.5环境才支持。

    h4. 測试相关

    . 问:怎样忽略某个阶段的结果?比方单元測试不一定要全正确
    答:给插件添加testFailureIgnore參数。并设置为false。

    假设要屏蔽该阶段,则用

    <skip>true</skip>
    {code:xml}
    <project>
      [...]
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <testFailureIgnore>true</testFailureIgnore>
            </configuration>
          </plugin>
        </plugins>
      </build>
      [...]
    </project>
    {code}
    . 问:我怎样在maven中增加PMD,CheckStyle,JDepend等检查功能?
    答:增加PMD检查。下面代码假设在
    reporting
    节点中增加则在
    mvn site
    中运行。假设在
    build
    节点中增加。则在build的时候自己主动执行检查。具体配置參考[pmd插件使用说明|http://maven.apache.org/plugins/maven-pmd-plugin/]
    {code:xml}
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>2.5</version>
          </plugin>
        </plugins>
    {code}
    增加 checkstyle 检查。具体配置參考[checkstyle插件使用说明|http://maven.apache.org/plugins/maven-checkstyle-plugin/],相同注意放置在reporting和build节点中的差别(全部报表类插件都要相同注意):
    {code:xml}
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>2.5</version>
          </plugin>
    {code}
    增加 simian 的支持。simian是一个支持代码相似度检查的工具,眼下有maven插件,也有checkstyle的插件。

    它不仅能够检查java,甚至能够支持文本文件的检查。

    具体帮助信息參考[这里|http://www.redhillconsulting.com.au/products/simian/]。simian 的 maven插件在[这里|http://mojo.codehaus.org/simian-report-maven-plugin/introduction.html]

    {code:xml}
          <build>
             <plugins>
                <plugin>
                   <groupId>org.codehaus.mojo</groupId>
                   <artifactId>simian-maven-plugin</artifactId>
                   <version>1.6.1</version>
                </plugin>
             </plugins>
             ...
          </build>
    {code}
    增加 jdepend 检查,具体配置參考[jdepend使用说明|http://mojo.codehaus.org/jdepend-maven-plugin/],
    {code:xml}
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jdepend-maven-plugin</artifactId>
            <version>2.0-beta-2</version>
          </plugin>
    {code}
    增加 findbugz 检查,具体配置參考[findbugz使用说明|http://mojo.codehaus.org/findbugs-maven-plugin/usage.html],
    {code:xml}
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.0.1</version>
          </plugin>
    {code}
    增加javadoc生成,具体配置參考[javadoc usage|http://maven.apache.org/plugins/maven-javadoc-plugin/usage.html]
    {code:xml}
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
              ...
            </configuration>
          </plugin>
    {code}
    增加 jxr 支持。JXR是一个生成java代码交叉引用和源码的html格式的工具。具体配置信息參考[jxr usage|http://maven.apache.org/plugins/maven-jxr-plugin/]。

    注意,jxr没有必要在build阶段执行。

    {code:xml}
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>2.1</version>
          </plugin>
        </plugins>
      </reporting>
    {code}
    增加 Cobertura 支持,它是一个代码覆盖率工具,能够用来评估具有对应測试的源码的比率。具体帮助在[这里|http://mojo.codehaus.org/cobertura-maven-plugin/index.html]。另外一个功能相似的软件是[EMMA|http://emma.sourceforge.net/samples.html],具体的帮助在[这里|http://mojo.codehaus.org/emma-maven-plugin/usage.html]。两个产品的比較文章在[这里|http://www.topcoder.com/tc?

    module=Static&d1=features&d2=030107]。个人倾向于都要用,由于给出的指标不一样。都有參考作用。

    {code:xml|title=Cobertura }
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.4</version>
            <configuration>
              <check>
                <branchRate>85</branchRate>
                <lineRate>85</lineRate>
                <haltOnFailure>true</haltOnFailure>
                <totalBranchRate>85</totalBranchRate>
                <totalLineRate>85</totalLineRate>
                <packageLineRate>85</packageLineRate>
                <packageBranchRate>85</packageBranchRate>
                <regexes>
                  <regex>
                    <pattern>com.example.reallyimportant.*</pattern>
                    <branchRate>90</branchRate>
                    <lineRate>80</lineRate>
                  </regex>
                  <regex>
                    <pattern>com.example.boringcode.*</pattern>
                    <branchRate>40</branchRate>
                    <lineRate>30</lineRate>
                  </regex>
                </regexes>
              </check>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>clean</goal>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
    {code}
    {code:xml|title=EMMA}
      <reporting>
        ...
        <plugins>
          ...
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-3-SNAPSHOT</version>
          </plugin>
          ...
        </plugins>
        ...
      </reporting>
    {code}
    加入 javaNCSS 插件。它是一个java代码的度量工具,具体參考在[这里|http://mojo.codehaus.org/javancss-maven-plugin/]。
    {code:xml}
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>javancss-maven-plugin</artifactId>
            <version>2.0-beta-2</version>
          </plugin>
        </plugins>
      </reporting>
    {code}
    h4. profile相关
    . 问:profile可以设置为某个变量不存在的条件下激活?
    答:使用。前缀,请看演示样例:
    {code:xml}
    <activation>
            <property>
              <name>!environment.type</name>
            </property>
          </activation>
    {code}
    h4. 部署相关
    . 问:其它部署到server的方式和配置怎么配?
    答:本文摘自 [http://blog.csdn.net/zyxnetxz/archive/2009/05/18/4199348.aspx]{panel} *Distribution Management* 用于配置分发管理。配置对应的产品公布信息,主要用于公布,在运行mvn deploy后表示要公布的位置 *# 配置到文件系统
    {code:xml}
    <distributionManagement>
      <repository>
        <id>proficio-repository<id>
        <name>Proficio Repository<name>
        <url>file://${basedir}/target/deploy<url>
      <repository>
    <distributionManagement>
    {code}
    *# 使用ssh2配置
    {code:xml}
    <distributionManagement>
      <repository>
        <id>proficio-repository<id>
        <name>Proficio Repository<name>
        <url>scp://sshserver.yourcompany.com/deploy<url>
      <repository>
    <distributionManagement>
    {code}
    *# 使用sftp配置
    {code:xml}
    <distributionManagement>
      <repository>
        <id>proficio-repositoryi<d>
        <name>Proficio Repository<name>
        <url>sftp://ftpserver.yourcompany.com/deploy<url>
      <repository>
    <distributionManagement>
    {code}
    *# 使用外在的ssh配置编译扩展用于指定使用wagon外在ssh提供,用于提供你的文件到对应的远程server。
    {code:xml}
    <distributionManagement>
      <repository>
        <id>proficio-repository<id>
        <name>Proficio Repository<name>
        <url>scpexe://sshserver.yourcompany.com/deploy<url>
      <repository>
    <distributionManagement>
    <build>
      <extensions>
        <extension>
          <groupId>org.apache.maven.wagon<groupId>
          <artifactId>wagon-ssh-external<artifactId>
          <version>1.0-alpha-6<version>
        <extension>
      <extensions>
    <build>
    {code}
    *# 使用ftp配置
    {code:xml}
    <distributionManagement>
      <repository>
        <id>proficio-repository<id>
        <name>Proficio Repository<name>
        <url>ftp://ftpserver.yourcompany.com/deploy<url>
      <repository>
    <distributionManagement>
    <build>
      <extensions>
        <extension>
          <groupId>org.apache.maven.wagongroupId>
          <artifactId>wagon-ftpartifactId>
          <version>1.0-alpha-6version>
        <extension>
      <extensions>
    <build>
    {code}
    {panel} h4. 插件配置
    . 问:我用maven输出site,怎样设置输出为utf8编码?
    答: 配置site插件的编码设置
    {code:xml}
    ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.0-beta-6</version>
        <configuration>
          <outputEncoding>UTF-8</outputEncoding>
        </configuration>
      </plugin>
      ...
    {code}
    
    
    
    
    
    
    本文借鉴与http://aiape.iteye.com/blog/1455420
  • 相关阅读:
    BZOJ 1036:树的统计Count(树链剖分)
    HDU 5950:Recursive sequence(矩阵快速幂)
    POJ 2763:Housewife Wind(树链剖分)
    HDU 2222:Keywords Search(AC自动机模板)
    HDU 3966:Aragorn's Story(树链剖分)
    矩阵乘法
    HDU 4635:Strongly connected(强连通)
    HDU 3078:Network(LCA之tarjan)
    HDU 2767:Proving Equivalences(强连通)
    HDU 1827:Summer Holiday(强连通)
  • 原文地址:https://www.cnblogs.com/yjbjingcha/p/7246649.html
Copyright © 2020-2023  润新知