1 /******************************************************************************* 2 * Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Evgeny Mandrikov - initial API and implementation 10 * 11 *******************************************************************************/ 12 package org.jacoco.maven; 13 14 import java.io.File; 15 16 /** 17 * <p> 18 * Prepares a property pointing to the JaCoCo runtime agent that can be passed 19 * as a VM argument to the application under test. Depending on the project 20 * packaging type by default a property with the following name is set: 21 * </p> 22 * 23 * <ul> 24 * <li>tycho.testArgLine for packaging type eclipse-test-plugin and</li> 25 * <li>argLine otherwise.</li> 26 * </ul> 27 * 28 * <p> 29 * If your project already uses the argLine to configure the 30 * surefire-maven-plugin, be sure that argLine defined as a property, rather 31 * than as part of the plugin configuration. For example: 32 * </p> 33 * 34 * <pre> 35 * <properties> 36 * <argLine>-your -extra -arguments</argLine> 37 * </properties> 38 * ... 39 * <plugin> 40 * <groupId>org.apache.maven.plugins</groupId> 41 * <artifactId>maven-surefire-plugin</artifactId> 42 * <configuration> 43 * <!-- Do not define argLine here! --> 44 * </configuration> 45 * </plugin> 46 * </pre> 47 * 48 * 49 * <p> 50 * Resulting coverage information is collected during execution and by default 51 * written to a file when the process terminates. 52 * </p> 53 * 54 * @phase initialize 55 * @goal prepare-agent 56 * @requiresProject true 57 * @requiresDependencyResolution runtime 58 * @threadSafe 59 * @since 0.5.3 60 */ 61 public class AgentMojo extends AbstractAgentMojo { 62 63 /** 64 * Path to the output file for execution data. 65 * 66 * @parameter property="jacoco.destFile" 67 * default-value="${project.build.directory}/jacoco.exec" 68 */ 69 private File destFile; 70 71 /** 72 * @return the destFile 73 */ 74 @Override 75 File getDestFile() { 76 return destFile; 77 } 78 79 } 80