本文整理汇总了Java中org.apache.maven.plugin.MojoExecutionException类的典型用法代码示例。如果您正苦于以下问题:Java MojoExecutionException类的具体用法?Java MojoExecutionException怎么用?Java MojoExecutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MojoExecutionException类属于org.apache.maven.plugin包,在下文中一共展示了MojoExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isMarkerOlder
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
public boolean isMarkerOlder( Artifact artifact1 )
throws MojoExecutionException
{
File marker = getMarkerFile();
if ( marker.exists() )
{
long artifactLastModified = artifact1.getFile().lastModified();
long markerLastModified = marker.lastModified();
return artifact1.getFile().lastModified() > marker.lastModified();
}
else
{
// if the marker doesn't exist, we want to copy so assume it is
// infinately older
return true;
}
}
示例2: execute
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
extractTemplatesFromJar();
try {
PublishProvider provider;
switch (publish.getProvider()) {
default:
provider = new ConfluenceProvider(publish.getEndpoint(), publish.getUsername(), publish.getPassword());
}
List<Page> pages = readHtmlPages();
publish(provider, pages);
} catch (Exception e) {
throw new MojoExecutionException("Unexpected error", e);
}
}
示例3: assureLinuxWebApp
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
@Test
public void assureLinuxWebApp() throws Exception {
final SiteInner siteInner = mock(SiteInner.class);
doReturn("app,linux").when(siteInner).kind();
final WebApp app = mock(WebApp.class);
doReturn(siteInner).when(app).inner();
// Linux Web App
WebAppUtils.assureLinuxWebApp(app);
// Non-Linux Web App
doReturn("app").when(siteInner).kind();
MojoExecutionException exception = null;
try {
WebAppUtils.assureLinuxWebApp(app);
} catch (MojoExecutionException e) {
exception = e;
} finally {
assertNotNull(exception);
}
}
示例4: execute
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
public void execute() throws MojoExecutionException {
this.sourcesDirectory = Paths.get(outputDirectory).resolve("generated-sources").resolve("sdk");
this.testsDirectory = Paths.get(outputDirectory).resolve("generated-test-sources").resolve("sdk-tests");
findModelRoots().forEach(p -> {
try {
getLog().info("Loading from: " + p.toString());
generateCode(C2jModels.builder()
.codeGenConfig(loadCodeGenConfig(p))
.customizationConfig(loadCustomizationConfig(p))
.serviceModel(loadServiceModel(p))
.waitersModel(loadWaiterModel(p))
.paginatorsModel(loadPaginatorModel(p))
.examplesModel(loadExamplesModel(p))
.build());
} catch (MojoExecutionException e) {
throw new RuntimeException(e);
}
});
project.addCompileSourceRoot(sourcesDirectory.toFile().getAbsolutePath());
project.addTestCompileSourceRoot(testsDirectory.toFile().getAbsolutePath());
}
示例5: execute
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
MetricFilterPublisher publisher =
dryRun ? new DryRunMetricFilterPublisher(getLog()) : new CloudwatchMetricFilterPublisher(getLog());
// Get a map of fully-namespaced metric names mapped to the metric fields in classes that extend LambdaMetricSet
Map<String, Field> metricFields = new HashMap<>();
try {
metricFields.putAll(new MetricsFinder(project).find());
} catch (DependencyResolutionRequiredException | MalformedURLException e) {
throw new MojoExecutionException("Could not scan classpath for metric fields", e);
}
if (!metricFields.isEmpty()) {
getLog().info(String.format("Found [%d] metric fields in classpath.", metricFields.size()));
int removed = publisher.removeMetricFilters(getMetricFilters(metricFields));
getLog().info(String.format("Removed [%d] metric filters.", removed));
} else {
getLog().warn("Did not find any metric fields in classpath.");
}
}
示例6: extractJar
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
void extractJar(File jar, ManifestTransformer manifestTransformer) throws MojoExecutionException {
try (JarFile jarFile = new JarFile(jar)) {
for (Enumeration<JarEntry> jarEntries = jarFile.entries(); jarEntries.hasMoreElements(); ) {
JarEntry jarEntry = jarEntries.nextElement();
if (manifestTransformer.canTransform(jarEntry)) {
jarEntry = manifestTransformer.transform(jarEntry);
}
if (!jarEntry.isDirectory() && !content.contains(jarEntry.getName())) {
content.add(jarEntry.getName());
makeDirsRecursively(jarEntry.getName());
try (InputStream in = getInputStream(jarEntry, jarFile, manifestTransformer)) {
jarOutputStream.putNextEntry(jarEntry);
IOUtil.copy(in, jarOutputStream);
}
}
}
} catch (IOException e) {
throw new MojoExecutionException("Error adding " + jar.getName() + " to target JAR: " + e.getMessage(), e);
}
}
示例7: processRootAnnotation
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
private void processRootAnnotation(Map<String, String> paths, String className, AnnotationInstance rootAnnotation)
throws MojoExecutionException {
if (rootAnnotation == null)
return;
List<MethodInfo> methods = rootAnnotation.target().asClass().methods();
for (MethodInfo method : methods)
if (!containsPathAnnotation(method)) {
String httpVerb = getHttpVerb(method);
if (httpVerb != null) {
String path = httpVerb;
path = addProducer(path, method);
path = addConsumer(path, method);
path = path.concat("/").concat(getRootPath(rootAnnotation));
addInPaths(paths, className, path);
}
}
}
示例8: execute
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// Create test context
try (final GenericXmlApplicationContext generateContext = new GenericXmlApplicationContext()) {
generateContext.load("classpath:generate-context.xml");
generateContext.refresh();
final DataSource dataSource = generateContext.getBean(DataSource.class);
final Generator generator = new Generator(getLog(), this::processRecord);
getLog().info("Loading templates from: " + source.getAbsolutePath());
getLog().info("Package: " + packageName);
for (final File file : source.listFiles(this::acceptAllFiles)) {
generator.generate(dataSource, file, destination, packageName);
}
}
}
示例9: file1UsesFile2TypeDefFile3Type
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
/**
* Checks hierarchical intra with inter file type linking.
*/
@Test
public void file1UsesFile2TypeDefFile3Type()
throws IOException, ParserException, MojoExecutionException {
String searchDir = "src/test/resources/file1UsesFile2TypeDefFile3Type";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
utilManager.resolveDependenciesUsingLinker();
String userDir = System.getProperty("user.dir");
YangPluginConfig yangPluginConfig = new YangPluginConfig();
yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
deleteDirectory(userDir + "/target/file1UsesFile2TypeDefFile3Type/");
}
示例10: setupHintedShader
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
private void setupHintedShader()
throws MojoExecutionException
{
if ( shaderHint != null )
{
try
{
shader = (Shader) plexusContainer.lookup( Shader.ROLE, shaderHint );
}
catch ( ComponentLookupException e )
{
throw new MojoExecutionException( "unable to lookup own Shader implementation with hint:'" + shaderHint
+ "'", e );
}
}
}
示例11: execute
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
/**
* Called by the project to let the task do its work.
* This will invoke PatternGenerator for each file in the nested FileSet(s).
*
* @throws MojoExecutionException if something goes wrong.
*/
public void execute() throws MojoExecutionException {
PatternGenerator pg = null;
try {
File directory = new File(fileSet.getDirectory());
String includes = StringUtils.join(fileSet.getIncludes(), ",");
String excludes = StringUtils.join(fileSet.getExcludes(), ",");
List<File> fileList = FileUtils.getFiles(directory, includes, excludes);
for (File file : fileList) {
pg = new PatternGenerator(file.toURI().toURL());
pg.setData(fileList);
pg.processPattern();
pg.destroy();
pg = null;
}
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("Error in executing PatternGeneratorMojo: " + e.getMessage(), e);
} finally {
if (pg != null) {
pg.destroy();
}
}
}
示例12: testUnpackDontOverWriteReleases
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
public void testUnpackDontOverWriteReleases()
throws IOException, MojoExecutionException, InterruptedException
{
stubFactory.setCreateFiles( true );
Artifact release = stubFactory.getReleaseArtifact();
release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
ArtifactItem item = new ArtifactItem( release );
ArrayList list = new ArrayList( 1 );
list.add( item );
mojo.setArtifactItems( list );
mojo.setOverWriteIfNewer( false );
mojo.execute();
assertUnpacked( item, false );
}
示例13: parseSoliditySource
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
private String parseSoliditySource(String includedFile) throws MojoExecutionException {
try {
byte[] contract = Files.readAllBytes(Paths.get(soliditySourceFiles.getDirectory(), includedFile));
CompilerResult result = SolidityCompiler.getInstance(getLog()).compileSrc(
contract,
SolidityCompiler.Options.ABI,
SolidityCompiler.Options.BIN,
SolidityCompiler.Options.INTERFACE,
SolidityCompiler.Options.METADATA
);
if (result.isFailed()) {
throw new MojoExecutionException("Could not compile solidity files\n" + result.errors);
}
getLog().debug("\t\tResult:\t" + result.output);
getLog().debug("\t\tError: \t" + result.errors);
return result.output;
} catch (IOException ioException) {
throw new MojoExecutionException("Could not compile files", ioException);
}
}
示例14: testUnpackOverWriteReleases
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
public void testUnpackOverWriteReleases()
throws IOException, MojoExecutionException, InterruptedException
{
stubFactory.setCreateFiles( true );
Artifact release = stubFactory.getReleaseArtifact();
release.getFile().setLastModified( System.currentTimeMillis() - 2000 );
ArtifactItem item = new ArtifactItem( release );
ArrayList list = new ArrayList( 1 );
list.add( item );
mojo.setArtifactItems( list );
mojo.setOverWriteIfNewer( false );
mojo.setOverWriteReleases( true );
mojo.execute();
assertUnpacked( item, true );
}
示例15: testUnpackOverWriteSnapshot
import org.apache.maven.plugin.MojoExecutionException; //导入依赖的package包/类
public void testUnpackOverWriteSnapshot()
throws IOException, MojoExecutionException, InterruptedException
{
stubFactory.setCreateFiles( true );
Artifact artifact = stubFactory.getSnapshotArtifact();
artifact.getFile().setLastModified( System.currentTimeMillis() - 2000 );
ArtifactItem item = new ArtifactItem( artifact );
ArrayList list = new ArrayList( 1 );
list.add( item );
mojo.setArtifactItems( list );
mojo.setOverWriteIfNewer( false );
mojo.setOverWriteReleases( false );
mojo.setOverWriteSnapshots( true );
mojo.execute();
assertUnpacked( item, true );
}