我正在使用带有jacoco插件的maven 来生成代码覆盖率指标.我有在配置一些困难神火由所需的Java插件的选项jacoco插件.我已经在Stack Overflow上看到了一些关于此问题的答案,但有些东西对我不起作用.
我有一个多模块项目,我的一个模块配置了surefire插件,如下所示:
foo/pom.xml:
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <argLine>-XX:MaxPermSize=512m</argLine>
    </configuration>
  </plugin>
</plugins>
这按预期工作.
现在我想结合jacoco获取代码覆盖率的指标,所以我加了一个代码覆盖率配置文件,处理所有jacoco配置:
parent/pom.xml:
<profile>
  <id>CodeCoverage</id>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>jacoco-initialize</id>
              <goals><goal>prepare-agent</goal></goals>
              <configuration>
                <propertyName>surefire.argLine</propertyName>
              </configuration>
              ...
            </execution>
          <executions> 
        </plugin>
      </plugins>
    </pluginManagement>
  </build>   
</profile>
它是在这里看到的是,如果代码覆盖率指定配置文件,然后jacoco插件配置为使用surefire.argLine属性,该属性用于配置argLine为万无一失插件.
然后我更新了foo模块的pom.xml文件,以使用jacoco插件生成的属性:surefire.argLine
foo/pom.xml:
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <argLine>${surefire.argLine} -XX:MaxPermSize=512m</argLine> …我正在尝试在我们的项目中实现语义版本控制。我测试了 Maven semver 插件,但这对我没有帮助,所以请不要问我为什么。我最终使用了 Maven Groovy。它的工作原理就像一个魅力,但是,当我安装或部署 Maven 项目时,存储库中的版本是变量名称。
尽管所有工件和 jar 文件都以正确的版本打包,但情况仍然如此。
所以请看看我的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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mytest.test</groupId>
    <artifactId>test-tag</artifactId>
    <version>${revision}</version> 
    <description>Test</description>
    <properties>
        <ChangeType>TO_BE_SET</ChangeType>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <providerSelection>2.0</providerSelection>
                            <properties>
                                <script>git describe --abbrev=0 --tags</script>
                            </properties>
                            <source>
                                def tagIt = 'git tag -a vXXXX -m "Auto tagged"'
                                def changeType = project.properties.ChangeType
                                def command = project.properties.script
                                def process = command.execute()
                                process.waitFor()
                                def describe = process.in.text.trim()
                                println "Setting revision to: …我有一个maven项目,需要在命令行设置属性(-Dmy.property = val).我需要做的是将该字符串转换为全部大写字母,因为该属性用于通过maven-resources-plugin在多个文件中替换字符串.最简单的方法是什么?