org.apache.ivy.core.module.descriptor.DefaultArtifact Java Examples
The following examples show how to use
org.apache.ivy.core.module.descriptor.DefaultArtifact.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testAbortTransaction() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); resolver.publish(ivyArtifact, src, false); resolver.publish(artifact, src, false); resolver.abortPublishTransaction(); assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists()); assertFalse(new File( "test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext") .exists()); }
Example #2
Source File: RepositoryAnalyser.java From ant-ivy with Apache License 2.0 | 6 votes |
public void analyse(String pattern, DependencyAnalyser depAnalyser) { JarModuleFinder finder = new JarModuleFinder(pattern); ModuleDescriptor[] mds = depAnalyser.analyze(finder.findJarModules()); Message.info("found " + mds.length + " modules"); for (ModuleDescriptor md : mds) { File ivyFile = new File(IvyPatternHelper.substitute( pattern, DefaultArtifact.newIvyArtifact(md.getModuleRevisionId(), md.getPublicationDate()))); try { Message.info("generating " + ivyFile); XmlModuleDescriptorWriter.write(md, ivyFile); } catch (IOException e) { Message.debug(e); } } }
Example #3
Source File: DependencyResolverIvyPublisher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultModuleVersionPublishMetaData publishMetaData = new DefaultModuleVersionPublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #4
Source File: RepositoryResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
protected void putSignature(Artifact artifact, File src, String dest, boolean overwrite) throws IOException { SignatureGenerator gen = getSettings().getSignatureGenerator(signerName); if (gen == null) { throw new IllegalArgumentException("Couldn't sign the artifacts! " + "Unknown signer name: '" + signerName + "'"); } File tempFile = File.createTempFile("ivytemp", gen.getExtension()); try { gen.sign(src, tempFile); repository.put(DefaultArtifact.cloneWithAnotherTypeAndExt(artifact, gen.getExtension(), artifact.getExt() + "." + gen.getExtension()), tempFile, chopQuery(dest, gen.getExtension()), overwrite); } finally { tempFile.delete(); } }
Example #5
Source File: DefaultConfigurationsToArtifactsConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) { Map<String, String> extraAttributes = new HashMap<String, String>(); if (GUtil.isTrue(publishArtifact.getClassifier())) { extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier()); } String name = publishArtifact.getName(); if (!GUtil.isTrue(name)) { name = moduleRevisionId.getName(); } return new DefaultArtifact( moduleRevisionId, publishArtifact.getDate(), name, publishArtifact.getType(), publishArtifact.getExtension(), extraAttributes); }
Example #6
Source File: DependencyResolverIvyPublisher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultIvyModulePublishMetaData publishMetaData = new DefaultIvyModulePublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #7
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Publishing with transaction=true and an unsupported pattern must fail. * * @throws Exception if something goes wrong */ @Test public void testUnsupportedTransaction() throws Exception { expExc.expect(IllegalStateException.class); expExc.expectMessage("transactional"); FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.setTransactional("true"); resolver.addArtifactPattern( // this pattern is not supported for transaction publish settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); resolver.publish(artifact, src, false); }
Example #8
Source File: DependencyResolverIvyPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultModuleVersionPublishMetaData publishMetaData = new DefaultModuleVersionPublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #9
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Publishing with transaction=true and overwrite mode must fail. * * @throws Exception if something goes wrong */ @Test public void testUnsupportedTransaction3() throws Exception { expExc.expect(IllegalStateException.class); expExc.expectMessage("transactional"); FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.setTransactional("true"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); // overwrite transaction not supported resolver.beginPublishTransaction(mrid, true); resolver.publish(artifact, src, true); }
Example #10
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 6 votes |
@Override public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) { if (!isM2compatible() || !isUsepoms()) { return null; } ModuleRevisionId mrid = dd.getDependencyRevisionId(); mrid = convertM2IdForResourceSearch(mrid); final String revision = dd.getDependencyRevisionId().getRevision(); final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision = MavenTimedSnapshotVersionMatcher.computeIfSnapshot(revision); if (snapshotRevision != null) { final ResolvedResource rres = findSnapshotDescriptor(dd, data, mrid, snapshotRevision); if (rres != null) { return rres; } } return findResourceUsingPatterns(mrid, getIvyPatterns(), DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #11
Source File: DefaultConfigurationsToArtifactsConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) { Map<String, String> extraAttributes = new HashMap<String, String>(); if (GUtil.isTrue(publishArtifact.getClassifier())) { extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier()); } String name = publishArtifact.getName(); if (!GUtil.isTrue(name)) { name = moduleRevisionId.getName(); } return new DefaultArtifact( moduleRevisionId, publishArtifact.getDate(), name, publishArtifact.getType(), publishArtifact.getExtension(), extraAttributes); }
Example #12
Source File: DependencyResolverIvyPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultIvyModulePublishMetaData publishMetaData = new DefaultIvyModulePublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #13
Source File: BintrayResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testBintray() throws Exception { BintrayResolver resolver = new BintrayResolver(); resolver.setSettings(settings); ModuleRevisionId mrid = ModuleRevisionId .newInstance("org.apache.ant", "ant-antunit", "1.2"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); DefaultArtifact artifact = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, downloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #14
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublish() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); assertEquals("test", resolver.getName()); resolver.addIvyPattern(settings.getBaseDir() + FS + "test" + FS + "repositories" + FS + "1" + FS + "[organisation]" + FS + "[module]" + FS + "[revision]" + FS + "[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + FS + "test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); resolver.publish(ivyArtifact, src, false); resolver.publish(artifact, src, false); resolver.commitPublishTransaction(); assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists()); assertTrue(new File( "test/repositories/1/myorg/mymodule/mytypes/myartifact-myrevision.myext") .exists()); }
Example #15
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublishOverwrite() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); assertEquals("test", resolver.getName()); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); File ivyFile = new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml"); File artifactFile = new File( "test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext"); touch(ivyFile); touch(artifactFile); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, true); resolver.publish(ivyArtifact, src, true); resolver.publish(artifact, src, true); resolver.commitPublishTransaction(); long length = src.length(); assertEquals(length, ivyFile.length()); assertEquals(length, artifactFile.length()); }
Example #16
Source File: AbstractPatternsBasedResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) { ModuleRevisionId mrid = dd.getDependencyRevisionId(); if (isM2compatible()) { mrid = convertM2IdForResourceSearch(mrid); } return findResourceUsingPatterns(mrid, ivyPatterns, DefaultArtifact.newIvyArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #17
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublishTransactionWithSubDirectories() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[type]/[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[type]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); // files should not be available until the transaction is committed resolver.publish(ivyArtifact, src, false); assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy/ivy.xml") .exists()); resolver.publish(artifact, src, false); assertFalse(new File( "test/repositories/1/myorg/mymodule/myrevision/mytype/myartifact-myrevision.myext") .exists()); resolver.commitPublishTransaction(); assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy/ivy.xml") .exists()); assertTrue(new File( "test/repositories/1/myorg/mymodule/myrevision/mytype/myartifact-myrevision.myext") .exists()); }
Example #18
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublishTransactionWithDottedOrganisation() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setM2compatible(true); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/m2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); // files should not be available until the transaction is committed resolver.publish(ivyArtifact, src, false); assertFalse(new File( "test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml") .exists()); resolver.publish(artifact, src, false); assertFalse(new File( "test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext") .exists()); resolver.commitPublishTransaction(); assertTrue(new File( "test/repositories/m2/org/apache/mymodule/myrevision/ivy-myrevision.xml") .exists()); assertTrue(new File( "test/repositories/m2/org/apache/mymodule/myrevision/myartifact-myrevision.myext") .exists()); }
Example #19
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Publishing with transaction=true and an unsupported combination of patterns must fail. * * @throws Exception if something goes wrong */ @Test public void testUnsupportedTransaction2() throws Exception { expExc.expect(IllegalStateException.class); expExc.expectMessage("transactional"); FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.setTransactional("true"); // the two patterns are inconsistent and thus not supported for transactions resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]-[module]/[revision]/[artifact]-[revision].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); resolver.publish(ivyArtifact, src, false); resolver.publish(artifact, src, false); }
Example #20
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDisableTransaction() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.setTransactional("false"); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); // with transactions disabled the file should be available as soon as they are published resolver.publish(ivyArtifact, src, false); assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists()); resolver.publish(artifact, src, false); assertTrue(new File( "test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext") .exists()); resolver.commitPublishTransaction(); assertTrue(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists()); assertTrue(new File( "test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext") .exists()); }
Example #21
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDownloadWithUseOriginIsTrue() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); ((DefaultRepositoryCacheManager) resolver.getRepositoryCacheManager()).setUseOrigin(true); assertEquals("test", resolver.getName()); resolver.addIvyPattern(IVY_PATTERN); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/" + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Date pubdate = new GregorianCalendar(2004, 10, 1, 11, 0, 0).getTime(); assertEquals(pubdate, rmr.getPublicationDate()); // test to ask to download DefaultArtifact artifact = new DefaultArtifact(mrid, pubdate, "mod1.1", "jar", "jar"); DownloadReport report = resolver.download(new Artifact[] {artifact}, getDownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #22
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublishTransactionWithBranch() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact].[ext]"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[branch]/[revision]/[artifact]-[revision].[ext]"); ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "mybranch", "myrevision"); Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml"); Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype", "myext"); File src = new File("test/repositories/ivysettings.xml"); resolver.beginPublishTransaction(mrid, false); // files should not be available until the transaction is committed resolver.publish(ivyArtifact, src, false); assertFalse(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml") .exists()); resolver.publish(artifact, src, false); assertFalse(new File( "test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext") .exists()); resolver.commitPublishTransaction(); assertTrue(new File("test/repositories/1/myorg/mymodule/mybranch/myrevision/ivy.xml") .exists()); assertTrue(new File( "test/repositories/1/myorg/mymodule/mybranch/myrevision/myartifact-myrevision.myext") .exists()); }
Example #23
Source File: ChainResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testDownloadWithDual() { ChainResolver chain = new ChainResolver(); chain.setName("chain"); chain.setSettings(settings); chain.setDual(true); // first resolver has only an artifact pattern which don't lead to anything: it won't find // the module FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("1"); resolver.setSettings(settings); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/nowhere/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); chain.add(resolver); resolver = new FileSystemResolver(); resolver.setName("2"); resolver.setSettings(settings); resolver.addIvyPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); chain.add(resolver); settings.addResolver(chain); MockMessageLogger mockLogger = new MockMessageLogger(); IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockLogger); DownloadReport report = chain.download( new Artifact[] {new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar")}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); assertEquals(DownloadStatus.SUCCESSFUL, report.getArtifactsReports()[0].getDownloadStatus()); mockLogger.assertLogDoesntContain("[FAILED ] org1#mod1.1;1.0!mod1.1.jar"); }
Example #24
Source File: ResolveEngineTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testLocateThenDownload() { ResolveEngine engine = new ResolveEngine(ivy.getSettings(), ivy.getEventManager(), ivy.getSortEngine()); testLocateThenDownload(engine, DefaultArtifact.newIvyArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date()), new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml")); testLocateThenDownload(engine, new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar"), new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar")); }
Example #25
Source File: TestHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
public static File getArchiveFileInCache(Ivy ivy, String organisation, String module, String revision, String artifactName, String type, String ext) { DefaultArtifact artifact = newArtifact(organisation, module, revision, artifactName, type, ext); return getRepositoryCacheManager(ivy, artifact.getModuleRevisionId()) .getArchiveFileInCache(artifact); }
Example #26
Source File: TestHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
public static File getArchiveFileInCache(Ivy ivy, String mrid, String artifactName, String type, String ext) { DefaultArtifact artifact = new DefaultArtifact(ModuleRevisionId.parse(mrid), new Date(), artifactName, type, ext); return getRepositoryCacheManager(ivy, artifact.getModuleRevisionId()) .getArchiveFileInCache(artifact); }
Example #27
Source File: NameSpaceHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
public static Artifact transform(Artifact artifact, NamespaceTransformer t) { if (t.isIdentity()) { return artifact; } ModuleRevisionId mrid = t.transform(artifact.getModuleRevisionId()); if (artifact.getModuleRevisionId().equals(mrid)) { return artifact; } return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(), artifact.getType(), artifact.getExt(), artifact.getUrl(), artifact.getQualifiedExtraAttributes()); }
Example #28
Source File: RepositoryResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
protected void putChecksum(Artifact artifact, File src, String dest, boolean overwrite, String algorithm) throws IOException { File csFile = File.createTempFile("ivytemp", algorithm); try { FileUtil.copy(new ByteArrayInputStream(ChecksumHelper.computeAsString(src, algorithm) .getBytes()), csFile, null); repository.put(DefaultArtifact.cloneWithAnotherTypeAndExt(artifact, algorithm, artifact.getExt() + "." + algorithm), csFile, chopQuery(dest, algorithm), overwrite); } finally { csFile.delete(); } }
Example #29
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
private ResolvedResource findSnapshotDescriptor(final DependencyDescriptor dd, final ResolveData data, final ModuleRevisionId mrid, final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision) { if (!isM2compatible()) { return null; } final String snapshotDescriptorPattern; if (snapshotRevision.isTimestampedSnapshot()) { Message.debug(mrid + " has been identified as a (Maven) timestamped snapshot revision"); // this is a Maven timestamped snapshot revision. Something like 1.0.0-<timestampedRev> // We now get the base revision from it, which is "1.0.0" and append the "-SNAPSHOT" to it. final String inferredSnapshotRevision = snapshotRevision.getBaseRevision() + "-SNAPSHOT"; // we replace the "/[revision]" in the descriptor pattern with the "inferred" snapshot // revision which is like "1.0.0-SNAPSHOT". // Ultimately, this will translate to something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotDescriptorPattern = getWholePattern().replaceFirst("/\\[revision\\]", "/" + inferredSnapshotRevision); } else { // it's not a timestamped revision, but a regular snapshot. Try and find any potential // timestamped revisions of this regular snapshot, by looking into the Maven metadata final String timestampedRev = findTimestampedSnapshotVersion(mrid); if (timestampedRev == null) { // no timestamped snapshots found and instead this is just a regular snapshot // version. So let's just fallback to our logic of finding resources using // configured Ivy pattern(s) return null; } Message.verbose(mrid + " has been identified as a snapshot revision which has a timestamped snapshot revision " + timestampedRev); // we have found a timestamped revision for a snapshot. So we replace the "-[revision]" // in the artifact file name to use the timestamped revision. // Ultimately, this will translate to something like // org/module/1.0.0-SNAPSHOT/artifact-1.0.0-<timestampedRev>(-[classifier]).ext snapshotDescriptorPattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + timestampedRev); } // find the descriptor using the snapshot descriptor pattern return findResourceUsingPattern(mrid, snapshotDescriptorPattern, DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data), data.getDate()); }
Example #30
Source File: NameSpaceHelperTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testTransformArtifactWithExtraAttributes() { Artifact artifact = new DefaultArtifact(ArtifactRevisionId.newInstance( ModuleRevisionId.parse("org.apache#test;1.0"), "test", "jar", "jar", Collections.singletonMap("m:qualifier", "sources")), new Date(), null, false); MRIDTransformationRule r = new MRIDTransformationRule(); r.addSrc(new MRIDRule("org.apache", "test", null)); r.addDest(new MRIDRule("apache", "test", null)); Artifact transformed = NameSpaceHelper.transform(artifact, r); assertEquals("apache#test;1.0", transformed.getModuleRevisionId().toString()); assertEquals(Collections.singletonMap("m:qualifier", "sources"), transformed.getQualifiedExtraAttributes()); }