Java Code Examples for org.apache.ivy.core.module.id.ModuleRevisionId#newInstance()
The following examples show how to use
org.apache.ivy.core.module.id.ModuleRevisionId#newInstance() .
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 testMaven2() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); resolver.setM2compatible(true); assertEquals("test", resolver.getName()); 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", "test", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); mrid = ModuleRevisionId.newInstance("org.apache.unknown", "test", "1.0"); rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNull(rmr); resolver.reportFailure(); }
Example 2
Source File: GradlePomModuleDescriptorBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void setModuleRevId(String group, String module, String version) { String effectiveVersion = version; if (version != null) { Matcher matcher = TIMESTAMP_PATTERN.matcher(version); if (matcher.matches()) { effectiveVersion = matcher.group(1) + "-SNAPSHOT"; } } this.mrid = ModuleRevisionId.newInstance(group, module, effectiveVersion); ivyModuleDescriptor.setModuleRevisionId(mrid); if (effectiveVersion != null && effectiveVersion.endsWith("SNAPSHOT")) { ivyModuleDescriptor.setStatus("integration"); } else { ivyModuleDescriptor.setStatus("release"); } }
Example 3
Source File: XmlModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Explain how to inherit metadata related to info element * * @param parent * a given parent module descriptor */ protected void mergeInfo(ModuleDescriptor parent) { ModuleRevisionId parentMrid = parent.getModuleRevisionId(); DefaultModuleDescriptor descriptor = getMd(); ModuleRevisionId currentMrid = descriptor.getModuleRevisionId(); ModuleRevisionId mergedMrid = ModuleRevisionId.newInstance( mergeValue(parentMrid.getOrganisation(), currentMrid.getOrganisation()), currentMrid.getName(), mergeValue(parentMrid.getBranch(), currentMrid.getBranch()), mergeRevisionValue(parentMrid.getRevision(), currentMrid.getRevision()), mergeValues(parentMrid.getQualifiedExtraAttributes(), currentMrid.getQualifiedExtraAttributes())); descriptor.setModuleRevisionId(mergedMrid); descriptor.setResolvedModuleRevisionId(mergedMrid); descriptor.setStatus(mergeValue(parent.getStatus(), descriptor.getStatus())); if (descriptor.getNamespace() == null && parent instanceof DefaultModuleDescriptor) { Namespace parentNamespace = ((DefaultModuleDescriptor) parent).getNamespace(); descriptor.setNamespace(parentNamespace); } descriptor.getExtraInfos().addAll(parent.getExtraInfos()); }
Example 4
Source File: PomModuleDescriptorParserTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testPackaging() throws Exception { ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-packaging.pom"), false); assertNotNull(md); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0"); assertEquals(mrid, md.getModuleRevisionId()); Artifact[] artifact = md.getArtifacts("master"); assertEquals(1, artifact.length); assertEquals(mrid, artifact[0].getModuleRevisionId()); assertEquals("test", artifact[0].getName()); assertEquals("war", artifact[0].getExt()); assertEquals("war", artifact[0].getType()); }
Example 5
Source File: ResolveReportTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testFixedMdRange() throws Exception { ResolveReport report = ivy.resolve(new File( "test/repositories/1/org1/mod1.4/ivys/ivy-1.0.2.xml"), getResolveOptions(new String[] {"*"})); assertNotNull(report); assertFalse(report.hasError()); ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.4", "1.0.2"); assertEquals(mrid, fixedMd.getModuleRevisionId()); assertEquals(Arrays.asList("default", "compile"), Arrays.asList(fixedMd.getConfigurationsNames())); assertEquals(1, fixedMd.getDependencies().length); checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.2", "1.1", "default", new String[] {"*"}); checkFixedMdDependency(fixedMd.getDependencies()[0], "org1", "mod1.2", "1.1", "compile", new String[] {"default"}); }
Example 6
Source File: PomModuleDescriptorParserTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testModel() throws Exception { ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings, getClass().getResource("test-model.pom"), false); assertNotNull(md); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "test", "1.0"); assertEquals(mrid, md.getModuleRevisionId()); assertNotNull(md.getConfigurations()); assertEquals(Arrays.asList(PomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS), Arrays.asList(md.getConfigurations())); Artifact[] artifact = md.getArtifacts("master"); assertEquals(1, artifact.length); assertEquals(mrid, artifact[0].getModuleRevisionId()); assertEquals("test", artifact[0].getName()); assertEquals("jar", artifact[0].getExt()); assertEquals("jar", artifact[0].getType()); }
Example 7
Source File: PomModuleDescriptorBuilder.java From ant-ivy with Apache License 2.0 | 5 votes |
public void setModuleRevId(String groupId, String artifactId, String version) { mrid = ModuleRevisionId.newInstance(groupId, artifactId, version); ivyModuleDescriptor.setModuleRevisionId(mrid); if (version == null || version.endsWith("SNAPSHOT")) { ivyModuleDescriptor.setStatus("integration"); } else { ivyModuleDescriptor.setStatus("release"); } }
Example 8
Source File: JarResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testSimpleFile() throws Exception { JarResolver resolver = new JarResolver(); resolver.setName("jarresolver1"); resolver.setFile(new File("test/jar-repos/jarrepo1.jar").getAbsolutePath()); resolver.addIvyPattern("[organisation]/[module]/ivys/ivy-[revision].xml"); resolver.addArtifactPattern("[organisation]/[module]/[type]s/[artifact]-[revision].[type]"); resolver.setSettings(settings); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"); ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); }
Example 9
Source File: ResolveReportTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testFixedMdMultipleExtends() throws Exception { // mod6.2 has two confs default and extension // mod6.2 depends on mod6.1 in conf (default->extension) // conf extension extends default // mod6.1 has two confs default and extension // mod6.1 depends on mod1.2 2.0 in conf (default->default) // conf extension extends default ResolveReport report = ivy.resolve(new File( "test/repositories/1/org6/mod6.2/ivys/ivy-0.3.xml"), getResolveOptions(new String[] {"default", "extension"})); assertNotNull(report); assertFalse(report.hasError()); ModuleDescriptor fixedMd = report.toFixedModuleDescriptor(ivy.getSettings(), null); ModuleRevisionId mrid = ModuleRevisionId.newInstance("org6", "mod6.2", "0.3"); assertEquals(mrid, fixedMd.getModuleRevisionId()); assertEquals(Arrays.asList("default", "extension"), Arrays.asList(fixedMd.getConfigurationsNames())); assertEquals(2, fixedMd.getDependencies().length); checkFixedMdDependency(fixedMd.getDependencies()[0], "org6", "mod6.1", "0.4", "extension", new String[] {"extension", "default"}); checkFixedMdDependency(fixedMd.getDependencies()[0], "org6", "mod6.1", "0.4", "default", new String[] {"extension", "default"}); checkFixedMdDependency(fixedMd.getDependencies()[1], "org1", "mod1.2", "2.0", "extension", new String[] {"default"}); checkFixedMdDependency(fixedMd.getDependencies()[1], "org1", "mod1.2", "2.0", "default", new String[] {"default"}); }
Example 10
Source File: PomModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 5 votes |
private void addTo(PomModuleDescriptorBuilder mdBuilder, PomDependencyMgt dep, ParserSettings ivySettings) throws ParseException, IOException { if ("import".equals(dep.getScope())) { // In Maven, "import" scope semantics are equivalent to getting (only) the // dependency management section of the imported module, into the current // module, so that those "managed dependency versions" are usable/applicable // in the current module's dependencies ModuleRevisionId importModRevID = ModuleRevisionId.newInstance(dep.getGroupId(), dep.getArtifactId(), dep.getVersion()); ResolvedModuleRevision importModule = parseOtherPom(ivySettings, importModRevID, false); if (importModule == null) { throw new IOException("Impossible to import module for " + mdBuilder.getModuleDescriptor().getResource().getName() + ". Import=" + importModRevID); } ModuleDescriptor importDescr = importModule.getDescriptor(); // add dependency management info from imported module for (PomDependencyMgt importedDepMgt : getDependencyManagements(importDescr)) { mdBuilder.addDependencyMgt(new DefaultPomDependencyMgt(importedDepMgt.getGroupId(), importedDepMgt.getArtifactId(), importedDepMgt.getVersion(), importedDepMgt.getScope(), importedDepMgt.getExcludedModules())); } } else { mdBuilder.addDependencyMgt(dep); } }
Example 11
Source File: P2DescriptorTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testResolvePacked() throws Exception { settings.setDefaultResolver("p2-with-packed"); ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit", "4.10.0.v4_10_0_v20120426-0900"); ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency( new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); assertEquals(1, rmr.getDescriptor().getAllArtifacts().length); DownloadOptions options = new DownloadOptions(); DownloadReport report = p2WithPackedResolver.download( rmr.getDescriptor().getAllArtifacts(), options); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; ArtifactDownloadReport ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus()); assertNotNull(ar.getUnpackedLocalFile()); }
Example 12
Source File: IvyTranslations.java From jeka with Apache License 2.0 | 5 votes |
static DefaultModuleDescriptor toPublicationLessModule(JkVersionedModule module, JkDependencySet dependencies, JkScopeMapping defaultMapping, JkVersionProvider resolvedVersions) { final ModuleRevisionId thisModuleRevisionId = ModuleRevisionId.newInstance(module .getModuleId().getGroup(), module.getModuleId().getName(), module.getVersion().getValue()); final DefaultModuleDescriptor result = new DefaultModuleDescriptor( thisModuleRevisionId, "integration", null); populateModuleDescriptor(result, dependencies, defaultMapping, resolvedVersions); return result; }
Example 13
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testPublishTransaction() 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); // 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.xml").exists()); resolver.publish(artifact, src, false); assertFalse(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 14
Source File: IBiblioResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
@Override protected ResolvedResource[] listResources(Repository repository, ModuleRevisionId mrid, String pattern, Artifact artifact) { if (shouldUseMavenMetadata(pattern)) { List<String> revs = listRevisionsWithMavenMetadata(repository, mrid.getModuleId() .getAttributes()); if (revs != null) { Message.debug("\tfound revs: " + revs); List<ResolvedResource> rres = new ArrayList<>(); for (String rev : revs) { ModuleRevisionId historicalMrid = ModuleRevisionId.newInstance(mrid, rev); String patternForRev = pattern; if (rev.endsWith("SNAPSHOT")) { String snapshotVersion = findTimestampedSnapshotVersion(historicalMrid); if (snapshotVersion != null) { patternForRev = pattern.replaceFirst("\\-\\[revision\\]", "-" + snapshotVersion); } } String resolvedPattern = IvyPatternHelper.substitute(patternForRev, historicalMrid, artifact); try { Resource res = repository.getResource(resolvedPattern); if (res != null) { // we do not test if the resource actually exist here, it would cause // a lot of checks which are not always necessary depending on the usage // which is done of the returned ResolvedResource array rres.add(new ResolvedResource(res, rev)); } } catch (IOException e) { Message.warn( "impossible to get resource from name listed by maven-metadata.xml:" + rres, e); } } return rres.toArray(new ResolvedResource[rres.size()]); } else { // maven metadata not available or something went wrong, // use default listing capability return super.listResources(repository, mrid, pattern, artifact); } } else { return super.listResources(repository, mrid, pattern, artifact); } }
Example 15
Source File: FileSystemResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testFixedRevision() throws Exception { FileSystemResolver resolver = new FileSystemResolver(); resolver.setName("test"); resolver.setSettings(settings); 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.SUCCESSFUL, ar.getDownloadStatus()); // test to ask to download again, should use cache report = resolver.download(new Artifact[] {artifact}, getDownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example 16
Source File: PackageMapping.java From ant-ivy with Apache License 2.0 | 4 votes |
public ModuleRevisionId getModuleRevisionId() { return ModuleRevisionId.newInstance(organisation, module, revision); }
Example 17
Source File: OBRResolverTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testResolveDual() throws Exception { ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy.osgi.testbundle", "1.2.3"); genericTestResolveDownload(dualResolver, mrid); }
Example 18
Source File: IvyUtil.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public static ModuleRevisionId createModuleRevisionId(String org, String name, String branch, String revConstraint, Map extraAttributes, boolean replaceNullBranchWithDefault) { synchronized (MODULE_ID_LOCK) { return ModuleRevisionId.newInstance(org, name, branch, revConstraint, extraAttributes, replaceNullBranchWithDefault); } }
Example 19
Source File: IvyUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public static ModuleRevisionId createModuleRevisionId(String org, String name, String branch, String revConstraint, Map extraAttributes, boolean replaceNullBranchWithDefault) { synchronized (MODULE_ID_LOCK) { return ModuleRevisionId.newInstance(org, name, branch, revConstraint, extraAttributes, replaceNullBranchWithDefault); } }
Example 20
Source File: P2DescriptorTest.java From ant-ivy with Apache License 2.0 | 4 votes |
@Test public void testResolveSource() throws Exception { settings.setDefaultResolver("p2-sources"); ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.apache.ivy", "2.2.0.final_20100923230623"); ResolvedModuleRevision rmr = p2SourceResolver.getDependency( new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); assertEquals(2, rmr.getDescriptor().getAllArtifacts().length); DownloadReport report = p2SourceResolver.download(rmr.getDescriptor().getAllArtifacts(), new DownloadOptions()); assertNotNull(report); assertEquals(2, report.getArtifactsReports().length); for (int i = 0; i < 2; i++) { Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i]; 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 DownloadReport report2 = p2SourceResolver.download(new Artifact[] {artifact}, new DownloadOptions()); assertNotNull(report2); assertEquals(1, report2.getArtifactsReports().length); ar = report2.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); } }