Home | History | Annotate | Download | only in maven
      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  *   &lt;properties&gt;
     36  *     &lt;argLine&gt;-your -extra -arguments&lt;/argLine&gt;
     37  *   &lt;/properties&gt;
     38  *   ...
     39  *   &lt;plugin&gt;
     40  *     &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
     41  *     &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
     42  *     &lt;configuration&gt;
     43  *       &lt;!-- Do not define argLine here! --&gt;
     44  *     &lt;/configuration&gt;
     45  *   &lt;/plugin&gt;
     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