List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException
public MojoExecutionException(String message)
MojoExecutionException
exception providing a message
. From source file:be.rubus.angularprime.build.maven.AngularDirectiveMojo.java
License:Apache License
private CompilationLevel getCompilationLevel(final String compilationLevel) throws MojoExecutionException { try {/*from ww w . ja v a 2 s. co m*/ return CompilationLevel.valueOf(compilationLevel); } catch (Exception e) { final String errMsg = "Compilation level '" + compilationLevel + "' is wrong. Valid constants are: " + "'WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS', 'ADVANCED_OPTIMIZATIONS'"; throw new MojoExecutionException(errMsg); } }
From source file:be.rubus.angularprime.build.maven.AngularDirectiveMojo.java
License:Apache License
private WarningLevel getWarningLevel(final String warningLevel) throws MojoExecutionException { try {//w w w . j a v a 2s . co m return WarningLevel.valueOf(warningLevel); } catch (Exception e) { final String errMsg = "Warning level '" + warningLevel + "' is wrong. Valid constants are: 'QUIET', " + "'DEFAULT', 'VERBOSE'"; throw new MojoExecutionException(errMsg); } }
From source file:biz.gabrys.maven.plugins.css.splitter.SplitMojo.java
License:Open Source License
private void validateParameters() throws MojoExecutionException { if (cacheTokenValue == null && TokenType.CUSTOM.name().equalsIgnoreCase(cacheTokenType)) { throw new MojoExecutionException( "Parameter cacheTokenValue is required when cacheTokenType is equal to \"custom\"!"); }/*from w w w . j a va 2 s. c om*/ }
From source file:biz.neustar.webmetrics.plugins.neustar_s3_maven_plugin.S3UploadMojo.java
License:Apache License
/** */ public void execute() throws MojoExecutionException { getLog().debug("accessKey: " + accessKey); getLog().debug("secretKey: " + secretKey); // getLog().debug("bucketName: " + bucketName); if ((files == null) || (files.isEmpty())) { throw new MojoExecutionException("No files configured to upload!"); }/*from ww w. ja v a 2s . com*/ if ((buckets == null) || (buckets.isEmpty())) { throw new MojoExecutionException("No buckets configured to upload files to!"); } AmazonS3 s3 = getS3Client(accessKey, secretKey); for (String bucket : buckets) { for (UploadFile uf : files) { File source = new File(uf.getSource()); if (!source.exists()) { throw new MojoExecutionException( "File/folder '" + source.getAbsolutePath() + "' doesn't exist."); } if (!doNotUpload) { // Upload the source File to the S3 bucket. boolean success = upload(s3, bucket, source, uf.getTarget()); if (!success) { if (failOnError) { throw new MojoExecutionException("S3 file upload failed!"); } } } else { getLog().debug("File " + source.getAbsolutePath() + " would have been uploaded to " + bucket + "/" + uf.getTarget()); } } } }
From source file:biz.paluch.maven.configurator.ConfigureFileMojo.java
License:Open Source License
/** * Perform configuration an arbitrary, external file. * * @throws org.apache.maven.plugin.MojoExecutionException * @throws org.apache.maven.plugin.MojoFailureException */// ww w . j av a 2s . c o m @Override public void execute() throws MojoExecutionException, MojoFailureException { if (file == null) { throw new MojoExecutionException("file must not be null"); } if (!file.exists()) { throw new MojoExecutionException("File " + file + " does not exist"); } if (!file.isFile()) { throw new MojoExecutionException("File " + file + " must be a file"); } configure(file); }
From source file:biz.paluch.maven.configurator.ConfigureMojo.java
License:Open Source License
private PackageType resolvePackageType(String packaging) throws MojoExecutionException { for (PackageType packagingType : PackageType.values()) { if (packagingType.getPackaging().equalsIgnoreCase(packaging)) { return packagingType; }/*from w w w .ja va 2 s. c om*/ } throw new MojoExecutionException("Cannot process packaging type " + packaging); }
From source file:biz.vidal.maven.plugins.uberjar.UberjarMojo.java
License:Apache License
private void checkArtifact(ArtifactModel artifact, String name) throws MojoExecutionException { if (artifact.getGroupId() == null || artifact.getArtifactId() == null || artifact.getVersion() == null) { throw new MojoExecutionException(name + " requires artifactId, groupId and version"); }//from w w w. j a v a2 s . c om }
From source file:br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo.java
License:Apache License
protected void handleNonSingle(int len) throws MojoExecutionException { if (0 == len) { throw new MojoExecutionException("No environments found"); } else {// w w w.java 2 s . c om throw new MojoExecutionException( "Multiple environments found matching the supplied parameters (may you file a bug report?)"); } }
From source file:br.com.ingenieux.mojo.beanstalk.cmd.env.waitfor.WaitForEnvironmentCommand.java
License:Apache License
public EnvironmentDescription executeInternal(WaitForEnvironmentContext context) throws Exception { // Those are invariants long timeoutMins = context.getTimeoutMins(); Date expiresAt = new Date(System.currentTimeMillis() + MINS_TO_MSEC * timeoutMins); Date lastMessageRecord = new Date(); info("Environment Lookup"); List<Predicate<EnvironmentDescription>> envPredicates = getEnvironmentDescriptionPredicate(context); Predicate<EnvironmentDescription> corePredicate = envPredicates.get(0); Predicate<EnvironmentDescription> fullPredicate = Predicates.and(envPredicates); do {/* w w w . ja v a 2s. co m*/ DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest() .withApplicationName(context.getApplicationName()).withIncludeDeleted(true); final List<EnvironmentDescription> envs = parentMojo.getService().describeEnvironments(req) .getEnvironments(); Collection<EnvironmentDescription> validEnvironments = Collections2.filter(envs, fullPredicate); debug("There are %d environments", validEnvironments.size()); if (1 == validEnvironments.size()) { EnvironmentDescription foundEnvironment = validEnvironments.iterator().next(); debug("Found environment %s", foundEnvironment); return foundEnvironment; } else { debug("Found %d environments. No good. Ignoring.", validEnvironments.size()); for (EnvironmentDescription d : validEnvironments) { debug(" ... %s", d); } // ... but have we've got any closer match? If so, dump recent events Collection<EnvironmentDescription> foundEnvironments = Collections2.filter(envs, corePredicate); if (1 == foundEnvironments.size()) { EnvironmentDescription foundEnvironment = foundEnvironments.iterator().next(); DescribeEventsResult events = service.describeEvents( new DescribeEventsRequest().withApplicationName(foundEnvironment.getApplicationName()) .withStartTime(new Date(1000 + lastMessageRecord.getTime())) .withEnvironmentId(foundEnvironment.getEnvironmentId()).withSeverity("TRACE")); Set<EventDescription> eventList = new TreeSet<EventDescription>( new EventDescriptionComparator()); eventList.addAll(events.getEvents()); for (EventDescription d : eventList) { info(String.format("%s %s %s", d.getSeverity(), d.getEventDate(), d.getMessage())); if (d.getSeverity().equals(("ERROR"))) { throw new MojoExecutionException( "Something went wrong in while waiting for the environment setup to complete : " + d.getMessage()); } lastMessageRecord = d.getEventDate(); } } } sleepInterval(POLL_INTERVAL); } while (!timedOutP(expiresAt)); throw new MojoExecutionException("Timed out"); }
From source file:br.com.ingenieux.mojo.jbake.SeedMojo.java
License:Apache License
public void execute() throws MojoExecutionException { if (outputDirectory.exists() && (!force)) throw new MojoExecutionException( format("The outputDirectory %s must *NOT* exist. Invoke with jbake.force as true to disregard", outputDirectory.getName())); try {//from w ww. j a va 2 s . co m URL url = new URL(seedUrl); File tmpZipFile = File.createTempFile("jbake", ".zip"); getLog().info(format("Downloading contents from %s into %s", seedUrl, tmpZipFile)); final FileOutputStream fos = new FileOutputStream(tmpZipFile); int length = IOUtils.copy(url.openStream(), fos); fos.close(); getLog().info(format("%d bytes downloaded. Unpacking into %s", length, outputDirectory)); unpackZip(tmpZipFile); } catch (Exception e) { getLog().info("Oops", e); throw new MojoExecutionException("Failure when running: ", e); } }