當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。