aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jacoco-maven-plugin.test/it/it-prepend-property-skip/pom.xml46
-rw-r--r--jacoco-maven-plugin.test/it/it-prepend-property-skip/src/test/java/ExampleTest.java23
-rw-r--r--jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java7
-rw-r--r--org.jacoco.doc/docroot/doc/changes.html2
4 files changed, 76 insertions, 2 deletions
diff --git a/jacoco-maven-plugin.test/it/it-prepend-property-skip/pom.xml b/jacoco-maven-plugin.test/it/it-prepend-property-skip/pom.xml
new file mode 100644
index 00000000..027abbe1
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-prepend-property-skip/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Evgeny Mandrikov - initial API and implementation
+-->
+<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>
+
+ <parent>
+ <groupId>jacoco</groupId>
+ <artifactId>setup-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>it-prepend-property-skip</artifactId>
+
+ <properties>
+ <argLine>-Dfoo</argLine>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/jacoco-maven-plugin.test/it/it-prepend-property-skip/src/test/java/ExampleTest.java b/jacoco-maven-plugin.test/it/it-prepend-property-skip/src/test/java/ExampleTest.java
new file mode 100644
index 00000000..1c906fcb
--- /dev/null
+++ b/jacoco-maven-plugin.test/it/it-prepend-property-skip/src/test/java/ExampleTest.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Evgeny Mandrikov - initial API and implementation
+ *
+ *******************************************************************************/
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+
+public class ExampleTest {
+
+ @Test
+ public void test() {
+ assertNotNull(System.getProperty("foo"));
+ }
+
+}
diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java
index e0e29648..67f5521b 100644
--- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java
+++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractAgentMojo.java
@@ -149,8 +149,11 @@ public abstract class AbstractAgentMojo extends AbstractJacocoMojo {
protected void skipMojo() {
final String name = getEffectivePropertyName();
final Properties projectProperties = getProject().getProperties();
- getLog().info(name + " set to empty");
- projectProperties.setProperty(name, "");
+ final String oldValue = projectProperties.getProperty(name);
+ if (oldValue == null) {
+ getLog().info(name + " set to empty");
+ projectProperties.setProperty(name, "");
+ }
}
File getAgentJarFile() {
diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html
index 628dacbe..2f7f0c9c 100644
--- a/org.jacoco.doc/docroot/doc/changes.html
+++ b/org.jacoco.doc/docroot/doc/changes.html
@@ -30,6 +30,8 @@
(GitHub <a href="https://github.com/jacoco/jacoco/issues/177">#177</a>).</li>
<li><code>ExecutionDataWriter.FORMAT_VERSION</code> is not a compile-time constant
(GitHub <a href="https://github.com/jacoco/jacoco/issues/474">#474</a>).</li>
+ <li>Maven goal "prepare-agent" should not overwrite existing property value if execution was skipped
+ (GitHub <a href="https://github.com/jacoco/jacoco/issues/486">#486</a>).</li>
</ul>
<h3>API Changes</h3>