Search in sources :

Example 6 with MavenPom

use of org.gradle.api.artifacts.maven.MavenPom in project gradle by gradle.

the class DefaultArtifactPomTest method writePom.

@Test
public void writePom() {
    final MavenPom mavenPomMock = context.mock(MavenPom.class);
    DefaultArtifactPom artifactPom = new DefaultArtifactPom(mavenPomMock);
    final File somePomFile = new File(tmpDir.getTestDirectory(), "someDir/somePath");
    context.checking(new Expectations() {

        {
            allowing(mavenPomMock).getArtifactId();
            will(returnValue("artifactId"));
            oneOf(mavenPomMock).writeTo(with(any(FileOutputStream.class)));
        }
    });
    PublishArtifact artifact = artifactPom.writePom(somePomFile);
    assertThat(artifact.getName(), equalTo("artifactId"));
    assertThat(artifact.getType(), equalTo("pom"));
    assertThat(artifact.getExtension(), equalTo("pom"));
    assertThat(artifact.getClassifier(), nullValue());
    assertThat(artifact.getFile(), equalTo(somePomFile));
}
Also used : Expectations(org.jmock.Expectations) DefaultMavenPom(org.gradle.api.publication.maven.internal.pom.DefaultMavenPom) MavenPom(org.gradle.api.artifacts.maven.MavenPom) FileOutputStream(java.io.FileOutputStream) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) File(java.io.File) Test(org.junit.Test)

Example 7 with MavenPom

use of org.gradle.api.artifacts.maven.MavenPom in project gradle by gradle.

the class MavenPluginConvention method pom.

/**
     * Creates and configures a new {@link MavenPom}. The given closure is executed to configure the new POM instance.
     *
     * @param configureClosure The closure to use to configure the POM instance.
     * @return The POM instance.
     */
public MavenPom pom(Closure configureClosure) {
    Factory<MavenPom> pomFactory = mavenFactory.createMavenPomFactory(project.getConfigurations(), conf2ScopeMappings.getMappings(), project.getFileResolver());
    MavenPom pom = pomFactory.create();
    pom.setGroupId(project.getGroup().toString());
    pom.setArtifactId(project.getName());
    pom.setVersion(project.getVersion().toString());
    return ConfigureUtil.configure(configureClosure, pom);
}
Also used : MavenPom(org.gradle.api.artifacts.maven.MavenPom)

Example 8 with MavenPom

use of org.gradle.api.artifacts.maven.MavenPom in project gradle by gradle.

the class MavenPluginConvention method pom.

/**
 * Creates and configures a new {@link MavenPom}. The given action is executed to configure the new POM instance.
 *
 * @param configureAction The action to use to configure the POM instance.
 * @return The POM instance.
 * @since 4.2
 */
public MavenPom pom(Action<? super MavenPom> configureAction) {
    MavenPom pom = pom();
    configureAction.execute(pom);
    return pom;
}
Also used : MavenPom(org.gradle.api.artifacts.maven.MavenPom)

Aggregations

MavenPom (org.gradle.api.artifacts.maven.MavenPom)8 Test (org.junit.Test)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)1 DefaultMavenPom (org.gradle.api.publication.maven.internal.pom.DefaultMavenPom)1 Expectations (org.jmock.Expectations)1