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 import java.io.IOException; 16 17 import org.apache.maven.plugin.MojoExecutionException; 18 import org.apache.maven.plugin.MojoFailureException; 19 import org.codehaus.plexus.util.FileUtils; 20 21 /** 22 * Restores original classes as they were before offline instrumentation. 23 * 24 * @phase prepare-package 25 * @goal restore-instrumented-classes 26 * @requiresProject true 27 * @threadSafe 28 * @since 0.6.2 29 */ 30 public class RestoreMojo extends AbstractJacocoMojo { 31 32 @Override 33 protected void executeMojo() throws MojoExecutionException, 34 MojoFailureException { 35 final File originalClassesDir = new File(getProject().getBuild() 36 .getDirectory(), "generated-classes/jacoco"); 37 final File classesDir = new File(getProject().getBuild() 38 .getOutputDirectory()); 39 try { 40 FileUtils.copyDirectoryStructure(originalClassesDir, classesDir); 41 } catch (final IOException e) { 42 throw new MojoFailureException("Unable to restore classes.", e); 43 } 44 } 45 46 } 47