当前位置: 首页>>代码示例>>Java>>正文


Java AbstractMojo类代码示例

本文整理汇总了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 );
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:20,代码来源:ExecJavaMojoTest.java

示例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 );
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:25,代码来源:AbstractJnlpMojoTest.java

示例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;
	}
 
开发者ID:roboconf,项目名称:roboconf-maven-plugin,代码行数:27,代码来源:ValidateProjectMojoTest.java

示例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());
    }
}
 
开发者ID:brooklyncentral,项目名称:brooklyn-maven-plugin,代码行数:30,代码来源:AbstractBrooklynMojoTest.java

示例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;
	}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:26,代码来源:AbstractTest.java

示例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));
	}
}
 
开发者ID:maven-nar,项目名称:m2e-nar,代码行数:10,代码来源:NarClassloader.java

示例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();
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:38,代码来源:ResolveMojoTest.java

示例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});
}
 
开发者ID:betfair,项目名称:cougar,代码行数:29,代码来源:TestExceptionMessageHandling.java

示例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;
}
 
开发者ID:lgrignon,项目名称:jsweet-maven-plugin,代码行数:6,代码来源:JSweetWatchMojo.java

示例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();
}
 
开发者ID:maven-nar,项目名称:m2e-nar,代码行数:6,代码来源:NarExecutionBuilder.java

示例11: setMojo

import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public Builder setMojo(final AbstractMojo mojo) {
	this.abstractMojo = mojo;
	return this;
}
 
开发者ID:struktured,项目名称:ocamljava-maven-plugin,代码行数:5,代码来源:OcamlRuntimeContainer.java

示例12: JarAppender

import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarAppender(final AbstractMojo abstractMojo) {
	this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}
 
开发者ID:struktured,项目名称:ocamljava-maven-plugin,代码行数:4,代码来源:JarAppender.java

示例13: FileGatherer

import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public FileGatherer(final AbstractMojo abstractMojo) {
	this.mojo = Preconditions.checkNotNull(abstractMojo);
}
 
开发者ID:struktured,项目名称:ocamljava-maven-plugin,代码行数:4,代码来源:FileGatherer.java

示例14: JarExtractor

import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarExtractor(final AbstractMojo abstractMojo) {
	this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}
 
开发者ID:struktured,项目名称:ocamljava-maven-plugin,代码行数:4,代码来源:JarExtractor.java

示例15: JarMerger

import org.apache.maven.plugin.AbstractMojo; //导入依赖的package包/类
public JarMerger(final AbstractMojo abstractMojo) {
	this.abstractMojo = Preconditions.checkNotNull(abstractMojo);
}
 
开发者ID:struktured,项目名称:ocamljava-maven-plugin,代码行数:4,代码来源:JarMerger.java


注:本文中的org.apache.maven.plugin.AbstractMojo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。