1 /* 2 * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.maven.exceptions; 17 18 import java.io.File; 19 import java.io.IOException; 20 21 import org.apache.commons.io.FileUtils; 22 import org.apache.maven.plugin.MojoExecutionException; 23 import org.apache.maven.plugin.MojoFailureException; 24 25 import de.smartics.maven.io.MojoIoUtils; 26 27 /** 28 * Extracts the exception code information of a project and generates one XML 29 * document for each code in the <a href="https://project.smartics.de/public/de.smartics.maven.plugin/maven-projectdoc-plugin/LATEST/" 30 * >projectdoc</a>'s <a href="https://project.smartics.de/public/de.smartics.projectdoc.doctypes/appcode/LATEST" 31 * >appcode doctype</a> format. 32 * 33 * @goal copy 34 * @phase process-classes 35 * @requiresProject 36 * @description XML export of project error codes. 37 */ 38 public class CopySdocCodeMojo extends AbstractSdocCodeMojo 39 { 40 // ********************************* Fields ********************************* 41 42 // --- constants ------------------------------------------------------------ 43 44 // --- members -------------------------------------------------------------- 45 46 /** 47 * The directory containing the generated documentation XML files. 48 * 49 * @parameter 50 * expression="${project.build.directory}/projectdoc-work/generated/process/implementation/appproperty" 51 * @required 52 * @since 1.0 53 */ 54 protected File genSrcDir; 55 56 // ****************************** Initializer ******************************* 57 58 // ****************************** Constructors ****************************** 59 60 // ****************************** Inner Classes ***************************** 61 62 // ********************************* Methods ******************************** 63 64 // --- init ----------------------------------------------------------------- 65 66 // --- get&set -------------------------------------------------------------- 67 68 // --- business ------------------------------------------------------------- 69 70 /** 71 * {@inheritDoc} 72 */ 73 @Override 74 protected void handleGeneratedDocuments() throws MojoExecutionException, 75 MojoFailureException 76 { 77 try 78 { 79 MojoIoUtils.provideDirectory(this.genSrcDir); 80 FileUtils.copyDirectory(output, this.genSrcDir); 81 handleMetaInfDir(); 82 } 83 catch (final IOException e) 84 { 85 throw new MojoExecutionException("Cannot copy resources to '" 86 + this.genSrcDir.getAbsolutePath() 87 + "'.", e); 88 } 89 } 90 91 private void handleMetaInfDir() 92 { 93 final File metaInfDir = new File(this.genSrcDir, "META-INF"); 94 if (metaInfDir.exists()) 95 { 96 metaInfDir.delete(); 97 } 98 } 99 100 // --- object basics -------------------------------------------------------- 101 102 }