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.basistech.oss.pump.PumpAbsolutePathnameMojo.java
License:Apache License
/** {@inheritDoc} */ public void execute() throws MojoExecutionException, MojoFailureException { for (String prop : propertyNames) { String path = (String) project.getProperties().get(prop); String canon = null;//from www .j a v a 2s . c om if (path == null) { getLog().error("No value for property " + prop); } else { File f = new File(path); try { canon = f.getCanonicalPath(); } catch (IOException e) { throw new MojoExecutionException("Failed to canonicalize " + f.getPath(), e); } project.getProperties().put(prop + ".abs", canon); if (verbose) { getLog().info("Setting " + prop + ".abs to " + canon); } } } }
From source file:com.basistech.ReleaseNoteMojo.java
License:Open Source License
public void execute() throws MojoExecutionException { StaticLoggerBinder.getSingleton().setLog(getLog()); if (skip) {//from w ww.j av a 2s. c o m getLog().info("Github Release Notes Plugin execution skipped"); return; } String releaseNoteContent; try { releaseNoteContent = FileUtils.readFileToString(releaseNotes, "utf-8"); } catch (IOException e) { throw new MojoExecutionException("Failed to read notes", e); } parseScm(); Client client = createClient(); String tagName = getTagName(); ReleaseInfo releaseInfo = new ReleaseInfo(tagName, null, tagName, releaseNoteContent, false, false); String uri; if ("github.com".equals(host)) { uri = String.format("https://api.github.com/repos/%s/%s/releases", owner, repoName); } else { uri = String.format("https://%s/api/v3/repos/%s/%s/releases", host, owner, repoName); } WebTarget target = client.target(uri); String existingRelease = getExistingRelease(tagName, target); createRelease(existingRelease, releaseInfo, target); }
From source file:com.basistech.ReleaseNoteMojo.java
License:Open Source License
private Client createClient() throws MojoExecutionException { Bus bus = BusFactory.getDefaultBus(); // insist on the async connector to use PATCH. bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE); ClientBuilder builder = ClientBuilder.newBuilder(); builder.register(new JacksonJsonProvider()); if (keystore != null) { try {//ww w . j a va2 s . c om builder.trustStore(readTrustStore(keystore)); } catch (Exception e) { throw new MojoExecutionException("Exception setting up SSL trust store", e); } } Client client = builder.build(); if (!getAuthFromSettings(client)) { if (oauth2Token != null) { setupOauth2(client, oauth2Token); } else if (userName != null) { setupBasicAuthentication(client, userName, password); } } return client; }
From source file:com.basistech.ReleaseNoteMojo.java
License:Open Source License
private void setupProxy(Invocation.Builder target) throws MojoExecutionException { Proxy proxy = getProxy(settings, serverId); if (null != proxy) { ClientConfiguration cxfConfig = WebClient.getConfig(target); Conduit conduit = cxfConfig.getConduit(); try {//w w w . jav a2s . c o m SettingsDecrypter settingsDecrypter = container.lookup(SettingsDecrypter.class); SettingsDecryptionResult result = settingsDecrypter .decrypt(new DefaultSettingsDecryptionRequest(proxy)); proxy = result.getProxy(); } catch (ComponentLookupException cle) { throw new MojoExecutionException("Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle); } getLog().debug(MessageFormat.format("Found Proxy {0}:{1}", proxy.getHost(), proxy.getPort())); HTTPConduit http = (HTTPConduit) conduit; http.getClient().setProxyServer(proxy.getHost()); http.getClient().setProxyServerPort(proxy.getPort()); http.getProxyAuthorization().setUserName(proxy.getUsername()); http.getProxyAuthorization().setPassword(proxy.getPassword()); } }
From source file:com.basistech.ReleaseNoteMojo.java
License:Open Source License
private String getTagName() throws MojoExecutionException { if (tag != null) { return tag; }//from ww w . j a va2 s.c om String scmTag = (String) project.getProperties().get("scm.tag"); if (scmTag != null) { return scmTag; } File releasePropsFile = new File(project.getBasedir(), "release.properties"); if (releasePropsFile.exists()) { Properties releaseProps = new Properties(); InputStream is = null; try { is = new FileInputStream(releasePropsFile); releaseProps.load(is); } catch (IOException ie) { throw new MojoExecutionException("Failed to read release.properties", ie); } finally { IOUtils.closeQuietly(is); } String propTag = (String) releaseProps.get("scm.tag"); if (propTag != null) { return propTag; } } throw new MojoExecutionException("No scm tag information available."); }
From source file:com.bc.maven.plugins.JavaHelpMojo.java
License:Open Source License
public void execute() throws MojoExecutionException { /*/*from w w w . j a va2 s. c o m*/ * Get the arguments... */ ArrayList<String> args = new ArrayList<String>(); if (!skip) { if (locale != null) { args.add("-locale"); args.add(locale); } if (dataBase != null) { args.add("-db"); args.add(dataBase.getAbsolutePath()); } if (logFile != null) { args.add("-logfile"); args.add(logFile.getAbsolutePath()); } if (configFile != null) { args.add("-c"); args.add(configFile.getAbsolutePath()); } if (verbose) { args.add("-verbose"); } if (noStopWords) { args.add("-nostopwords"); } if (sourcePath != null) { args.add("-sourcepath"); args.add(sourcePath.getAbsolutePath() + File.separator); List<String> files = getFilesToIndex(sourcePath); args.addAll(files); } try { indexer.compile(args.toArray(new String[args.size()])); } catch (Exception e) { throw new MojoExecutionException( "Java Help indexing exception, a full search database may not have been created.", e); } getLog().info("Javahelp Search Database written to " + dataBase.getAbsolutePath()); } else { getLog().info("Skipping Javahelp search indexing."); } }
From source file:com.bealearts.livecycle.ArchiveMojo.java
License:Apache License
/** * Execute the Mojo//from w w w . jav a2 s .c o m */ public void execute() throws MojoExecutionException { File archive = new File(this.buildDirectory, this.finalName + ".lca"); try { String[] excludes = { "**/*.application" }; this.zipArchiver.addDirectory(new File(this.buildDirectory, "classes"), null, excludes); this.zipArchiver.setDestFile(archive); this.zipArchiver.createArchive(); } catch (Exception e) { throw new MojoExecutionException("Error creating archive", e); } Artifact artifact = this.project.getArtifact(); artifact.setFile(archive); }
From source file:com.bekioui.maven.plugin.client.generator.ClientFactoryGenerator.java
License:Apache License
public static TypeName generate(Project project, List<Resource> resources) throws MojoExecutionException { try {/*ww w . j av a 2 s . co m*/ String interfaceName = project.properties().clientPrefix() + INTERFACE_BASE_NAME; TypeName interfaceType = ClassName.get(project.apiPackageName(), interfaceName).box(); Map<Resource, String> resourceToMethodName = createInterface(project, resources, interfaceName); createImplementation(project, resources, interfaceType, resourceToMethodName); return interfaceType; } catch (Exception e) { throw new MojoExecutionException("Failed to generate client factory.", e); } }
From source file:com.bekioui.maven.plugin.client.generator.ClientGenerator.java
License:Apache License
public static void generate(Project project, List<ContextResource> contextResources, TypeName clientFactoryType) throws MojoExecutionException { try {// ww w.j av a 2 s.c om String interfaceName = project.properties().clientPrefix() + INTERFACE_BASE_NAME; TypeName interfaceType = ClassName.get(project.apiPackageName(), interfaceName).box(); createInterface(project, contextResources, interfaceName); createImplementation(project, contextResources, clientFactoryType, interfaceType); } catch (Exception e) { throw new MojoExecutionException("Failed to generate client.", e); } }
From source file:com.bekioui.maven.plugin.client.generator.ContextGenerator.java
License:Apache License
public static List<ContextResource> generate(Project project, List<Resource> resources, TypeName clientFactoryType) throws MojoExecutionException { try {/* ww w. j a va 2s. co m*/ List<ContextResource> contextResources = new ArrayList<>(resources.size()); for (Resource resource : resources) { String className = resource.className() + CONTEXT_SUFFIX; contextResources.add(ContextResource .create(ClassName.get(project.contextPackageName(), className).box(), className, resource)); FieldSpec resourceField = FieldSpec.builder(resource.typeName(), resource.fieldName()) // .addModifiers(Modifier.PRIVATE, Modifier.FINAL) // .build(); MethodSpec constructor = MethodSpec.constructorBuilder() // .addModifiers(Modifier.PUBLIC) // .addParameter(ParameterSpec.builder(clientFactoryType, "clientFactory").build()) // .addStatement("this." + resource.fieldName() + " = clientFactory." + getResourceMethodName(resource) + "()") // .build(); TypeSpec clazz = TypeSpec.classBuilder(className) // .addModifiers(Modifier.PUBLIC) // .addField(resourceField) // .addMethod(constructor) // .addMethods(resource.methods()) // .build(); FileGenerator.generate(project, project.contextPackageName(), clazz); } return contextResources; } catch (Exception e) { throw new MojoExecutionException("Failed to generate context classes.", e); } }