use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-dependency-plugin by apache.
the class TestUnpackMarkerFileHandler method setUp.
protected void setUp() throws Exception {
super.setUp();
testDir = new File(getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + "unpack-markers" + File.separatorChar);
DependencyTestUtils.removeDirectory(testDir);
assertFalse(testDir.exists());
stubFactory = new DependencyArtifactStubFactory(this.testDir, false);
Artifact artifact = stubFactory.createArtifact("test", "test", "1");
ArtifactItem artifactItem;
stubFactory.getArtifactItem(artifact);
artifactItems.add(stubFactory.getArtifactItem(stubFactory.createArtifact("test", "test", "1")));
artifact = stubFactory.createArtifact("test2", "test2", "2");
artifactItem = new ArtifactItem(artifact);
artifactItem.setIncludes("**/*.xml");
artifactItems.add(artifactItem);
artifact = stubFactory.createArtifact("test3", "test3", "3");
artifactItem = new ArtifactItem(artifact);
artifactItem.setExcludes("**/*.class");
artifactItems.add(artifactItem);
artifact = stubFactory.createArtifact("test4", "test4", "4");
artifactItem = new ArtifactItem(artifact);
artifactItem.setIncludes("**/*.xml");
artifactItem.setExcludes("**/*.class");
artifactItems.add(artifactItem);
outputFolder = new File("target/markers/");
DependencyTestUtils.removeDirectory(this.outputFolder);
assertFalse(outputFolder.exists());
}
use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-dependency-plugin by apache.
the class TestUnpackMarkerFileHandler method testMarkerTimeStamp.
public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException {
File theFile = new File(outputFolder, "theFile.jar");
outputFolder.mkdirs();
theFile.createNewFile();
ArtifactItem theArtifactItem = artifactItems.get(0);
Artifact theArtifact = theArtifactItem.getArtifact();
theArtifact.setFile(theFile);
UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(theArtifactItem, this.outputFolder);
assertFalse(handler.isMarkerSet());
// if the marker is not set, assume it is infinately older than the
// artifact.
assertTrue(handler.isMarkerOlder(theArtifact));
handler.setMarker();
assertFalse(handler.isMarkerOlder(theArtifact));
assertTrue(theFile.setLastModified(theFile.lastModified() + 60000));
assertTrue(handler.isMarkerOlder(theArtifact));
theFile.delete();
handler.clearMarker();
assertFalse(handler.isMarkerSet());
}
use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-plugins by apache.
the class TestUnpackMarkerFileHandler method setUp.
protected void setUp() throws Exception {
super.setUp();
testDir = new File(getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar + "unpack-markers" + File.separatorChar);
DependencyTestUtils.removeDirectory(testDir);
assertFalse(testDir.exists());
stubFactory = new DependencyArtifactStubFactory(this.testDir, false);
Artifact artifact = stubFactory.createArtifact("test", "test", "1");
ArtifactItem artifactItem;
stubFactory.getArtifactItem(artifact);
artifactItems.add(stubFactory.getArtifactItem(stubFactory.createArtifact("test", "test", "1")));
artifact = stubFactory.createArtifact("test2", "test2", "2");
artifactItem = new ArtifactItem(artifact);
artifactItem.setIncludes("**/*.xml");
artifactItems.add(artifactItem);
artifact = stubFactory.createArtifact("test3", "test3", "3");
artifactItem = new ArtifactItem(artifact);
artifactItem.setExcludes("**/*.class");
artifactItems.add(artifactItem);
artifact = stubFactory.createArtifact("test4", "test4", "4");
artifactItem = new ArtifactItem(artifact);
artifactItem.setIncludes("**/*.xml");
artifactItem.setExcludes("**/*.class");
artifactItems.add(artifactItem);
outputFolder = new File("target/markers/");
DependencyTestUtils.removeDirectory(this.outputFolder);
assertFalse(outputFolder.exists());
}
use of org.apache.maven.plugins.dependency.fromConfiguration.ArtifactItem in project maven-plugins by apache.
the class TestUnpackMarkerFileHandler method testMarkerTimeStamp.
public void testMarkerTimeStamp() throws MojoExecutionException, IOException, InterruptedException {
File theFile = new File(outputFolder, "theFile.jar");
outputFolder.mkdirs();
theFile.createNewFile();
ArtifactItem theArtifactItem = artifactItems.get(0);
Artifact theArtifact = theArtifactItem.getArtifact();
theArtifact.setFile(theFile);
UnpackFileMarkerHandler handler = new UnpackFileMarkerHandler(theArtifactItem, this.outputFolder);
assertFalse(handler.isMarkerSet());
// if the marker is not set, assume it is infinately older than the
// artifact.
assertTrue(handler.isMarkerOlder(theArtifact));
handler.setMarker();
assertFalse(handler.isMarkerOlder(theArtifact));
assertTrue(theFile.setLastModified(theFile.lastModified() + 60000));
assertTrue(handler.isMarkerOlder(theArtifact));
theFile.delete();
handler.clearMarker();
assertFalse(handler.isMarkerSet());
}
Aggregations