类org.apache.maven.plugin.testing.stubs.ArtifactStub源码实例Demo

下面列出了怎么用org.apache.maven.plugin.testing.stubs.ArtifactStub的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: deadcode4j   文件: A_ModuleGenerator.java
@Test
public void createsClassPathEntryForKnownProject() throws MojoExecutionException {
    MavenProject firstProject = givenMavenProject("firstProject");
    Artifact artifact = new ArtifactStub();
    artifact.setGroupId("de.is24.junit");
    artifact.setArtifactId("firstProject");
    artifact.setVersion("42");
    artifact.setScope("compile");
    mavenProject.setArtifacts(newHashSet(artifact));

    Iterable<Module> modules = objectUnderTest.getModulesFor(asList(firstProject, mavenProject));

    assertThat(modules, is(Matchers.<Module>iterableWithSize(2)));
    Module module = Iterables.getLast(modules);
    assertThat(module.getClassPath(), is(Matchers.<File>iterableWithSize(1)));
}
 
源代码2 项目: deadcode4j   文件: A_ModuleGenerator.java
private MavenProject givenMavenProject(String projectId) {
    MavenProject mavenProject = new MavenProject();
    mavenProject.setGroupId("de.is24.junit");
    mavenProject.setArtifactId(projectId);
    mavenProject.setVersion("42");
    mavenProject.getProperties().setProperty("project.build.sourceEncoding", "UTF-8");
    ArtifactStub projectArtifact = new ArtifactStub();
    projectArtifact.setGroupId("de.is24.junit");
    projectArtifact.setArtifactId(projectId);
    projectArtifact.setVersion("42");
    mavenProject.setArtifact(projectArtifact);
    Build build = new Build();
    build.setOutputDirectory(tempFileRule.getTempFile().getParent());
    mavenProject.setBuild(build);
    return mavenProject;
}
 
源代码3 项目: deadcode4j   文件: A_ModuleGenerator.java
private Artifact addArtifact(MavenProject mavenProject, final boolean resolved) {
    Artifact artifact = new ArtifactStub() {
        private boolean resolved = false;

        @Override
        public boolean isResolved() {
            return this.resolved;
        }

        @Override
        public void setResolved(boolean b) {
            this.resolved = b;
        }

        @Override
        public File getFile() {
            return isResolved() ? super.getFile() : null;
        }
    };
    artifact.setGroupId("de.is24.junit");
    artifact.setArtifactId("dependency");
    artifact.setVersion("42");
    artifact.setScope("compile");
    artifact.setResolved(resolved);
    artifact.setFile(tempFileRule.getTempFile());

    mavenProject.setArtifactFilter(new ScopeArtifactFilter(SCOPE_COMPILE_PLUS_RUNTIME));
    if (resolved) {
        mavenProject.setResolvedArtifacts(newHashSet(artifact));
    } else {
        mavenProject.setArtifacts(newHashSet(artifact));
    }
    return artifact;
}
 
源代码4 项目: deadcode4j   文件: ProjectStub.java
public ProjectStub() {
    ArtifactStub artifact = new ArtifactStub();
    artifact.setGroupId("de.is24.junit");
    artifact.setArtifactId("project");
    artifact.setVersion("42");
    setArtifact(artifact);
    setGroupId(artifact.getGroupId());
    setArtifactId(artifact.getArtifactId());
    setVersion(artifact.getVersion());
    setPackaging("jar");

    setCompileSourceRoots(newArrayList("src/test/java/"));

    properties.setProperty("project.build.sourceEncoding", "UTF-8");
}
 
源代码5 项目: webstart   文件: JarResourcesGeneratorTest.java
private ResolvedJarResource buildJarResource( final String hrefValue, final String version, final String mainClass,
                                              final boolean outputJarVersion, final boolean includeInJnlp )
{

    return new ResolvedJarResource( new ArtifactStub() )
    {

        /**
         * {@inheritDoc}
         */
        public String getHrefValue()
        {
            return hrefValue;
        }

        /**
         * {@inheritDoc}
         */
        public String getMainClass()
        {
            return mainClass;
        }

        /**
         * {@inheritDoc}
         */
        public String getVersion()
        {
            return version;
        }

        /**
         * {@inheritDoc}
         */
        public boolean isIncludeInJnlp()
        {
            return includeInJnlp;
        }

        /**
         * {@inheritDoc}
         */
        public boolean isOutputJarVersion()
        {
            return outputJarVersion;
        }

    };

}
 
源代码6 项目: dependency-mediator   文件: ProjectStub.java
/**
 * Default constructor
 */
public ProjectStub() {
    MavenXpp3Reader pomReader = new MavenXpp3Reader();
    Model model;
    try {
        model = pomReader.read(ReaderFactory.newXmlReader(new File(getBasedir(), "pom.xml")));
        setModel(model);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    Artifact artifact = new ArtifactStub();
    artifact.setArtifactId(model.getArtifactId());
    artifact.setGroupId(model.getGroupId());
    artifact.setVersion(model.getVersion());
    setArtifact(artifact);

    setGroupId(model.getGroupId());
    setArtifactId(model.getArtifactId());
    setVersion(model.getVersion());
    setName(model.getName());
    setUrl(model.getUrl());
    setPackaging(model.getPackaging());

    Build build = new Build();
    build.setFinalName(model.getArtifactId());
    build.setDirectory(getBasedir() + "/target");
    build.setSourceDirectory(getBasedir() + "/src/main/java");
    build.setOutputDirectory(getBasedir() + "/target/classes");
    build.setTestSourceDirectory(getBasedir() + "/src/test/java");
    build.setTestOutputDirectory(getBasedir() + "/target/test-classes");
    setBuild(build);

    List<String> compileSourceRoots = new ArrayList<String>();
    compileSourceRoots.add(getBasedir() + "/src/main/java");
    setCompileSourceRoots(compileSourceRoots);

    List<String> testCompileSourceRoots = new ArrayList<String>();
    testCompileSourceRoots.add(getBasedir() + "/src/test/java");
    setTestCompileSourceRoots(testCompileSourceRoots);
}
 
 类所在包
 类方法