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.caucho.maven.aws.MavenEc2ListCluster.java
License:Open Source License
protected void describeTriadMembers(Jec2 ec2) throws MojoExecutionException { try {//from w w w. j ava2 s . c o m List<String> addresses = new ArrayList<String>(); for (String triadIp : _triadIps) addresses.add(triadIp); List<AddressInfo> addressInfos = ec2.describeAddresses(addresses); List<String> instanceIds = new ArrayList<String>(); for (AddressInfo addressInfo : addressInfos) instanceIds.add(addressInfo.getInstanceId()); List<ReservationDescription> descriptions = ec2.describeInstances(instanceIds); /// XXX should ignore address info index and use elastic ip for (int i = 0; i < _triadIps.length; i++) { String instanceId = addressInfos.get(i).getInstanceId(); for (ReservationDescription description : descriptions) { List<ReservationDescription.Instance> instances = description.getInstances(); for (ReservationDescription.Instance instance : instances) { if (instance.getInstanceId().equals(instanceId)) { getLog().info(indexToName(i) + ":"); getLog().info(" Instance Id : " + instance.getInstanceId()); getLog().info(" State : " + instance.getState()); String launchTime = DATE_FORMAT.format(instance.getLaunchTime().getTime()); getLog().info(" Launch Time : " + launchTime); } } } } } catch (EC2Exception e) { throw new MojoExecutionException("Exception while finding triad members", e); } }
From source file:com.caucho.maven.MavenJspc.java
License:Open Source License
/** * Executes the maven resin:jspc task//from w w w. j a va 2 s .co m */ public void execute() throws MojoExecutionException { List<String> args = new ArrayList<String>(); args.add("-app-dir"); args.add(_rootDirectory.getAbsolutePath()); if (_config != null) { args.add("-conf"); args.add(_config.getAbsolutePath()); } if (_compiler != null) { args.add("-compiler"); args.add(_compiler); } try { JspCompiler.main(args.toArray(new String[args.size()])); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new MojoExecutionException(e.toString(), e); } }
From source file:com.caucho.maven.MavenUploadWar.java
License:Open Source License
/** * Executes the maven resin:run task/*from w w w.j av a 2 s .c om*/ */ @Override protected void doTask(WebAppDeployClient client) throws MojoExecutionException { Log log = getLog(); try { // upload com.caucho.vfs.Path path = Vfs.lookup(_warFile); String archiveTag = _archive; if ("true".equals(archiveTag)) { archiveTag = client.createArchiveTag(getVirtualHost(), getContextRoot(), getVersion()); } else if ("false".equals(archiveTag)) { archiveTag = null; } CommitBuilder commit = buildVersionedWarTag(); client.commitArchive(commit, path); log.info("Deployed " + path + " to tag " + commit.getId()); /* if (archiveTag != null) { client.copyTag(archiveTag, tag, attributes); log.info("Created archive tag " + archiveTag); } if (getVersion() != null && _writeHead) { String headTag = buildWarTag(); client.copyTag(headTag, tag, attributes); log.info("Wrote head version tag " + headTag); } */ } catch (Exception e) { throw new MojoExecutionException("Resin upload war failed", e); } }
From source file:com.cdmtech.atlas.maven.plugins.generator.ASDependenciesGeneratorMojo.java
License:Open Source License
public void execute() throws MojoExecutionException { getLog().info("ClassName: " + className); getLog().info("filesDirectory: " + filesDirectory); getLog().info("classPackage: " + classPackage); String tpl = composeASDepFile(); getLog().info("File name: " + className + ".as"); File output = new File(outputDirectory.getAbsolutePath() + "/" + composePath() + className + ".as"); if ((output.getParentFile() != null) && (!output.getParentFile().exists())) { if (!(true == output.getParentFile().mkdirs())) getLog().info("Error creating outputDirectory."); }/*ww w .j a va 2 s .com*/ FileWriter w = null; try { w = new FileWriter(output); w.write(tpl); } catch (IOException e) { throw new MojoExecutionException("Error creating file " + output, e); } finally { if (w != null) { try { w.close(); } catch (IOException e) { // ignore } } } if (project.getExecutionProject() != null) { project.getExecutionProject().addCompileSourceRoot(outputDirectory.getAbsolutePath()); } project.addCompileSourceRoot(outputDirectory.getAbsolutePath()); getLog().debug("Adding dependencies source path (" + outputDirectory.getAbsolutePath() + ") to project: " + project.getArtifactId()); }
From source file:com.chiralbehaviors.CoRE.generators.PolymorphicMixinGenerator.java
License:Open Source License
public void execute() throws MojoExecutionException { System.out.println(String.format("args: %s, %s, %s", packageName, outputDirectory, className)); File file = new File(outputDirectory, String.format("%s/%s.java", packageName.replace('.', '/'), className)); File parentDir = new File(outputDirectory, packageName.replace('.', '/')); try {/*w ww .j a v a2 s . c o m*/ Files.createDirectories(parentDir.toPath()); } catch (IOException e) { throw new MojoExecutionException(String.format("Cannot create parent directories %s", file.getParent()), e); } final Map<String, Class<?>> entityMap = new HashMap<String, Class<?>>(); Set<String> imports = new HashSet<String>(); List<AnnotationValue> annotations = new ArrayList<AnnotationValue>(); Reflections reflections = new Reflections(Ruleform.class.getPackage().getName()); for (Class<? extends Ruleform> form : reflections.getSubTypesOf(Ruleform.class)) { if (!Modifier.isAbstract(form.getModifiers())) { Class<?> prev = entityMap.put(form.getSimpleName(), form); assert prev == null : String.format("Found previous mapping %s of: %s", prev, form); imports.add(form.getCanonicalName()); annotations.add(new AnnotationValue(form.getSimpleName(), form.getSimpleName().toLowerCase())); } } STGroup group = new STGroupFile("templates/polymorphicmixin.stg"); ST mixin = group.getInstanceOf("mixinclass"); mixin.add("importdecs", imports); mixin.add("annotations", annotations); FileOutputStream os; try { Files.deleteIfExists(file.toPath()); os = new FileOutputStream(Files.createFile(file.toPath()).toFile()); } catch (FileNotFoundException e) { throw new MojoExecutionException( String.format("Cannot find file for create %s", file.getAbsolutePath(), e)); } catch (IOException e) { throw new MojoExecutionException( String.format("Error creating file %s\nCause: %s", file.getAbsolutePath(), e.getMessage())); } try { os.write(mixin.render().getBytes()); os.close(); } catch (IOException e) { throw new MojoExecutionException(String.format("Error writing file %s", file.getAbsolutePath(), e)); } }
From source file:com.chiralbehaviors.CoRE.networkInference.NetworkInferenceQueryGenerator.java
License:Open Source License
@Override public void execute() throws MojoExecutionException { getLog().info(String.format("output directory %s", outputDirectory)); try {/*ww w . j ava 2 s . c o m*/ Files.createDirectories(outputDirectory.toPath()); } catch (IOException e) { throw new MojoExecutionException( String.format("Cannot create output directory %s", outputDirectory.getAbsoluteFile()), e); } for (String[] info : GENERATED) { File output = new File(outputDirectory, String.format("%s/%s.xml", info[1].replace('.', '/'), info[3])); generate(info[0], info[1], info[2], info[3], output); } }
From source file:com.chiralbehaviors.CoRE.networkInference.NetworkInferenceQueryGenerator.java
License:Open Source License
private void generate(String entityName, String entityPackage, String tableName, String queryPrefix, File output) throws MojoExecutionException { getLog().info(String.format("Generating %s to %s", entityName, output)); try {//from w w w . j av a2 s. c o m Files.createDirectories(output.getParentFile().toPath()); } catch (IOException e) { throw new MojoExecutionException(String.format("Cannot create generated file parent directories %s", output.getParentFile().getAbsoluteFile()), e); } try { Files.deleteIfExists(output.toPath()); } catch (IOException e) { throw new MojoExecutionException( String.format("Cannot delete generated file %s", output.getAbsoluteFile()), e); } STGroup group = new STGroupFile(TEMPLATES_NETWORK_INFERENCE_STG, '%', '%'); ST inference = group.getInstanceOf(NETWORK_INFERENCE); inference.add(ENTITY_NAME, entityName); inference.add(ENTITY_PACKAGE, entityPackage); inference.add(TABLE_NAME, tableName); inference.add(QUERY_PREFIX, queryPrefix); try (OutputStream os = new FileOutputStream(output)) { os.write(inference.render().getBytes()); } catch (FileNotFoundException e) { throw new MojoExecutionException( String.format("Cannot find generated file for write %s", output.getAbsoluteFile()), e); } catch (IOException e) { throw new MojoExecutionException(String.format("Error generating file %s", output.getAbsoluteFile()), e); } }
From source file:com.chiralbehaviors.CoRE.workspace.plugin.WorkspaceDslLoader.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("Creating workspaces from dsl resources "); List<URL> toLoad = new ArrayList<>(); for (String resource : resources) { URL url;/* ww w .java 2 s. co m*/ try { url = Utils.resolveResourceURL(getClass(), resource); } catch (Exception e) { throw new MojoExecutionException( String.format("An error has occurred while resolving resource: %s", resource), e); } if (url == null) { throw new MojoExecutionException(String.format("Cannot resolve resource: %s", resource)); } toLoad.add(url); } try (Model model = new ModelImpl(database.getCreate())) { model.create().transaction(c -> { for (URL url : toLoad) { try { try (InputStream is = url.openStream()) { getLog().info(String.format("Loading dsl from: %s", url.toExternalForm())); try { JsonImporter.manifest(is, model); } catch (IllegalStateException e) { getLog().warn(String.format("Could not load : %s", e.getMessage())); } } } catch (IOException e) { throw new MojoExecutionException( String.format("An error has occurred while creating workspace from resource: %s", url.toExternalForm()), e); } } }); } catch (IOException | SQLException e) { throw new MojoExecutionException( "An error has occurred while initilizing the required SQL infrastructure", e); } }
From source file:com.chiralbehaviors.CoRE.workspace.plugin.WorkspaceSnapshotGenerator.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("Generating workspace snapshots from database state "); try (DSLContext create = database.getCreate()) { for (Export export : exports) { UUID uuid = WorkspaceAccessor.uuidOf(export.iri); getLog().warn(String.format("Processing workspace: %s:%s", uuid, export.iri)); try (Model model = new ModelImpl(create)) { WorkspaceScope scope = model.getWorkspaceModel().getScoped(uuid); if (scope == null) { getLog().warn("Could not find workspace"); continue; }//from w w w. j a va 2 s. c o m getLog().warn(String.format("Serializing workspace: %s to:%s", uuid, export.output)); try (FileOutputStream os = new FileOutputStream(export.output)) { scope.getWorkspace().getSnapshot().serializeTo(os); } catch (IOException e) { throw new MojoFailureException("An error occurred while serializing the workspace", e); } } catch (DataAccessException e) { throw new MojoFailureException("An error occurred while serializing the workspace", e); } } } catch (IOException | SQLException e) { throw new MojoExecutionException( "An error has occurred while initilizing the required DB infrastructure", e); } }
From source file:com.chiralbehaviors.CoRE.workspace.plugin.WorkspaceSnapshotLoader.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { getLog().info("loading workspace snapshots resources "); List<URL> toLoad = new ArrayList<>(); for (String resource : resources) { URL url;/*from w w w .j a v a 2s. com*/ try { url = Utils.resolveResourceURL(getClass(), resource); } catch (Exception e) { throw new MojoExecutionException( String.format("An error has occurred while resolving resource: %s", resource), e); } if (url == null) { throw new MojoExecutionException(String.format("Cannot resolve resource: %s", resource)); } toLoad.add(url); } try (DSLContext create = database.getCreate()) { create.transaction(c -> { WorkspaceSnapshot.load(create, toLoad); }); } catch (DataAccessException | IOException | SQLException e) { throw new MojoExecutionException("An error has occurred while loading snapshots", e); } }