List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException
public MojoExecutionException(String message, Throwable cause)
MojoExecutionException
exception wrapping an underlying Throwable
and providing a message
. From source file:com.autentia.mvn.plugin.changes.BugzillaChangesMojo.java
License:Open Source License
/** * Gets bugs XML document from Bugzilla. * // w w w.j a va 2 s. c o m * @param client * @param bugsIds * @return * @throws MojoExecutionException */ private Document getBugsDocument(final HttpClient client, final String bugsIds) throws MojoExecutionException { final String link = this.bugzillaUrl + SHOWBUG_URL; try { final byte[] response = this.httpRequest.sendPostRequest(client, link, bugsIds); final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final DocumentBuilder db = dbf.newDocumentBuilder(); db.setEntityResolver(new EntityResolver() { public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException, IOException { return new InputSource( this.getClass().getClassLoader().getResourceAsStream("bugzilla3/bugzilla.dtd")); } }); final ByteArrayInputStream bais = new ByteArrayInputStream(response); final Document docBugzilla = db.parse(bais); this.cleanBugzillaDocument(docBugzilla); return docBugzilla; } catch (final HttpStatusException e) { this.getLog().warn("Can not recover bugs in XML", e); throw new MojoExecutionException("Can not recover bugs in XML.", e); } catch (final IOException e) { this.getLog().warn("Can not recover bugs in XML", e); throw new MojoExecutionException("Can not recover bugs in XML.", e); } catch (final ParserConfigurationException e) { this.getLog().warn("Can not parse XML bugs", e); throw new MojoExecutionException("Can not parse XML bugs.", e); } catch (final SAXException e) { this.getLog().warn("Can not build bugs XML document", e); throw new MojoExecutionException("Can not build bugs XML document.", e); } }
From source file:com.autentia.mvn.plugin.changes.BugzillaChangesMojo.java
License:Open Source License
/** * Gets the bug list from Bugzilla and builds the bug Id's string. [id=bug_id&id=bug_id&...] * //from www . j av a2 s. co m * @param client * @return * @throws MojoExecutionException */ private String getBugList(final HttpClient client) throws MojoExecutionException { try { if (this.productName == null) { // recuperamos el nombre del proyecto del POM this.productName = this.project.getName(); } final String[] resolutions = this.resolution.split(","); String resolution = ""; for (final String element : resolutions) { resolution = resolution + PARAMETERS_UNION + RESOLUTION_PARAMETER + PARAMETERS_ASSIGN + URLEncoder.encode(element, "UTF-8"); } String componentURL = ""; // si es padre no tenemos en cuenta el componente ya que es todo if (this.project.getParent() != null) { if ((this.componentName != null) && !this.componentName.equals("")) { componentURL = PARAMETERS_UNION + COMPONENT_PARAMETER + PARAMETERS_ASSIGN + URLEncoder.encode(this.componentName, "UTF-8"); } } // version String version = ""; if (this.currentVersionOnly) { version = PARAMETERS_UNION + TARGET_PARAMETER + PARAMETERS_ASSIGN + URLEncoder.encode(this.versionName, "UTF-8"); } final String buglistURL = this.bugzillaUrl + BUGLIST_URL + BEGIN_PARAMETERS + PRODUCT_PARAMETER + PARAMETERS_ASSIGN + URLEncoder.encode(this.productName, "UTF-8") + componentURL + resolution + version + "&order=target_milestone"; final String response = new String(this.httpRequest.sendGetRequest(client, buglistURL), "UTF-8"); return this.buildBugsIdsString(response); } catch (final HttpStatusException e) { this.getLog().warn("Can not recover bug list", e); throw new MojoExecutionException("Can not recover bug list.", e); } catch (final IOException e) { this.getLog().warn("Can not recover bug list", e); throw new MojoExecutionException("Can not recover bug list.", e); } }
From source file:com.autentia.mvn.plugin.changes.BugzillaChangesMojo.java
License:Open Source License
/** * Performs Bugzilla login.// w w w. ja va2 s .c o m * * @param client * @return True if login is successfully. * @throws MojoExecutionException */ private boolean login(final HttpClient client) throws MojoExecutionException { final String link = this.bugzillaUrl + this.loginPage; final String parameters = LOGIN_PARAMETER_NAME + PARAMETERS_ASSIGN + this.bugzillaUser + PARAMETERS_UNION + PASSWORD_PARAMETER_NAME + PARAMETERS_ASSIGN + this.bugzillaPassword; boolean success = false; try { final String response = new String(this.httpRequest.sendPostRequest(client, link, parameters), "UTF-8"); success = response.indexOf(LOGIN_FAILURE) == -1; } catch (final HttpStatusException e) { this.getLog().warn("Can not do login", e); throw new MojoExecutionException("Can not do login.", e); } catch (final IOException e) { this.getLog().warn("Can not do login", e); throw new MojoExecutionException("Can not do login.", e); } return success; }
From source file:com.autentia.mvn.plugin.release.bugzilla.BugzillaReleaseMojo.java
License:Open Source License
private void promptVersionAndMilestone() throws MojoExecutionException { try {/*from ww w . ja va 2 s . c o m*/ versionName = prompter.prompt("What is the product release Bugzilla version name? ", versionName); } catch (final PrompterException e) { throw new MojoExecutionException("Could not get new version name.", e); } try { newMilestone = prompter.prompt("What is the product new development Bugzilla milestone? ", newMilestone); } catch (final PrompterException e) { throw new MojoExecutionException("Could not get milestone name.", e); } }
From source file:com.autentia.mvn.plugin.release.bugzilla.BugzillaReleaseMojo.java
License:Open Source License
/** * Change bugs in bugzilla/*from www . j a va2 s . c o m*/ * * @param wc * @param statusValues * @param formField * @param fieldValue * @throws MojoExecutionException */ private void changeBugs(final WebConversation wc, final String[] statusValues, final String formField, final String fieldValue) throws MojoExecutionException { try { final WebRequest req = new GetMethodWebRequest(bugzillaUrl + BUGLIST_URL); req.setParameter(PRODUCT_PARAMETER, productName); req.setParameter(STATUS_PARAMETER, statusValues); req.setParameter(TARGET_PARAMETER, versionName); final WebResponse resp = wc.getResponse(req); final WebLink[] weblinks = resp.getLinks(); for (final WebLink webLink : weblinks) { if (webLink.getURLString().startsWith(SHOWBUG_URL)) { final WebResponse response = webLink.click(); final WebForm webForm = response.getFormWithName(CHANGEFORM); webForm.setParameter(formField, fieldValue); webForm.submit(); } } } catch (final MalformedURLException e) { throw new MojoExecutionException("", e); } catch (final IOException e) { throw new MojoExecutionException("", e); } catch (final SAXException e) { throw new MojoExecutionException("", e); } }
From source file:com.autentia.mvn.plugin.release.bugzilla.BugzillaReleaseMojo.java
License:Open Source License
/** * Do bugzilla login/*from w ww. j a v a2 s .c o m*/ * * @param wc * @return * @throws MojoExecutionException */ private boolean login(final WebConversation wc) throws MojoExecutionException { try { final WebRequest req = new GetMethodWebRequest(bugzillaUrl + loginPage); WebResponse resp; resp = wc.getResponse(req); final WebForm webForm = resp.getFormWithName("login"); if (isEmpty(bugzillaUser)) { bugzillaUser = prompter.prompt("Enter bugzilla user:"); } if (isEmpty(bugzillaPassword)) { bugzillaPassword = prompter.promptForPassword("Enter bugzilla password:"); } webForm.setParameter("Bugzilla_login", bugzillaUser); webForm.setParameter("Bugzilla_password", bugzillaPassword); webForm.submit(); resp = wc.getCurrentPage(); final HTMLElement errorMessage = resp.getElementWithID("error_msg"); return (errorMessage == null); } catch (final MalformedURLException e) { throw new MojoExecutionException("", e); } catch (final IOException e) { throw new MojoExecutionException("", e); } catch (final SAXException e) { throw new MojoExecutionException("", e); } catch (final PrompterException e) { throw new MojoExecutionException("", e); } }
From source file:com.azurenight.maven.TroposphereMojo.java
License:Apache License
public void execute() throws MojoExecutionException { File sourceDirectory = getSourceDirectory(); getLog().debug("source=" + sourceDirectory + " target=" + getOutputDirectory()); if (!(sourceDirectory != null && sourceDirectory.exists())) { getLog().info("Request to add '" + sourceDirectory + "' folder. Not added since it does not exist."); return;//from ww w . j av a2s . c o m } File f = outputDirectory; if (!f.exists()) { f.mkdirs(); } setupVariables(); extractJarToDirectory(jythonArtifact.getFile(), temporaryBuildDirectory); // now what? we have the jython content, now we need // easy_install getLog().debug("installing easy_install ..."); try { FileUtils.copyInputStreamToFile(setuptoolsResource.openStream(), setuptoolsJar); } catch (IOException e) { throw new MojoExecutionException("copying setuptools failed", e); } try { FileUtils.copyInputStreamToFile(botoURL.openStream(), botoFile); } catch (IOException e) { throw new MojoExecutionException("copying boto failed", e); } try { FileUtils.copyInputStreamToFile(tropoURL.openStream(), tropoFile); } catch (IOException e) { throw new MojoExecutionException("copying troposphere failed", e); } extractJarToDirectory(setuptoolsJar, new File(sitepackagesdir, SETUPTOOLS_EGG)); try { IOUtils.write("./" + SETUPTOOLS_EGG + "\n", new FileOutputStream(new File(sitepackagesdir, "setuptools.pth"))); } catch (IOException e) { throw new MojoExecutionException("writing path entry for setuptools failed", e); } getLog().debug("installing easy_install done"); Iterator<String> it = libs.iterator(); while (it.hasNext()) { String s = it.next(); if (s == null || s.length() == 0) { it.remove(); } } if (libs == null || libs.size() == 0) { getLog().info("no python libraries requested"); } else { getLog().debug("installing requested python libraries"); // then we need to call easy_install to install the other // dependencies. runJythonScriptOnInstall(temporaryBuildDirectory, getEasyInstallArgs("Lib/site-packages/" + SETUPTOOLS_EGG + "/easy_install.py"), null); getLog().debug("installing requested python libraries done"); } processFiles(); }
From source file:com.azurenight.maven.TroposphereMojo.java
License:Apache License
/** * @param file// w w w . j ava 2s.co m * @return * @throws MojoExecutionException */ private List<String> getPythonArgs(String file) throws MojoExecutionException { List<String> args = new ArrayList<String>(); // I want to launch args.add("java"); // to run the generated jython installation here args.add("-cp"); args.add("." + getClassPathSeparator() + "Lib"); // which should know about itself args.add("-Dpython.home=."); File jythonFakeExecutable = new File(temporaryBuildDirectory, "jython"); try { jythonFakeExecutable.createNewFile(); } catch (IOException e) { throw new MojoExecutionException("couldn't create file", e); } args.add("-Dpython.executable=" + jythonFakeExecutable.getName()); args.add("org.python.util.jython"); // and it should run the supplied file args.add(file); return args; }
From source file:com.azurenight.maven.TroposphereMojo.java
License:Apache License
private JarFile openJarFile(File jar) throws MojoExecutionException { try {/*from w w w.j av a 2s . c o m*/ return new JarFile(jar); } catch (IOException e) { throw new MojoExecutionException("opening jython artifact jar failed", e); } }
From source file:com.azurenight.maven.TroposphereMojo.java
License:Apache License
private void closeFile(ZipFile ja) throws MojoExecutionException { try {/*ww w . j a va2 s . c om*/ ja.close(); } catch (IOException e) { throw new MojoExecutionException("closing jython artifact jar failed", e); } }