if ( contentGraphicList == null || contentGraphicList.isEmpty() ) getLog().warn( "There are no images in " + dir.getAbsolutePath() + "/" + imageType ); return ; try getLog().info( "Deleting the old " + imageType ); getLog().error( message ); throw new MojoFailureException( message ); getLog().error( e.getMessage(), e ); throw new MojoExecutionException( e.getMessage(), e );
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (mainClass == null) { throw new MojoExecutionException("main class not configured"); } try (URLClassLoader loader = new Classpath(mavenProject).toClassLoader()) { Path srcdir = new File(mavenProject.getBuild().getSourceDirectory()).toPath(); Path bindir = new File(mavenProject.getBuild().getOutputDirectory()).toPath(); getLog().debug("Using classloader " + loader); getLog().debug(" source: " + srcdir); getLog().debug(" bin: " + bindir); Path output = new ApiParser(srcdir) .with(loader) .export(bindir, mainClass); getLog().info("API file: " + output); } catch (Exception x) { throw new MojoFailureException("ApiTool resulted in exception: ", x); } } }
if(this.project.getArtifact().getFile() == null){ File f = new File(this.project.getBuild().getDirectory(), this.project.getBuild().getFinalName() +".gem"); if (f.exists()) { this.project.getArtifact().setFile(f); if (this.gem == null && this.project.getArtifact() != null && this.project.getArtifact().getFile() != null && this.project.getArtifact().getFile().exists()) { final GemArtifact gemArtifact = new GemArtifact(this.project); throw new MojoExecutionException("not a gem artifact"); throw new MojoFailureException("more than one gem file found, use -Dgem=... to specifiy one"); getLog().info("use gem: " + this.gem); script.addArg(this.gem);
getLog().warn( "No Archetype IT projects: root 'projects' directory not found." ); File archetypeFile = project.getArtifact().getFile(); throw new MojoFailureException( "Unable to get the archetypes' artifact which should have just been built:" + " you probably launched 'mvn archetype:integration-test' instead of" + " 'mvn integration-test'." ); getLog().warn( "No Archetype IT projects: no directory with goal.txt found." ); if ( !StringUtils.isEmpty( errors ) ) throw new MojoExecutionException( errors ); throw new MojoFailureException( ex, ex.getMessage(), ex.getMessage() );
appcp.addAll(resources(mavenProject.getResources())); Set<Artifact> artifacts = new LinkedHashSet<Artifact>(mavenProject.getArtifacts()); if (!"pom".equals(artifact.getType())) { appcp.add(new File(artifact.getFile().getAbsolutePath())); watchDirs.add(mavenProject.getBasedir()); watchDirs.addAll(refbasedir); if (this.watchDirs != null) { cmd.setWorkdir(mavenProject.getBasedir()); getLog().debug("cmd: " + cmd.debug()); getLog().debug("Starting process: " + cmd.debug()); cmd.execute(); } catch (Exception ex) { throw new MojoFailureException("Execution of " + cmd + " resulted in error", ex);
getLog().info( "Skipping RSL creation" ); return; getLog().debug( "project.getPackaging = " + packaging ); if ( project.getArtifact().getFile() == null ) getLog().warn( "Skipping RSL creator, no SWC attached to this project." ); return; throw new MojoExecutionException( e.getMessage(), e ); throw new MojoFailureException( "Got " + result + " errors building project, check logs" );
versionRange = VersionRange.createFromVersionSpec(mavenParameters.getVersionRangeWithProjectVersion()); } catch (InvalidVersionSpecificationException e) { throw new MojoFailureException("Invalid version versionRange: " + e.getMessage(), e); previousArtifact = mavenParameters.getArtifactFactory().createDependencyArtifact(project.getGroupId(), project.getArtifactId(), versionRange, project.getPackaging(), null, Artifact.SCOPE_COMPILE); if (!previousArtifact.getVersionRange().isSelectedVersionKnown(previousArtifact)) { getLog().debug("Searching for versions in versionRange: " + previousArtifact.getVersionRange()); List<ArtifactVersion> availableVersions = mavenParameters.getMetadataSource().retrieveAvailableVersions(previousArtifact, mavenParameters.getLocalRepository(), project.getRemoteArtifactRepositories()); filterSnapshots(availableVersions); ArtifactVersion version = versionRange.matchVersion(availableVersions); if (version != null) { previousArtifact.selectVersion(version.toString()); throw new MojoFailureException("Invalid comparison version: " + e.getMessage(), e); } catch (ArtifactMetadataRetrievalException e) { throw new MojoExecutionException("Error determining previous version: " + e.getMessage(), e); if (previousArtifact.getVersion() == null) { getLog().info("Unable to find a previous version of the project in the repository.");
private boolean detectJavaBootClasspath( String javaExecutable ) throws MojoFailureException, MojoExecutionException getLog().info( "Attempting to auto-detect the boot classpath for " + javaExecutable ); Iterator<Artifact> i = pluginArtifacts.iterator(); Artifact javaBootClasspathDetector = null; if ( StringUtils.equals( jbcpdGroupId, candidate.getGroupId() ) && StringUtils.equals( jbcpdArtifactId, candidate.getArtifactId() ) && candidate.getFile() != null && candidate.getFile().isFile() ) getLog().warn( "Skipping signature generation as could not find boot classpath detector (" + ArtifactUtils.versionlessKey( jbcpdGroupId, jbcpdArtifactId ) + ")." ); return false; throw new MojoFailureException( "Could not find boot classpath detector (" + ArtifactUtils.versionlessKey( jbcpdGroupId, jbcpdArtifactId ) + ")." ); throw new MojoExecutionException( e.getLocalizedMessage(), e );
protected Model modelFromNativePom(Log log) throws MojoExecutionException, MojoFailureException { Map<String, ModelSource> options = new HashMap<String, ModelSource>(); options.put(ModelProcessor.SOURCE, new FileModelSource(nativePom)); assert modelManager != null; try { ModelReader reader = modelManager.getReaderFor(options); if (reader == null) { throw new MojoExecutionException("no model reader found for " + nativePom); } if (log.isDebugEnabled()) { log.debug("Parsing native pom " + nativePom); } return reader.read(nativePom, options); } catch (IOException e) { throw new MojoFailureException("error parsing " + nativePom, e); } } }
public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "Skipping OpenAPI specification resolution" ); return; getLog().info( "Resolving OpenAPI specification.." ); if (StringUtils.isBlank(encoding)) { encoding = projectEncoding; openAPIInput = Yaml.mapper().readValue(openapiFileContent, OpenAPI.class); } catch (Exception e1) { getLog().error( "Error reading/deserializing openapi file" , e); throw new MojoFailureException(e.getMessage(), e); getLog().error( "Error reading/deserializing openapi file" , e); throw new MojoFailureException(e.getMessage(), e); getLog().error( "Error resolving API specification" , e); throw new MojoFailureException(e.getMessage(), e); } catch (IOException e) { getLog().error( "Error writing API specification" , e); throw new MojoExecutionException("Failed to write API definition", e); } catch (Exception e) { getLog().error( "Error resolving API specification" , e); throw new MojoExecutionException(e.getMessage(), e);
public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Skipping access modifier checks"); return; File outputDir = new File(project.getBuild().getOutputDirectory()); for (Artifact a : (Collection<Artifact>)project.getArtifacts()) dependencies.add(a.getFile().toURI().toURL()); URL outputURL = outputDir.toURI().toURL(); dependencies.add(outputURL); String message = "Access modifier checks failed. See the details above"; if (failOnError) { throw new MojoFailureException(message); } else { getLog().warn(message); throw new MojoExecutionException("Failed to enforce @Restricted constraints",e);
getLog().info( deviceLogLinePrefix + "Running tests for specified test package: " + str ); getLog().info( deviceLogLinePrefix + "Running tests for specified test classes/methods: " + parsedClasses ); getLog().info( deviceLogLinePrefix + "Running instrumentation tests in " + parsedInstrumentationPackage ); try if ( testRunListener.hasFailuresOrErrors() && !testFailSafe ) throw new MojoFailureException( deviceLogLinePrefix + "Tests failed on device." ); throw new MojoFailureException( deviceLogLinePrefix + "Test run failed to complete: " + testRunListener.getTestRunFailureCause() ); throw new MojoFailureException( deviceLogLinePrefix + testRunListener.getExceptionMessages() ); throw new MojoExecutionException( deviceLogLinePrefix + "timeout", e ); throw new MojoExecutionException( deviceLogLinePrefix + "adb command rejected", e ); throw new MojoExecutionException( deviceLogLinePrefix + "shell command " + "unresponsive", e );
private ClassFinder createFinder(String classloaderType) throws Exception { ClassFinder finder; if ("project".equals(classloaderType)) { List<URL> urls = new ArrayList<>(); urls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL()); for (Artifact artifact : project.getArtifacts()) { if (artifactInclude != null && artifactInclude.length() > 0 && artifact.getArtifactId().matches(artifactInclude)) { File file = artifact.getFile(); if (file != null) { getLog().debug("Use artifact " + artifact.getArtifactId() + ": " + file); urls.add(file.toURI().toURL()); } } else { getLog().debug("Ignore artifact " + artifact.getArtifactId()); } } ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader()); finder = new ClassFinder(loader, urls); } else if ("plugin".equals(classLoader)) { finder = new ClassFinder(getClass().getClassLoader()); } else { throw new MojoFailureException("classLoader attribute must be 'project' or 'plugin'"); } return finder; }
public void execute() throws MojoExecutionException, MojoFailureException { if (project.getPackaging().equalsIgnoreCase("pom")) { String errorMsg = "[ERROR] This plugin cannot be run from a pom project, please run it from a jar or war project (i.e. core or web)."; throw new MojoFailureException(errorMsg); throw new MojoExecutionException("You must specify an entity name to continue."); if (project.getPackaging().equals("war") && (project.hasParent() && !project.getParentArtifact().getGroupId().contains("appfuse"))) { String moduleName = (String) project.getParent().getModules().get(0); getLog().error("[ERROR] No <dao.framework> property found in pom.xml. Please add this property.");
/** * Will copy the specified artifact into the output directory. * @param artifact The artifact already resolved to be copied. * @throws MojoFailureException If an error hapen while copying the file. */ private void copyFileToDirectory(org.apache.maven.artifact.Artifact artifact) throws MojoFailureException { File toCopy = artifact.getFile(); if (toCopy != null && toCopy.exists() && toCopy.isFile()) { try { getLog().info("Copying file " + toCopy.getName() + " to directory " + outputDirectory); File outputFile = null; if (this.outputFileName == null) { outputFile = new File(outputDirectory, toCopy.getName()); } else { outputFile = new File(outputDirectory, this.outputFileName); } Files.copy(toCopy.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { getLog().debug("Error while copying file", e); throw new MojoFailureException("Error copying the file : " + e.getMessage()); } } else { throw new MojoFailureException("Artifact file not present : " + toCopy); } }
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (project == null) { throw new MojoExecutionException("This plugin can only be used inside a project."); throw new MojoFailureException("can not write to output dir: " + outputPath); throw new MojoFailureException("templates not found in dir: " + outputPath); project.addCompileSourceRoot(outputPath); break; case "test": project.addTestCompileSourceRoot(outputPath); break; default: throw new MojoFailureException("scope must be compile or test"); getLog().info(format("Freemarker generation:\n scope: %s,\n config: %s,\n templates: %s", scope, config.getAbsolutePath(), templatesPath)); final File tmp = Files.createTempDirectory("freemarker-tmp").toFile(); getLog().info("Adding maven data loader"); settings.setEngineAttribute(MavenDataLoader.MAVEN_DATA_ATTRIBUTE, new MavenData(project)); settings.add(Settings.NAME_DATA, format("maven: %s()", MavenDataLoader.class.getName())); throw new MojoFailureException(MiscUtil.causeMessages(e), e);
@Override public String assureInputFromUser(String attribute, String defaultValue, String regex, String errorMessage, String prompt) throws MojoFailureException { final String initValue = System.getProperty(attribute); final String input = StringUtils.isNotEmpty(initValue) ? initValue : defaultValue; if (StringUtils.isNotEmpty(input) && validateInputByRegex(input, regex)) { log.info(String.format("Use %s for %s", input, attribute)); return input; } else { throw new MojoFailureException(String.format("Invalid input for %s : %s", attribute, input)); } }
parsedVersionName = project.getVersion(); getLog().info( "Setting " + ATTR_VERSION_NAME + " to " + parsedVersionName ); manifestElement.setAttribute( ATTR_VERSION_NAME, parsedVersionName ); dirty = true; || ( parsedVersionCodeAutoIncrement && parsedVersionCodeUpdateFromVersion ) ) throw new MojoFailureException( "versionCodeAutoIncrement, versionCodeUpdateFromVersion and versionCode " + "are mutual exclusive. They cannot be specified at the same time. Please specify either " + "versionCodeAutoIncrement, versionCodeUpdateFromVersion or versionCode!" ); getLog().info( "Setting " + ATTR_VERSION_CODE + " to " + parsedVersionCode ); manifestElement.setAttribute( ATTR_VERSION_CODE, String.valueOf( parsedVersionCode ) ); dirty = true; project.getProperties().setProperty( "android.manifest.versionCode", String.valueOf( parsedVersionCode ) ); project.getProperties() .setProperty( "android.manifest.applicationIcon", String.valueOf( parsedApplicationIcon ) ); .equals( parsedSharedUserId, sharedUserIdAttrib.getValue() ) ) getLog().info( "Setting " + ATTR_SHARED_USER_ID + " to " + parsedSharedUserId ); manifestElement.setAttribute( ATTR_SHARED_USER_ID, parsedSharedUserId ); dirty = true;
@Override public void execute() throws MojoExecutionException, MojoFailureException { String groupId = project.getGroupId(); String developerConnection = project.getScm().getDeveloperConnection(); if (!developerConnection.startsWith(SCM_PREFIX)) { throw new MojoFailureException("Unexpected developer connection: " + developerConnection); } String repoUrl = developerConnection.substring(SCM_PREFIX.length()); File directory = new File(project.getBuild().getDirectory() + "/osstrich"); JavadocPublisher javadocPublisher = new JavadocPublisher(new MavenCentral(), new Cli(), getLog(), directory); try { int artifactsPublished = javadocPublisher.publishLatest(repoUrl, groupId); getLog().info("Published Javadoc for " + artifactsPublished + " artifacts of " + groupId + " to " + repoUrl); } catch (IOException e) { throw new MojoExecutionException( "Failed to publish Javadoc of " + groupId + " to " + repoUrl, e); } } }
@SuppressWarnings("unchecked") private void validateDependencyVersions() throws MojoExecutionException, MojoFailureException { getLog().info(Messages.CompileMojo_7); final String sarlSdkGroupId = this.mavenHelper.getConfig("sarl-sdk.groupId"); //$NON-NLS-1$ final String sarlSdkArtifactId = this.mavenHelper.getConfig("sarl-sdk.artifactId"); //$NON-NLS-1$ final Map<String, Artifact> artifacts = this.mavenHelper.getSession().getCurrentProject().getArtifactMap(); final String sdkArtifactKey = ArtifactUtils.versionlessKey(sarlSdkGroupId, sarlSdkArtifactId); final Artifact sdkArtifact = artifacts.get(sdkArtifactKey); final Set<Artifact> dependencies = this.mavenHelper.resolveDependencies(sdkArtifactKey, false); for (final Artifact dependency : dependencies) { final ArtifactVersion dependencyVersion = new DefaultArtifactVersion(dependency.getVersion()); final String dependencyKey = ArtifactUtils.versionlessKey(dependency); final ArtifactVersion currentVersion = versions.get(dependencyKey); final Artifact dependencyArtifact = artifacts.get(entry.getKey()); if (dependencyArtifact != null) { final ArtifactVersion dependencyVersion = new DefaultArtifactVersion(dependencyArtifact.getVersion()); if (entry.getValue().compareTo(dependencyVersion) > 0) { final String message = MessageFormat.format(Messages.CompileMojo_8, dependencyArtifact.getGroupId(), dependencyArtifact.getArtifactId(), dependencyArtifact.getVersion(), entry.getValue().toString()); getLog().error(message); hasError = true; throw new MojoFailureException(Messages.CompileMojo_10);