List of usage examples for org.apache.maven.plugin MojoFailureException MojoFailureException
public MojoFailureException(Object source, String shortMessage, String longMessage)
MojoFailureException exception providing the source and a short and long message: these messages are used to improve the message written at the end of Maven build. From source file:au.edu.usq.fascinator.maven_plugins.rdf_reactor_file.SchemaItem.java
License:Open Source License
/** * Generates the Java code for the requested RDFS Most of these parameters * are as per the org.ontoware.rdfreactor.generator.CodeGenerator.generate * method//from ww w . ja v a 2 s. co m * * @param skipBuiltins * if false, internal helper classes are re-generated. This is * usually not needed. * @param workingDirectory * location to download any schema listed as a URL * @param outputDirectory * location for generated Java classes * @param rdfReactorLogfile * @param mavenLogger * @throws MojoExecutionException * @throws MojoFailureException * when no schema is provided, the various schema could not be * loaded or the generation fails */ protected void generateCode(boolean skipBuiltins, File workingDirectory, File outputDirectory, File rdfReactorLogfile, Log mavenLogger) throws MojoExecutionException, MojoFailureException { model.open(); this.log = mavenLogger; // Check to make sure that we have a file or a URL if (schemaUrlLibrary == null && schemaFileLibrary == null) { throw new MojoFailureException(this, "Schema file error", "No locations (file or URL given for " + this.schemaName); } Model workingSchemaModel = null; try { workingSchemaModel = loadSchema(workingDirectory); } catch (IOException e) { throw new MojoFailureException(e, "Schema access error", "Could not access the requested schema for " + schemaName); } log.info("Generating code for " + schemaName + ". Classes will be in package " + packageName + " and with method prefix " + methodPrefix + ". skipBuiltins is " + skipBuiltins + "."); try { CodeGenerator.generate(workingSchemaModel, outputDirectory, packageName, Reasoning.rdfs, skipBuiltins, methodPrefix); } catch (Exception e) { throw new MojoFailureException(e, "RDFS processing error", "Could not generate code from the specified RDF schema file."); } finally { model.close(); } }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipseToMavenMojo.java
License:Open Source License
/** * Resolves the deploy<code>deployTo</code> parameter to an <code>ArtifactRepository</code> instance (if set). * * @return ArtifactRepository instance of null if <code>deployTo</code> is not set. * @throws MojoFailureException//from w w w . j a v a2s. c om * @throws MojoExecutionException */ private ArtifactRepository resolveRemoteRepo() throws MojoFailureException, MojoExecutionException { if (deployTo != null) { Matcher matcher = DEPLOYTO_PATTERN.matcher(deployTo); if (!matcher.matches()) { throw new MojoFailureException(deployTo, Messages.getString("EclipseToMavenMojo.invalidsyntaxforrepository"), //$NON-NLS-1$ Messages.getString("EclipseToMavenMojo.invalidremoterepositorysyntax")); //$NON-NLS-1$ } else { String id = matcher.group(1).trim(); String layout = matcher.group(2).trim(); String url = matcher.group(3).trim(); ArtifactRepositoryLayout repoLayout; try { repoLayout = (ArtifactRepositoryLayout) container.lookup(ArtifactRepositoryLayout.ROLE, layout); } catch (ComponentLookupException e) { throw new MojoExecutionException( Messages.getString("EclipseToMavenMojo.cannotfindrepositorylayout", layout), e); //$NON-NLS-1$ } return artifactRepositoryFactory.createDeploymentArtifactRepository(id, url, repoLayout, true); } } return null; }
From source file:com.codetroopers.maven.mergeprops.MergeProperty.java
License:Apache License
private static void checkCountMismatch(final Map<String, Properties> propertiesMap, final Merge merge, final Map<String, Integer> localeSizeMap) throws MojoFailureException { //if we got the same numbers of keys, the set will flatten every values if (shouldFailIfNoMatchFromProperty() && merge.getFailOnCountMismatch() && new HashSet<Integer>(localeSizeMap.values()).size() != 1) { final HashMultiset<String> multiset = HashMultiset.create(); for (Map.Entry<String, Properties> entry : propertiesMap.entrySet()) { multiset.addAll(Maps.fromProperties(entry.getValue()).keySet()); }/* ww w . j av a 2s . c om*/ final int bundlesAmount = propertiesMap.keySet().size(); final Set<String> lonelyKeys = Sets.newHashSet(Collections2.filter(multiset, new Predicate<String>() { @Override public boolean apply(final String input) { return multiset.count(input) != bundlesAmount; } })); throw new MojoFailureException(lonelyKeys, "Invalid property count for file : " + merge.getTarget(), "Lonely keys are : \n" + Joiner.on("\n").join(lonelyKeys)); } }
From source file:com.elasticgrid.maven.DeployMojo.java
License:Open Source License
@SuppressWarnings("unchecked") public void execute() throws MojoExecutionException, MojoFailureException { File oar = new File(oarFileName); getLog().info("Deploying oar " + oar.getName() + "..."); // TODO: copy the OAR to the dropBucket ArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); try {//from www .j a va2 s . c o m ArtifactResolutionResult result = resolver.resolveTransitively(dependencies, project.getArtifact(), localRepository, remoteRepositories, artifactMetadataSource, filter); Set<Artifact> artifacts = result.getArtifacts(); for (Artifact artifact : artifacts) { getLog().info("Detected dependency: " + artifact + " available in " + artifact.getFile()); // TODO: this is where the actual copy to the remote maven repository should occur! } } catch (ArtifactResolutionException e) { throw new MojoFailureException(e, "Can't resolve artifact", "Can't resolve artifact"); } catch (ArtifactNotFoundException e) { throw new MojoFailureException(e, "Can't find artifact", "Can't find artifact"); } List<Artifact> attachments = project.getAttachedArtifacts(); getLog().info("Found " + attachments.size() + " attachments"); for (Artifact artifact : attachments) { getLog().info("Detected attachment: " + artifact + " available in " + artifact.getFile()); // TODO: copy the artifacts to the maven repo too! } }
From source file:com.eviware.soapui.maven2.LoadTestMojo.java
License:EUPL
public void execute() throws MojoExecutionException, MojoFailureException { if (skip || System.getProperty("maven.test.skip", "false").equals("true")) return;//w ww. ja v a 2 s . com if (projectFile == null) { throw new MojoExecutionException("soapui-project-file setting is required"); } // if( !new File(projectFile).exists() ) // { // throw new MojoExecutionException("soapui-project-file [" + projectFile + "] is not found" ); // } SoapUILoadTestRunner runner = new SoapUILoadTestRunner( "SoapUI " + SoapUI.SOAPUI_VERSION + " Maven2 LoadTest Runner"); runner.setProjectFile(projectFile); if (endpoint != null) runner.setEndpoint(endpoint); if (testSuite != null) runner.setTestSuite(testSuite); if (testCase != null) runner.setTestCase(testCase); if (loadTest != null) runner.setLoadTest(loadTest); if (username != null) runner.setUsername(username); if (password != null) runner.setPassword(password); if (wssPasswordType != null) runner.setWssPasswordType(wssPasswordType); if (domain != null) runner.setDomain(domain); if (limit != null) runner.setLimit(limit.intValue()); if (threadCount != null) runner.setThreadCount(threadCount.intValue()); if (host != null) runner.setHost(host); if (outputFolder != null) runner.setOutputFolder(outputFolder); runner.setPrintReport(printReport); runner.setSaveAfterRun(saveAfterRun); if (settingsFile != null) runner.setSettingsFile(settingsFile); if (projectPassword != null) runner.setProjectPassword(projectPassword); if (settingsPassword != null) runner.setSoapUISettingsPassword(settingsPassword); if (globalProperties != null) runner.setGlobalProperties(globalProperties); if (projectProperties != null) runner.setProjectProperties(projectProperties); if (soapuiProperties != null && soapuiProperties.size() > 0) for (Object key : soapuiProperties.keySet()) { System.out.println( "Setting " + (String) key + " value " + soapuiProperties.getProperty((String) key)); System.setProperty((String) key, soapuiProperties.getProperty((String) key)); } try { runner.run(); } catch (Throwable e) { getLog().error(e.toString()); throw new MojoFailureException(this, "SoapUI LoadTest(s) failed", e.getMessage()); } }
From source file:com.eviware.soapui.maven2.MockServiceMojo.java
License:EUPL
public void execute() throws MojoExecutionException, MojoFailureException { if (skip || System.getProperty("maven.test.skip", "false").equals("true")) return;//from w ww. j a v a 2 s. c om if (projectFile == null) { throw new MojoExecutionException("soapui-project-file setting is required"); } // if( !new File(projectFile).exists() ) // { // throw new MojoExecutionException("soapui-project-file [" + projectFile + "] is not found" ); // } SoapUIMockServiceRunner runner = new SoapUIMockServiceRunner( "SoapUI " + SoapUI.SOAPUI_VERSION + " Maven2 MockService Runner"); runner.setProjectFile(projectFile); if (mockService != null) runner.setMockService(mockService); if (path != null) runner.setPath(path); if (port != null) runner.setPort(port); if (settingsFile != null) runner.setSettingsFile(settingsFile); runner.setBlock(!noBlock); runner.setSaveAfterRun(saveAfterRun); if (projectPassword != null) runner.setProjectPassword(projectPassword); if (settingsPassword != null) runner.setSoapUISettingsPassword(settingsPassword); if (globalProperties != null) runner.setGlobalProperties(globalProperties); if (projectProperties != null) runner.setProjectProperties(projectProperties); if (soapuiProperties != null && soapuiProperties.size() > 0) for (Object key : soapuiProperties.keySet()) { System.out.println( "Setting " + (String) key + " value " + soapuiProperties.getProperty((String) key)); System.setProperty((String) key, soapuiProperties.getProperty((String) key)); } try { runner.run(); } catch (Exception e) { getLog().error(e.toString()); throw new MojoFailureException(this, "SoapUI MockService(s) failed", e.getMessage()); } }
From source file:com.eviware.soapui.maven2.SecurityTestMojo.java
License:EUPL
public void execute() throws MojoExecutionException, MojoFailureException { if (skip || System.getProperty("maven.test.skip", "false").equals("true")) return;// w w w . j a va2s . co m if (projectFile == null) { throw new MojoExecutionException("soapui-project-file setting is required"); } // if( !projectFile.startsWith( "http" ) ) // if( !new File( projectFile ).exists() ) // { // throw new MojoExecutionException( "soapui-project-file [" + projectFile + "] is not found or not specified" ); // } SoapUISecurityTestRunner runner = new SoapUISecurityTestRunner( "SoapUI " + SoapUI.SOAPUI_VERSION + " Maven2 Security Test Runner"); runner.setProjectFile(projectFile); if (endpoint != null) runner.setEndpoint(endpoint); if (testSuite != null) runner.setTestSuite(testSuite); if (testCase != null) runner.setTestCase(testCase); if (username != null) runner.setUsername(username); if (password != null) runner.setPassword(password); if (wssPasswordType != null) runner.setWssPasswordType(wssPasswordType); if (domain != null) runner.setDomain(domain); if (host != null) runner.setHost(host); if (outputFolder != null) runner.setOutputFolder(outputFolder); runner.setPrintReport(printReport); runner.setExportAll(exportAll); runner.setJUnitReport(junitReport); runner.setEnableUI(interactive); runner.setIgnoreError(testFailIgnore); runner.setSaveAfterRun(saveAfterRun); if (settingsFile != null) runner.setSettingsFile(settingsFile); if (projectPassword != null) runner.setProjectPassword(projectPassword); if (settingsPassword != null) runner.setSoapUISettingsPassword(settingsPassword); if (globalProperties != null) runner.setGlobalProperties(globalProperties); if (projectProperties != null) runner.setProjectProperties(projectProperties); if (soapuiProperties != null && soapuiProperties.size() > 0) for (Object key : soapuiProperties.keySet()) { // System.out.println( "Setting " + ( String )key + " value " + soapuiProperties.getProperty( ( String )key ) ); System.setProperty((String) key, soapuiProperties.getProperty((String) key)); } if (securityTest != null && securityTest.length() > 0) runner.setSecurityTestName(securityTest); try { runner.run(); } catch (Exception e) { getLog().error(e.toString()); throw new MojoFailureException(this, "SoapUI Test(s) failed", e.getMessage()); } }
From source file:com.eviware.soapui.maven2.ToolMojo.java
License:EUPL
public void execute() throws MojoExecutionException, MojoFailureException { if (projectFile == null) { throw new MojoExecutionException("soapui-project-file setting is required"); }//from www . j av a 2 s . com // if (!new File(projectFile).exists()) // { // throw new MojoExecutionException("soapui-project-file [" + projectFile + "] is not found"); // } SoapUIToolRunner runner = new SoapUIToolRunner("SoapUI " + SoapUI.SOAPUI_VERSION + " Maven2 Tool Runner"); runner.setProjectFile(projectFile); if (iface != null) runner.setInterface(iface); if (tool != null) runner.setTool(tool); if (settingsFile != null) runner.setSettingsFile(settingsFile); if (projectPassword != null) runner.setProjectPassword(projectPassword); if (settingsPassword != null) runner.setSoapUISettingsPassword(settingsPassword); if (outputFolder != null) runner.setOutputFolder(outputFolder); if (soapuiProperties != null && soapuiProperties.size() > 0) for (Object key : soapuiProperties.keySet()) { System.out.println( "Setting " + (String) key + " value " + soapuiProperties.getProperty((String) key)); System.setProperty((String) key, soapuiProperties.getProperty((String) key)); } try { runner.run(); } catch (Exception e) { getLog().error(e.toString()); throw new MojoFailureException(this, "SoapUI Tool(s) failed", e.getMessage()); } }
From source file:com.fibon.maven.confluence.AbstractConfluenceMojo.java
License:Apache License
protected MojoFailureException fail(String message, Exception e) { getLog().error(message, e); return new MojoFailureException(e, message, e.getMessage()); }
From source file:com.github.wcy123.maven.launcher.RunnerMojo.java
License:Apache License
ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException { // if it's a simple url String id = "temp"; ArtifactRepositoryLayout layout = getLayout("default"); String url = repo;/*from w w w.ja v a 2s.c om*/ // if it's an extended repo URL of the form id::layout::url if (repo.contains("::")) { Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo); if (!matcher.matches()) { throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo, "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"."); } id = matcher.group(1).trim(); if (!StringUtils.isEmpty(matcher.group(2))) { layout = getLayout(matcher.group(2).trim()); } url = matcher.group(3).trim(); } return new MavenArtifactRepository(id, url, layout, policy, policy); }