本文整理汇总了Java中org.apache.maven.plugin.AbstractMojo类的典型用法代码示例。如果您正苦于以下问题:Java AbstractMojo类的具体用法?Java AbstractMojo怎么用?Java AbstractMojo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractMojo类属于org.apache.maven.plugin包,在下文中一共展示了AbstractMojo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpProject
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
throws Exception
{
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
ArtifactRepositoryLayout localRepositoryLayout =
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
String path = "src/test/repository";
ArtifactRepository localRepository =
new DefaultArtifactRepository( "local", "file://" + new File( path ).getAbsolutePath(),
localRepositoryLayout );
MavenProject project = builder.buildWithDependencies( pomFile, localRepository, null );
// this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
setVariableValueToObject( mojo, "project", project );
}
示例2: setUpProject
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
throws Exception
{
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
ArtifactRepositoryFactory artifactRepositoryFactory =
(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" );
String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository";
ArtifactRepository localRepository =
artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(),
policy, policy );
ProfileManager profileManager = new DefaultProfileManager( getContainer() );
MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager );
//this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
setVariableValueToObject( mojo, "project", project );
}
示例3: findMojo
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
protected AbstractMojo findMojo( String projectName, String goalName ) throws Exception {
// Find the project
File baseDir = this.resources.getBasedir( projectName );
Assert.assertNotNull( baseDir );
Assert.assertTrue( baseDir.exists());
Assert.assertTrue( baseDir.isDirectory());
File pom = new File( baseDir, "pom.xml" );
AbstractMojo mojo = (AbstractMojo) this.rule.lookupMojo( goalName, pom );
Assert.assertNotNull( mojo );
// Create the Maven project by hand (...)
final MavenProject mvnProject = new MavenProject() ;
mvnProject.setFile( pom ) ;
this.rule.setVariableValueToObject( mojo, "project", mvnProject );
Assert.assertNotNull( this.rule.getVariableValueFromObject( mojo, "project" ));
// Initialize the project
InitializeMojo initMojo = new InitializeMojo();
initMojo.setProject( mvnProject );
initMojo.execute();
return mojo;
}
示例4: executeMojoWithTimeout
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
/**
* Executes the given mojo and fails if it does not succeed within the given period.
* @see AbstractInvokeBrooklynMojo#setPollPeriod(int, TimeUnit)
*/
protected void executeMojoWithTimeout(final AbstractMojo mojo, int timeout, TimeUnit unit) throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Exception> exception = new AtomicReference<Exception>();
Thread t = new Thread() {
@Override
public void run() {
try {
mojo.execute();
} catch (Exception e) {
exception.set(e);
} finally {
latch.countDown();
}
}
};
t.start();
boolean threadComplete = latch.await(timeout, unit);
if (exception.get() != null) {
if (t.isAlive()) t.interrupt();
throw exception.get();
} else if (!threadComplete) {
t.interrupt();
fail(mojo + " incomplete after " + timeout + " " + unit.name().toLowerCase());
}
}
示例5: findMojo
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
protected AbstractMojo findMojo( String projectName, String goalName ) throws Exception {
// Find the project
File baseDir = this.resources.getBasedir( projectName );
Assert.assertNotNull( baseDir );
Assert.assertTrue( baseDir.isDirectory());
File pom = new File( baseDir, "pom.xml" );
AbstractMojo mojo = (AbstractMojo) this.rule.lookupMojo( goalName, pom );
Assert.assertNotNull( mojo );
// Create the Maven project by hand (...)
final MavenProject mvnProject = new MavenProject() ;
mvnProject.setFile( pom ) ;
this.rule.setVariableValueToObject( mojo, "project", mvnProject );
Assert.assertNotNull( this.rule.getVariableValueFromObject( mojo, "project" ));
// Initialize the project
InitializeMojo initMojo = new InitializeMojo();
initMojo.setProject( mvnProject );
initMojo.execute();
return mojo;
}
示例6: createNarExecutionBuilder
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public INarExecutionBuilder createNarExecutionBuilder(final MavenProject mavenProject, final AbstractMojo mojo) throws CoreException {
try {
Class<?> clazz = Class.forName(builder, true, this);
Constructor<?> constructor = clazz.getConstructor(MavenProject.class, AbstractMojo.class);
return (INarExecutionBuilder) constructor.newInstance(mavenProject, mojo);
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "NAR Classloader problem", e));
}
}
示例7: testWithInvalidRoboconfDependencies
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
@Test( expected = MojoExecutionException.class )
public void testWithInvalidRoboconfDependencies() throws Exception {
// Prepare the project
final String projectName = "project--valid";
File baseDir = this.resources.getBasedir( projectName );
Assert.assertNotNull( baseDir );
Assert.assertTrue( baseDir.isDirectory());
AbstractMojo mojo = findMojo( projectName, "resolve" );
this.rule.setVariableValueToObject( mojo, "repoSystem", newRepositorySystem());
this.rule.setVariableValueToObject( mojo, "repositories", new ArrayList<RemoteRepository>( 0 ));
// Add dependencies
MavenProject project = (MavenProject) this.rule.getVariableValueFromObject( mojo, "project" );
project.setDependencyArtifacts( new HashSet<Artifact> ());
Artifact notRbcfArtifact1 = new DefaultArtifact( "net.roboconf", "roboconf-core", "0.2", "runtime", "jar", null, new DefaultArtifactHandler());
project.getDependencyArtifacts().add( notRbcfArtifact1 );
Artifact notRbcfArtifact2 = new DefaultArtifact( "net.roboconf", "roboconf-core", "0.2", "runtime", "jar", null, new DefaultArtifactHandler());
notRbcfArtifact2.setFile( new File( "file that does not exist" ));
project.getDependencyArtifacts().add( notRbcfArtifact2 );
Artifact notRbcfArtifact3 = new DefaultArtifact( "net.roboconf", "roboconf-core", "0.2", "runtime", "jar", null, new DefaultArtifactHandler());
File temp = this.folder.newFile( "toto.zip" );
Assert.assertTrue( temp.exists());
notRbcfArtifact3.setFile( temp );
project.getDependencyArtifacts().add( notRbcfArtifact3 );
// Execute it
File targetDir = new File( baseDir, MavenPluginConstants.TARGET_MODEL_DIRECTORY + "/" + Constants.PROJECT_DIR_GRAPH );
Assert.assertFalse( targetDir.isDirectory());
mojo.execute();
}
示例8: setup
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
@Before
public void setup() throws Exception {
final String baseDir = System.getProperty("user.dir");
mojo = new IdlToDSMojo();
mojo.setBaseDir(baseDir);
mojo.setWsdlXslResource(RSRC);
mojo.setXsdXslResource(RSRC);
Field projectField = IdlToDSMojo.class.getDeclaredField("project");
projectField.setAccessible(true);
projectField.set(mojo, mock(MavenProject.class));
Field iddAsResourceField = IdlToDSMojo.class.getDeclaredField("iddAsResource");
iddAsResourceField.setAccessible(true);
iddAsResourceField.setBoolean(mojo, true);
Field logField = AbstractMojo.class.getDeclaredField("log");
logField.setAccessible(true);
logField.set(mojo, mock(Log.class));
Service s = new Service();
Field f = Service.class.getDeclaredField("serviceName");
f.setAccessible(true);
f.set(s, SERVICE_NAME);
mojo.setServices(new Service[]{s});
}
示例9: TranspilatorThread
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public TranspilatorThread(AbstractMojo mojo, MavenProject project) {
setPriority(Thread.MAX_PRIORITY);
this.project = project;
this.mojo = mojo;
}
示例10: NarExecutionBuilder
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public NarExecutionBuilder(final AbstractMojo compileMojo, final MojoExecution mojoExceution) {
this.narCompileMojo = (INarCompileMojo) compileMojo;
this.mojoExecution = mojoExceution;
parseNarVersionNumbers();
}
示例11: setMojo
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public Builder setMojo(final AbstractMojo mojo) {
this.abstractMojo = mojo;
return this;
}
示例12: JarAppender
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarAppender(final AbstractMojo abstractMojo) {
this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}
示例13: FileGatherer
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public FileGatherer(final AbstractMojo abstractMojo) {
this.mojo = Preconditions.checkNotNull(abstractMojo);
}
示例14: JarExtractor
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarExtractor(final AbstractMojo abstractMojo) {
this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}
示例15: JarMerger
import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarMerger(final AbstractMojo abstractMojo) {
this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}