本文整理了Java中org.apache.maven.plugin.MojoExecutionException
类的一些代码示例,展示了MojoExecutionException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MojoExecutionException
类的具体详情如下:
包路径:org.apache.maven.plugin.MojoExecutionException
类名称:MojoExecutionException
[英]An exception occurring during the execution of a plugin.
Throwing this exception causes a "BUILD ERROR" message to be displayed.
[中]插件执行期间发生的异常。
引发此异常会导致显示“生成错误”消息。
代码示例来源:origin: apache/usergrid
initCertStore();
Properties props = new Properties();
try {
File extractedConfigPropFile = new File( getExtractedRunnerPath(), PROJECT_FILE );
FileInputStream inputStream = new FileInputStream( extractedConfigPropFile );
props.load( inputStream );
inputStream.close();
throw new MojoExecutionException( e.getMessage() );
WebResource resource = client.resource( endpoint ).path( "/status" );
LOG.info( "Commit ID: {}", props.getProperty( Project.GIT_UUID_KEY ) );
LOG.info( "Artifact Id: {}", props.getProperty( Project.ARTIFACT_ID_KEY ) );
LOG.info( "Group Id: {}", props.getProperty( Project.GROUP_ID_KEY ) );
LOG.error( "Error Message: {}", resp.getEntity( String.class ) );
throw new MojoExecutionException( "Status plugin goal has failed" );
代码示例来源:origin: jeremylong/DependencyCheck
/**
* Generates the Dependency-Check Site Report.
*
* @param sink the sink to write the report to
* @param locale the locale to use when generating the report
* @throws MavenReportException if a maven report exception occurs
*/
public void generate(Sink sink, Locale locale) throws MavenReportException {
final boolean shouldSkip = Boolean.parseBoolean(System.getProperty("dependency-check.skip", Boolean.toString(skip)));
if (shouldSkip) {
getLog().info("Skipping report generation " + getName(Locale.US));
return;
}
generatingSite = true;
try {
validateAggregate();
} catch (MojoExecutionException ex) {
throw new MavenReportException(ex.getMessage());
}
project.setContextValue(getOutputDirectoryContextKey(), getReportOutputDirectory());
try {
runCheck();
} catch (MojoExecutionException ex) {
throw new MavenReportException(ex.getMessage(), ex);
} catch (MojoFailureException ex) {
getLog().warn("Vulnerabilities were identifies that exceed the CVSS threshold for failing the build");
}
}
代码示例来源:origin: apache/avro
private Document build()
throws MojoExecutionException
getLog().debug( "load plugin-help.xml: " + PLUGIN_HELP_PATH );
InputStream is = null;
try
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return dBuilder.parse( is );
throw new MojoExecutionException( e.getMessage(), e );
throw new MojoExecutionException( e.getMessage(), e );
throw new MojoExecutionException( e.getMessage(), e );
throw new MojoExecutionException( e.getMessage(), e );
代码示例来源:origin: bytedeco/javacpp
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
log.debug("classPaths: " + Arrays.deepToString(classPaths));
log.debug("buildPath: " + buildPath);
log.debug("buildPaths: " + Arrays.deepToString(buildPaths));
project.addCompileSourceRoot(targetDirectory);
v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s);
properties.setProperty("platform.artifacts", project.getBuild().getOutputDirectory());
for (Artifact a : plugin.getArtifacts()) {
String s = a.getFile().getCanonicalPath();
String v = properties.getProperty("platform.artifacts", "");
properties.setProperty("platform.artifacts",
v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s);
Properties projectProperties = project.getProperties();
for (String key : properties.stringPropertyNames()) {
projectProperties.setProperty("javacpp." + key, properties.getProperty(key));
log.error("Failed to execute JavaCPP Builder: " + e.getMessage());
throw new MojoExecutionException("Failed to execute JavaCPP Builder", e);
代码示例来源:origin: apache/usergrid
throw new MojoExecutionException( "Failed to generate the project.properties." );
Properties props = new Properties();
props.load( new FileInputStream( projectFile ) );
ProjectBuilder builder = new ProjectBuilder( props );
project = builder.getProject();
throw new MojoExecutionException(
"Cannot access local file system based project information: " + getProjectFileToUploadPath(), e );
代码示例来源:origin: simpligility/android-maven-plugin
getLog().debug( "copyManifest: " + androidManifestFile + " -> " + destinationManifestFile );
if ( androidManifestFile == null )
getLog().debug( "Manifest copying disabled. Using default manifest only" );
return;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse( androidManifestFile );
Source source = new DOMSource( doc );
getLog().info( "Manifest copied from " + androidManifestFile + " to " + destinationManifestFile );
getLog().error( "Error during copyManifest" );
throw new MojoExecutionException( "Error during copyManifest", e );
代码示例来源:origin: rapidoid/rapidoid
protected void invokeInstalled(MavenSession session, List<String> goals, boolean updateSnapshots, Map<String, String> properties) throws MojoExecutionException {
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(session.getRequest().getPom());
request.setGoals(goals);
request.setAlsoMake(true);
request.setUpdateSnapshots(updateSnapshots);
Properties props = new Properties();
props.putAll(properties);
request.setProperties(props);
Invoker invoker = new DefaultInvoker();
boolean success;
try {
InvocationResult result = invoker.execute(request);
success = result.getExitCode() == 0 && result.getExecutionException() == null;
} catch (MavenInvocationException e) {
throw new MojoExecutionException("Invocation error! " + ABORT, e);
}
failIf(!success, "An error occurred. " + ABORT);
}
代码示例来源:origin: fabric8io/docker-maven-plugin
private AuthConfig getAuthConfigFromSystemProperties(LookupMode lookupMode) throws MojoExecutionException {
Properties props = System.getProperties();
String userKey = lookupMode.asSysProperty(AUTH_USERNAME);
String passwordKey = lookupMode.asSysProperty(AUTH_PASSWORD);
if (props.containsKey(userKey)) {
if (!props.containsKey(passwordKey)) {
throw new MojoExecutionException("No " + passwordKey + " provided for username " + props.getProperty(userKey));
}
return new AuthConfig(props.getProperty(userKey),
decrypt(props.getProperty(passwordKey)),
props.getProperty(lookupMode.asSysProperty(AUTH_EMAIL)),
props.getProperty(lookupMode.asSysProperty(AUTH_AUTHTOKEN)));
} else {
return null;
}
}
代码示例来源:origin: swagger-api/swagger-core
public void execute() throws MojoExecutionException, MojoFailureException
getLog().info( "Skipping OpenAPI specification resolution" );
return;
getLog().info( "Resolving OpenAPI specification.." );
String pEnc = project.getProperties().getProperty("project.build.sourceEncoding");
if (StringUtils.isNotBlank(pEnc)) {
projectEncoding = pEnc;
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);
代码示例来源:origin: org.apache.felix/maven-bundle-plugin
/**
* Initialize the document builder from Xerces.
*
* @return DocumentBuilder ready to create new document
* @throws MojoExecutionException : occurs when the instantiation of the document builder fails
*/
private DocumentBuilder initConstructor() throws MojoExecutionException
{
DocumentBuilder constructor = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try
{
constructor = factory.newDocumentBuilder();
}
catch ( ParserConfigurationException e )
{
getLog().error( "Unable to create a new xml document" );
throw new MojoExecutionException( "Cannot create the Document Builder : " + e.getMessage() );
}
return constructor;
}
代码示例来源:origin: apache/storm
@Override
public void execute() throws MojoExecutionException {
try {
SCM scm = determineSCM();
project.getProperties().setProperty(buildTimeProperty, getBuildTime());
project.getProperties().setProperty(scmUriProperty, getSCMUri(scm));
project.getProperties().setProperty(scmBranchProperty, getSCMBranch(scm));
project.getProperties().setProperty(scmCommitProperty, getSCMCommit(scm));
project.getProperties().setProperty(md5Property, computeMD5());
} catch (Throwable ex) {
throw new MojoExecutionException(ex.toString(), ex);
}
}
代码示例来源:origin: simpligility/android-maven-plugin
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 );
代码示例来源:origin: vipshop/Saturn
@SuppressWarnings({ "unchecked" })
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!CommonUtils.initSaturnHome())
throw new MojoExecutionException("The ${user.home}/.saturn/caches is not exists");
Log log = getLog();
MavenProject project = (MavenProject) getPluginContext().get("project");
String version = getSaturnVersion(project);
log.info("Packing the saturn job into a zip file: version:" + version);
List<File> runtimeLibFiles = new ArrayList<File>();
List<Artifact> runtimeArtifacts = project.getRuntimeArtifacts();
for (Artifact artifact : runtimeArtifacts) {
runtimeLibFiles.add(artifact.getFile());
}
runtimeLibFiles.add(new File(project.getBuild().getDirectory(),
project.getBuild().getFinalName() + "." + project.getPackaging()));
File zipFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-" + "app.zip");
try {
CommonUtils.zip(runtimeLibFiles, null, zipFile);
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("zip " + zipFile + " failed", e);
}
projectHelper.attachArtifact(project, "zip", "executor", zipFile);
}
代码示例来源:origin: jeremylong/DependencyCheck
outputDir = new File(this.getProject().getBuild().getDirectory());
engine.writeReports(p.getName(), p.getGroupId(), p.getArtifactId(), p.getVersion(), outputDir, getFormat());
} catch (ReportException ex) {
if (exCol == null) {
throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol);
} else {
getLog().debug("Error writing the report", ex);
checkForFailure(engine.getDependencies());
if (exCol != null && this.isFailOnError()) {
throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol);
if (getLog().isDebugEnabled()) {
getLog().debug("Database connection error", ex);
throw new MojoExecutionException(msg, ex);
getLog().error(msg, ex);
代码示例来源:origin: speedment/speedment
@Override
protected void execute(Speedment speedment) throws MojoExecutionException, MojoFailureException {
getLog().info("Saving default configuration from database to '" + configLocation().toAbsolutePath() + "'.");
final ConfigFileHelper helper = speedment.getOrThrow(ConfigFileHelper.class);
try {
helper.setCurrentlyOpenFile(configLocation().toFile());
helper.loadFromDatabaseAndSaveToFile();
} catch (final Exception ex) {
final String err = "An error occured while reloading.";
getLog().error(err);
throw new MojoExecutionException(err, ex);
}
}
代码示例来源:origin: jooby-project/jooby
@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);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
try {
urls.add( file.toURI().toURL() );
getLog().debug( "Adding classpath entry for classes root " + file.getAbsolutePath() );
throw new MojoExecutionException( msg, e );
getLog().warn( msg );
Set<Artifact> artifacts = project.getArtifacts();
if ( artifacts != null) {
for ( Artifact a : artifacts ) {
if ( !Artifact.SCOPE_TEST.equals( a.getScope() ) ) {
try {
urls.add( a.getFile().toURI().toURL() );
getLog().debug( "Adding classpath entry for dependency " + a.getId() );
String msg = "Unable to resolve URL for dependency " + a.getId() + " at " + a.getFile().getAbsolutePath();
if ( failOnError ) {
throw new MojoExecutionException( msg, e );
getLog().warn( msg );
代码示例来源:origin: streamsets/datacollector
ClassLoader projectCL = getProjectClassLoader();
if (usesDataCollectorAPI(projectCL)) {
File file = new File(project.getBuild().getOutputDirectory(), BUNDLES_TO_GEN_FILE);
if (file.exists() && file.isFile()) {
Map<String, File> bundles = new HashMap<>();
bundles.put(bundleName, bundleFile);
File jarFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-bundles.jar");
getLog().info("Building bundles jar: " + jarFile.getAbsolutePath());
createBundlesJar(jarFile, bundles);
} else {
getLog().debug(BUNDLES_TO_GEN_FILE + "' file does not have any class, no bundles jar will be generated");
getLog().debug("Project does not have '" + BUNDLES_TO_GEN_FILE + "' file, no bundles jar will be generated");
throw new MojoExecutionException(ex.toString(), ex);
代码示例来源:origin: simpligility/android-maven-plugin
private void generateR() throws MojoExecutionException
getLog().info( "Generating R file for " + project.getArtifact() );
.makeResourcesNonConstant( AAR.equals( project.getArtifact().getType() ) )
.addExtraArguments( aaptExtraArgs );
getLog().debug( getAndroidSdk().getAaptPath() + " " + commandBuilder.toString() );
try
executor.setCaptureStdOut( true );
final List<String> commands = commandBuilder.build();
executor.executeCommand( getAndroidSdk().getAaptPath(), commands, project.getBasedir(), false );
throw new MojoExecutionException( "", e );
generateCorrectRJavaForAarDependencies( resGenerator );
getLog().info( "Adding R gen folder to compile classpath: " + genDirectory );
project.addCompileSourceRoot( genDirectory.getAbsolutePath() );
代码示例来源:origin: rapidoid/rapidoid
if (!deleted) getLog().warn("Couldn't delete the temporary assembly descriptor file!");
List<String> appJars = IO.find("*-uber-jar.jar").in(project.getBuild().getDirectory()).getNames();
uberJar = appJar.toFile().getAbsolutePath();
} catch (IOException e) {
throw new MojoExecutionException("Couldn't rename the file! " + ABORT, e);
getLog().info("");
getLog().info("The main class is: " + mainClass);
throw new MojoExecutionException("Couldn't add the JAR manifest! " + ABORT, e);
内容来源于网络,如有侵权,请联系作者删除!