List of usage examples for java.lang CloneNotSupportedException getStackTrace
public StackTraceElement[] getStackTrace()
From source file:org.apache.maven.plugins.linkcheck.SiteInvoker.java
/** * Invoke Maven for the <code>site</code> phase for a temporary Maven project using * <code>tmpReportingOutputDirectory</code> as <code>${project.reporting.outputDirectory}</code>. * This is a workaround to be sure that all site files have been correctly generated. * <br/>/*from w ww.java 2s . co m*/ * <b>Note 1</b>: the Maven Home should be defined in the <code>maven.home</code> Java system property * or defined in <code>M2_HOME</code> system env variables. * <b>Note 2</be>: we can't use <code>siteOutputDirectory</code> param from site plugin because some plugins * <code>${project.reporting.outputDirectory}</code> in their conf. * * @param project the MavenProject to invoke the site on. Not null. * @param tmpReportingOutputDirectory not null * @throws IOException if any */ public void invokeSite(MavenProject project, File tmpReportingOutputDirectory) throws IOException { String mavenHome = getMavenHome(); if (StringUtils.isEmpty(mavenHome)) { getLog().error("Could NOT invoke Maven because no Maven Home is defined. " + "You need to set the M2_HOME system env variable or a 'maven.home' Java system property."); return; } // invoker site parameters List goals = Collections.singletonList("site"); Properties properties = new Properties(); properties.put("linkcheck.skip", "true"); // to stop recursion File invokerLog = FileUtils.createTempFile("invoker-site-plugin", ".txt", new File(project.getBuild().getDirectory())); // clone project and set a new reporting output dir MavenProject clone; try { clone = (MavenProject) project.clone(); } catch (CloneNotSupportedException e) { IOException ioe = new IOException("CloneNotSupportedException: " + e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } // MLINKCHECK-1 if (clone.getOriginalModel().getReporting() == null) { clone.getOriginalModel().setReporting(new Reporting()); } clone.getOriginalModel().getReporting().setOutputDirectory(tmpReportingOutputDirectory.getAbsolutePath()); List profileIds = getActiveProfileIds(clone); // create the original model as tmp pom file for the invoker File tmpProjectFile = FileUtils.createTempFile("pom", ".xml", project.getBasedir()); Writer writer = null; try { writer = WriterFactory.newXmlWriter(tmpProjectFile); clone.writeOriginalModel(writer); } finally { IOUtil.close(writer); } // invoke it try { invoke(tmpProjectFile, invokerLog, mavenHome, goals, profileIds, properties); } finally { if (!getLog().isDebugEnabled()) { tmpProjectFile.delete(); } } }