Search in sources :

Example 1 with DefaultFileMarkerHandler

use of org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler in project maven-plugins by apache.

the class UnpackDependenciesMojo method doExecute.

/**
     * Main entry into mojo. This method gets the dependencies and iterates
     * through each one passing it to DependencyUtil.unpackFile().
     *
     * @throws MojoExecutionException with a message if an error occurs.
     * @see #getDependencySets(boolean)
     * @see #unpack(Artifact, File, String)
     */
@Override
protected void doExecute() throws MojoExecutionException {
    DependencyStatusSets dss = getDependencySets(this.failOnMissingClassifierArtifact);
    for (Artifact artifact : dss.getResolvedDependencies()) {
        File destDir;
        destDir = DependencyUtil.getFormattedOutputDirectory(useSubDirectoryPerScope, useSubDirectoryPerType, useSubDirectoryPerArtifact, useRepositoryLayout, stripVersion, outputDirectory, artifact);
        unpack(artifact, destDir, getIncludes(), getExcludes(), getEncoding());
        DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(artifact, this.markersDirectory);
        handler.setMarker();
    }
    for (Artifact artifact : dss.getSkippedDependencies()) {
        getLog().info(artifact.getId() + " already exists in destination.");
    }
}
Also used : DependencyStatusSets(org.apache.maven.plugins.dependency.utils.DependencyStatusSets) DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 2 with DefaultFileMarkerHandler

use of org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler in project maven-plugins by apache.

the class TestMarkerFileFilter method testGettersSetters.

public void testGettersSetters() {
    MarkerFileFilter filter = new MarkerFileFilter(true, false, true, new DefaultFileMarkerHandler(outputFolder));
    assertEquals(true, filter.isOverWriteReleases());
    assertEquals(false, filter.isOverWriteSnapshots());
    assertEquals(true, filter.isOverWriteIfNewer());
    filter.setOverWriteReleases(false);
    filter.setOverWriteSnapshots(true);
    filter.setOverWriteIfNewer(false);
    assertEquals(false, filter.isOverWriteReleases());
    assertEquals(true, filter.isOverWriteSnapshots());
    assertEquals(false, filter.isOverWriteIfNewer());
}
Also used : DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler)

Example 3 with DefaultFileMarkerHandler

use of org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler in project maven-plugins by apache.

the class TestMarkerFileFilter method testMarkerTimestamp.

public void testMarkerTimestamp() throws IOException, MojoExecutionException, ArtifactFilterException {
    // filter includes release artifact because no marker present
    // filter includes snapshot artifact becaues it is newer than marker
    DependencyArtifactStubFactory fileFact = new DependencyArtifactStubFactory(outputFolder, true);
    Artifact snap = fileFact.getSnapshotArtifact();
    Artifact release = fileFact.getReleaseArtifact();
    Set<Artifact> tempArtifacts = new HashSet<Artifact>();
    tempArtifacts.add(snap);
    tempArtifacts.add(release);
    DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(snap, outputFolder);
    handler.setMarker();
    assertTrue(snap.getFile().setLastModified(snap.getFile().lastModified() + 1500));
    MarkerFileFilter filter = new MarkerFileFilter(false, false, true, new DefaultFileMarkerHandler(outputFolder));
    Set<Artifact> result = filter.filter(tempArtifacts);
    assertEquals(2, result.size());
    // update marker; filter won't include snapshot because timestamps equal
    handler.setMarker();
    result = filter.filter(tempArtifacts);
    assertEquals(1, result.size());
    // filter won't include snapshot because it is older than marker
    assertTrue(snap.getFile().setLastModified(snap.getFile().lastModified() - 10000));
    result = filter.filter(tempArtifacts);
    assertEquals(1, result.size());
    assertTrue(handler.clearMarker());
    assertFalse(handler.isMarkerSet());
    snap.getFile().delete();
    release.getFile().delete();
    DependencyTestUtils.removeDirectory(outputFolder);
    assertFalse(outputFolder.exists());
}
Also used : DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler) Artifact(org.apache.maven.artifact.Artifact) DependencyArtifactStubFactory(org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory) HashSet(java.util.HashSet)

Example 4 with DefaultFileMarkerHandler

use of org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler in project maven-plugins by apache.

the class TestMarkerFileFilter method testMarkerSnapshots.

public void testMarkerSnapshots() throws ArtifactFilterException, MojoExecutionException, IOException {
    DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler(fact.getSnapshotArtifact(), outputFolder);
    handler.setMarker();
    MarkerFileFilter filter = new MarkerFileFilter(true, false, false, new DefaultFileMarkerHandler(outputFolder));
    Set<Artifact> result = filter.filter(artifacts);
    assertEquals(1, result.size());
    filter.setOverWriteSnapshots(true);
    result = filter.filter(artifacts);
    assertEquals(2, result.size());
    assertTrue(handler.clearMarker());
    DependencyTestUtils.removeDirectory(outputFolder);
    assertFalse(outputFolder.exists());
}
Also used : DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler) Artifact(org.apache.maven.artifact.Artifact)

Example 5 with DefaultFileMarkerHandler

use of org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler in project maven-plugins by apache.

the class TestMarkerFileFilter method testMarkerFile.

public void testMarkerFile() throws ArtifactFilterException {
    MarkerFileFilter filter = new MarkerFileFilter(true, true, false, new DefaultFileMarkerHandler(outputFolder));
    Set<Artifact> result = filter.filter(artifacts);
    assertEquals(2, result.size());
    filter.setOverWriteReleases(false);
    filter.setOverWriteSnapshots(false);
    result = filter.filter(artifacts);
    assertEquals(2, result.size());
}
Also used : DefaultFileMarkerHandler(org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

DefaultFileMarkerHandler (org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler)6 Artifact (org.apache.maven.artifact.Artifact)5 File (java.io.File)1 HashSet (java.util.HashSet)1 DependencyArtifactStubFactory (org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory)1 DependencyStatusSets (org.apache.maven.plugins.dependency.utils.DependencyStatusSets)1