org.apache.ivy.plugins.resolver.DependencyResolver Java Examples
The following examples show how to use
org.apache.ivy.plugins.resolver.DependencyResolver.
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: EndResolveDependencyEvent.java From ant-ivy with Apache License 2.0 | 6 votes |
public EndResolveDependencyEvent(DependencyResolver resolver, DependencyDescriptor dd, ModuleRevisionId requestedRevisionId, ResolvedModuleRevision module, long duration) { super(NAME, resolver, dd, requestedRevisionId); this.module = module; this.duration = duration; addAttribute("duration", String.valueOf(duration)); if (this.module != null) { // override revision from the dependency descriptor addAttribute("revision", this.module.getDescriptor().getResolvedModuleRevisionId() .getRevision()); // now that we have loaded the dependency descriptor, we can put the extra attributes // contained in the descriptor too addAttributes(this.module.getDescriptor().getResolvedModuleRevisionId() .getQualifiedExtraAttributes()); addAttributes(this.module.getDescriptor().getResolvedModuleRevisionId() .getExtraAttributes()); addAttribute("resolved", "true"); } else { addAttribute("resolved", "false"); } }
Example #2
Source File: IvyInternalPublisher.java From jeka with Apache License 2.0 | 6 votes |
private int publishIvyArtifacts(JkIvyPublication publication, Instant date, ModuleDescriptor moduleDescriptor) { int count = 0; for (final DependencyResolver resolver : IvyTranslations.publishResolverOf(this.ivy .getSettings())) { final JkRepo publishRepo = this.publishRepos.getRepoConfigHavingUrl(IvyTranslations .publishResolverUrl(resolver)); final JkVersionedModule versionedModule = IvyTranslations .toJkVersionedModule(moduleDescriptor.getModuleRevisionId()); if (!isMaven(resolver) && publishRepo.getPublishConfig().getVersionFilter().test(versionedModule.getVersion())) { JkLog.startTask("Publishing for repository " + resolver); this.publishIvyArtifacts(resolver, publication, date, moduleDescriptor); JkLog.endTask(); count++; } } return count; }
Example #3
Source File: IvyConfigureTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testDefault() { // by default settings look in the current directory for an ivysettings.xml file... // but Ivy itself has one, and we don't want to use it configure.getProject().setProperty("ivy.settings.file", "no/settings/will/use/default.xml"); configure.execute(); IvySettings settings = getIvyInstance().getSettings(); assertNotNull(settings.getDefaultResolver()); DependencyResolver publicResolver = settings.getResolver("public"); assertNotNull(publicResolver); assertTrue(publicResolver instanceof IBiblioResolver); IBiblioResolver ibiblio = (IBiblioResolver) publicResolver; assertTrue(ibiblio.isM2compatible()); }
Example #4
Source File: DependencyResolverIdentifier.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public static String forIvyResolver(DependencyResolver resolver) { List<String> parts = new ArrayList<String>(); parts.add(resolver.getClass().getName()); if (resolver instanceof AbstractPatternsBasedResolver) { AbstractPatternsBasedResolver patternsBasedResolver = (AbstractPatternsBasedResolver) resolver; parts.add(joinPatterns(patternsBasedResolver.getIvyPatterns())); parts.add(joinPatterns(patternsBasedResolver.getArtifactPatterns())); if (patternsBasedResolver.isM2compatible()) { parts.add("m2compatible"); } } else { parts.add(resolver.getName()); // TODO We should not be assuming equality between resolvers here based on name... } return calculateId(parts); }
Example #5
Source File: LoopbackDependencyResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ResolvedModuleRevision getDependency(final DependencyDescriptor dd, final ResolveData data) throws ParseException { final DependencyResolver loopback = this; return cacheLockingManager.useCache(String.format("Resolve %s", dd), new Factory<ResolvedModuleRevision>() { public ResolvedModuleRevision create() { DefaultBuildableComponentResolveResult result = new DefaultBuildableComponentResolveResult(); DefaultDependencyMetaData dependency = new DefaultDependencyMetaData(dd); IvyContext ivyContext = IvyContext.pushNewCopyContext(); try { ivyContext.setResolveData(data); dependencyResolver.resolve(dependency, result); } finally { IvyContext.popContext(); } return new ResolvedModuleRevision(loopback, loopback, result.getMetaData().getDescriptor(), null); } }); }
Example #6
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 6 votes |
public ModuleEntry[] listModuleEntries(OrganisationEntry org) { Set<ModuleEntry> entries = new HashSet<>(); Map<String, Object> tokenValues = new HashMap<>(); tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation()); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] modules = resolver.listTokenValues( new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues); for (Map<String, String> me : modules) { String module = me.get(IvyPatternHelper.MODULE_KEY); entries.add(new ModuleEntry(org, module)); } } return entries.toArray(new ModuleEntry[entries.size()]); }
Example #7
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 6 votes |
public RevisionEntry[] listRevisionEntries(ModuleEntry module) { Set<RevisionEntry> entries = new HashSet<>(); Map<String, Object> tokenValues = new HashMap<>(); tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, module.getOrganisation()); tokenValues.put(IvyPatternHelper.MODULE_KEY, module.getModule()); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] revisions = resolver.listTokenValues( new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues); for (Map<String, String> revision : revisions) { entries.add(new RevisionEntry(module, revision.get(IvyPatternHelper.REVISION_KEY))); } } return entries.toArray(new RevisionEntry[entries.size()]); }
Example #8
Source File: XmlSettingsParserTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Test case for IVY-860. * * @throws Exception if something goes wrong * @see <a href="https://issues.apache.org/jira/browse/IVY-860">IVY-860</a> */ @Test public void testMacroAndRef2() throws Exception { IvySettings settings = new IvySettings(); XmlSettingsParser parser = new XmlSettingsParser(settings); parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-macro+ref2.xml")); DependencyResolver macrores = settings.getResolver("macroresolver"); assertNotNull(macrores); assertTrue(macrores instanceof ChainResolver); DependencyResolver testResolver = settings.getResolver("test"); assertNotNull(testResolver); assertTrue(testResolver instanceof IBiblioResolver); ChainResolver chain = (ChainResolver) macrores; List<DependencyResolver> subresolvers = chain.getResolvers(); assertNotNull(subresolvers); assertEquals(1, subresolvers.size()); assertEquals(testResolver, subresolvers.get(0)); }
Example #9
Source File: XmlSettingsParserTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Test case for IVY-319. * * @throws Exception if something goes wrong * @see <a href="https://issues.apache.org/jira/browse/IVY-319">IVY-319</a> */ @Test public void testMacroAndRef() throws Exception { IvySettings settings = new IvySettings(); XmlSettingsParser parser = new XmlSettingsParser(settings); parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-macro+ref.xml")); DependencyResolver shared = settings.getResolver("shared"); assertNotNull(shared); assertTrue(shared instanceof FileSystemResolver); DependencyResolver mychain = settings.getResolver("mychain"); assertNotNull(mychain); assertTrue(mychain instanceof ChainResolver); ChainResolver chain = (ChainResolver) mychain; List<DependencyResolver> subresolvers = chain.getResolvers(); assertNotNull(subresolvers); assertEquals(1, subresolvers.size()); shared = subresolvers.get(0); assertEquals("shared", shared.getName()); assertTrue(shared instanceof FileSystemResolver); }
Example #10
Source File: DefaultArtifactRepositoryContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public DependencyResolver addAfter(Object userDescription, final String beforeResolverName, Closure configureClosure) { if (!GUtil.isTrue(beforeResolverName)) { throw new InvalidUserDataException("You must specify beforeResolverName"); } DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addAfter()"); final ArtifactRepository before = getByName(beforeResolverName); return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() { public void execute(ArtifactRepository repository) { int insertPos = indexOf(before) + 1; if (insertPos == size()) { DefaultArtifactRepositoryContainer.super.add(repository); } else { DefaultArtifactRepositoryContainer.this.add(insertPos, repository); } } }); }
Example #11
Source File: DefaultArtifactRepositoryContainer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public DependencyResolver addAfter(Object userDescription, final String beforeResolverName, Closure configureClosure) { if (!GUtil.isTrue(beforeResolverName)) { throw new InvalidUserDataException("You must specify beforeResolverName"); } DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addAfter()"); final ArtifactRepository before = getByName(beforeResolverName); return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() { public void execute(ArtifactRepository repository) { int insertPos = indexOf(before) + 1; if (insertPos == size()) { DefaultArtifactRepositoryContainer.super.add(repository); } else { DefaultArtifactRepositoryContainer.this.add(insertPos, repository); } } }); }
Example #12
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 6 votes |
public String[] listRevisions(String org, String module) { Set<String> entries = new HashSet<>(); Map<String, Object> tokenValues = new HashMap<>(); tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org); tokenValues.put(IvyPatternHelper.MODULE_KEY, module); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] revisions = resolver.listTokenValues( new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues); for (Map<String, String> revision : revisions) { entries.add(revision.get(IvyPatternHelper.REVISION_KEY)); } } return entries.toArray(new String[entries.size()]); }
Example #13
Source File: DefaultRepositoryHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public DependencyResolver mavenRepo(Map<String, ?> args, Closure configClosure) { DeprecationLogger.nagUserOfReplacedMethod("RepositoryHandler.mavenRepo()", "maven()"); Map<String, Object> modifiedArgs = new HashMap<String, Object>(args); if (modifiedArgs.containsKey("urls")) { List<?> urls = flattenCollections(modifiedArgs.remove("urls")); if (!urls.isEmpty()) { modifiedArgs.put("url", urls.get(0)); List<?> extraUrls = urls.subList(1, urls.size()); modifiedArgs.put("artifactUrls", extraUrls); } } MavenArtifactRepository repository = repositoryFactory.createMavenRepository(); ConfigureUtil.configureByMap(modifiedArgs, repository); DependencyResolver resolver = repositoryFactory.toResolver(repository); ConfigureUtil.configure(configClosure, resolver); addRepository(repositoryFactory.createResolverBackedRepository(resolver), "mavenRepo"); return resolver; }
Example #14
Source File: DownloadingRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ResolvedModuleRevision cacheModuleDescriptor(DependencyResolver resolver, final ResolvedResource resolvedResource, DependencyDescriptor dd, Artifact moduleArtifact, ResourceDownloader downloader, CacheMetadataOptions options) throws ParseException { if (!moduleArtifact.isMetadata()) { return null; } ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() { public ResolvedResource resolve(Artifact artifact) { return resolvedResource; } }; ArtifactDownloadReport report = download(moduleArtifact, artifactResourceResolver, downloader, new CacheDownloadOptions().setListener(options.getListener()).setForce(true)); if (report.getDownloadStatus() == DownloadStatus.FAILED) { LOGGER.warn("problem while downloading module descriptor: {}: {} ({} ms)", resolvedResource.getResource(), report.getDownloadDetails(), report.getDownloadTimeMillis()); return null; } ModuleDescriptor md = parseModuleDescriptor(resolver, moduleArtifact, options, report.getLocalFile(), resolvedResource.getResource()); LOGGER.debug("\t{}: parsed downloaded md file for {}; parsed={}" + getName(), moduleArtifact.getModuleRevisionId(), md.getModuleRevisionId()); MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(md.getMetadataArtifact()); madr.setSearched(true); madr.setDownloadStatus(report.getDownloadStatus()); madr.setDownloadDetails(report.getDownloadDetails()); madr.setArtifactOrigin(report.getArtifactOrigin()); madr.setDownloadTimeMillis(report.getDownloadTimeMillis()); madr.setOriginalLocalFile(report.getLocalFile()); madr.setSize(report.getSize()); return new ResolvedModuleRevision(resolver, resolver, md, madr); }
Example #15
Source File: AbstractRepositoryCacheManager.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
protected ModuleDescriptor parseModuleDescriptor(DependencyResolver resolver, Artifact moduleArtifact, CacheMetadataOptions options, File artifactFile, Resource resource) throws ParseException { ModuleRevisionId moduleRevisionId = moduleArtifact.getId().getModuleRevisionId(); try { IvySettings ivySettings = IvyContextualiser.getIvyContext().getSettings(); ParserSettings parserSettings = new LegacyResolverParserSettings(ivySettings, resolver, moduleRevisionId); ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(resource); return parser.parseDescriptor(parserSettings, new URL(artifactFile.toURI().toASCIIString()), resource, options.isValidate()); } catch (IOException e) { throw UncheckedException.throwAsUncheckedException(e); } }
Example #16
Source File: IvySettings.java From ant-ivy with Apache License 2.0 | 5 votes |
public synchronized DependencyResolver getDefaultResolver() { DependencyResolver r = getDictatorResolver(); if (r != null) { return r; } if (defaultResolver == null) { defaultResolver = resolversMap.get(defaultResolverName); } if (workspaceResolver != null && !(defaultResolver instanceof WorkspaceChainResolver)) { defaultResolver = new WorkspaceChainResolver(this, defaultResolver, workspaceResolver); } return defaultResolver; }
Example #17
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 5 votes |
public OrganisationEntry[] listOrganisationEntries() { Set<OrganisationEntry> entries = new HashSet<>(); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] orgs = resolver.listTokenValues( new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>()); for (Map<String, String> oe : orgs) { String org = oe.get(IvyPatternHelper.ORGANISATION_KEY); entries.add(new OrganisationEntry(resolver, org)); } } return entries.toArray(new OrganisationEntry[entries.size()]); }
Example #18
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Returns an empty array when no token values are found. * * @param token * ditto * @param otherTokenValues Map * @return String[] */ public String[] listTokenValues(String token, Map<String, Object> otherTokenValues) { Set<String> entries = new LinkedHashSet<>(); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] values = resolver.listTokenValues(new String[] {token}, otherTokenValues); for (Map<String, String> value : values) { entries.add(value.get(token)); } } return entries.toArray(new String[entries.size()]); }
Example #19
Source File: PomModuleDescriptorParserTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private IvySettings createIvySettingsForParentLicenseTesting(final String parentPomFileName, final String parentOrgName, final String parentModuleName) throws Exception { final URL parentPomURL = this.getClass().getResource(parentPomFileName); assertNotNull("Could not find " + parentPomFileName, parentPomURL); final PomReader parentPomReader = new PomReader(parentPomURL, new URLResource(parentPomURL)); final License[] parentLicenses = parentPomReader.getLicenses(); assertNotNull("Missing licenses in parent pom " + parentPomFileName, parentLicenses); assertEquals("Unexpected number of licenses in parent pom " + parentPomFileName, 1, parentLicenses.length); final DependencyResolver dependencyResolver = new MockedDependencyResolver() { @Override protected ModuleDescriptor getModuleDescriptor(DependencyDescriptor dependencyDescriptor) { final String depOrg = dependencyDescriptor.getDependencyId().getOrganisation(); final String depModuleName = dependencyDescriptor.getDependencyId().getName(); if (depOrg.equals(parentOrgName) && depModuleName.equals(parentModuleName)) { final DefaultModuleDescriptor moduleDescriptor = DefaultModuleDescriptor.newDefaultInstance(dependencyDescriptor.getDependencyRevisionId()); for (final License license : parentLicenses) { moduleDescriptor.addLicense(license); } return moduleDescriptor; } else { return super.getModuleDescriptor(dependencyDescriptor); } } }; final IvySettings ivySettings = new IvySettings(); ivySettings.setDictatorResolver(dependencyResolver); return ivySettings; }
Example #20
Source File: TestHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Fills a repository with a set of module, using empty files for published artifacts. * * @param resolver * the resolver to use to publish the modules * @param mds * the descriptors of the modules to put in the repository * @throws IOException * if an IO problem occurs while filling the repository */ public static void fillRepository(DependencyResolver resolver, Collection<ModuleDescriptor> mds) throws IOException { File tmp = File.createTempFile("ivy", "tmp"); try { for (ModuleDescriptor md : mds) { boolean overwrite = false; resolver.beginPublishTransaction(md.getModuleRevisionId(), overwrite); boolean published = false; try { XmlModuleDescriptorWriter.write(md, tmp); resolver.publish(md.getMetadataArtifact(), tmp, overwrite); tmp.delete(); tmp.createNewFile(); for (Artifact artifact : md.getAllArtifacts()) { resolver.publish(artifact, tmp, overwrite); } resolver.commitPublishTransaction(); published = true; } finally { if (!published) { resolver.abortPublishTransaction(); } } } } finally { tmp.delete(); } }
Example #21
Source File: ConfigureTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testTypedefWithCustomClasspath() throws Exception { Ivy ivy = new Ivy(); ivy.setVariable("ivy.custom.test.dir", new File("test/java/org/apache/ivy/core/settings") .toURI().toURL().toString()); ivy.configure(ConfigureTest.class.getResource("ivysettings-custom-typedef.xml")); DependencyResolver custom = ivy.getSettings().getResolver("custom"); assertNotNull(custom); assertEquals("org.apache.ivy.plugins.resolver.CustomResolver", custom.getClass().getName()); }
Example #22
Source File: ConfigureTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testTypedefWithCustomClasspathWithFile() throws Exception { Ivy ivy = new Ivy(); ivy.setVariable("ivy.custom.test.dir", new File("test/java/org/apache/ivy/core/settings").getAbsolutePath()); ivy.configure(ConfigureTest.class.getResource("ivysettings-custom-typedef2.xml")); DependencyResolver custom = ivy.getSettings().getResolver("custom"); assertNotNull(custom); assertEquals("org.apache.ivy.plugins.resolver.CustomResolver", custom.getClass().getName()); }
Example #23
Source File: ResolvedModuleRevision.java From ant-ivy with Apache License 2.0 | 5 votes |
public ResolvedModuleRevision(DependencyResolver resolver, DependencyResolver artifactResolver, ModuleDescriptor descriptor, MetadataArtifactDownloadReport report) { this.resolver = resolver; this.artifactResolver = artifactResolver; this.descriptor = descriptor; this.report = report; }
Example #24
Source File: UpdateSiteResolverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
private void genericTestResolveDownload(DependencyResolver resolver, ModuleRevisionId mrid) throws ParseException { ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data); assertNotNull(rmr); assertEquals(mrid, rmr.getId()); Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0]; DownloadReport report = resolver.download(new Artifact[] {artifact}, new 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}, new DownloadOptions()); assertNotNull(report); assertEquals(1, report.getArtifactsReports().length); ar = report.getArtifactReport(artifact); assertNotNull(ar); assertEquals(artifact, ar.getArtifact()); assertEquals(DownloadStatus.NO, ar.getDownloadStatus()); }
Example #25
Source File: DefaultArtifactRepositoryContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public DependencyResolver addBefore(Object userDescription, final String afterResolverName, Closure configureClosure) { if (!GUtil.isTrue(afterResolverName)) { throw new InvalidUserDataException("You must specify afterResolverName"); } DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.addBefore()"); final ArtifactRepository after = getByName(afterResolverName); return addCustomDependencyResolver(userDescription, configureClosure, new Action<ArtifactRepository>() { public void execute(ArtifactRepository repository) { DefaultArtifactRepositoryContainer.super.add(indexOf(after), repository); } }); }
Example #26
Source File: DefaultArtifactRepositoryContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public List<DependencyResolver> getResolvers() { DeprecationLogger.nagUserOfDiscontinuedMethod("ArtifactRepositoryContainer.getResolvers()"); List<DependencyResolver> returnedResolvers = new ArrayList<DependencyResolver>(); for (ArtifactRepository repository : this) { returnedResolvers.add(baseRepositoryFactory.toResolver(repository)); } return returnedResolvers; }
Example #27
Source File: OnlineXmlSettingsParserTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testIncludeHttpAbsoluteFile() throws Exception { // Use a settings file via http that use an include with absolute file // WARNING : this test will only work if the test are launched from the project root // directory configureURLHandler(); IvySettings settings = new IvySettings(); XmlSettingsParser parser = new XmlSettingsParser(settings); parser.parse(new URL( "http://ant.apache.org/ivy/test/ivysettings-include-http-absolute-file.xml")); DependencyResolver inc = settings.getResolver("includeworks"); assertNotNull(inc); assertTrue(inc instanceof ChainResolver); }
Example #28
Source File: IvyInternalPublisher.java From jeka with Apache License 2.0 | 5 votes |
private static void abortPublishTransaction(DependencyResolver resolver) { try { resolver.abortPublishTransaction(); } catch (final IOException e) { JkLog.warn("Publish transaction hasn't been properly aborted"); } }
Example #29
Source File: SearchEngine.java From ant-ivy with Apache License 2.0 | 5 votes |
public String[] listOrganisations() { Set<String> entries = new HashSet<>(); for (DependencyResolver resolver : settings.getResolvers()) { Map<String, String>[] orgs = resolver.listTokenValues( new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>()); for (Map<String, String> org : orgs) { entries.add(org.get(IvyPatternHelper.ORGANISATION_KEY)); } } return entries.toArray(new String[entries.size()]); }
Example #30
Source File: PomModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 4 votes |
private void addSourcesAndJavadocArtifactsIfPresent(PomModuleDescriptorBuilder mdBuilder, ParserSettings ivySettings) { if (mdBuilder.getMainArtifact() == null) { // no main artifact in pom, we don't need to search for meta artifacts return; } boolean sourcesLookup = !"false" .equals(ivySettings.getVariable("ivy.maven.lookup.sources")); boolean javadocLookup = !"false" .equals(ivySettings.getVariable("ivy.maven.lookup.javadoc")); if (!sourcesLookup && !javadocLookup) { Message.debug("Sources and javadocs lookup disabled"); return; } ModuleDescriptor md = mdBuilder.getModuleDescriptor(); ModuleRevisionId mrid = md.getModuleRevisionId(); DependencyResolver resolver = ivySettings.getResolver(mrid); if (resolver == null) { Message.debug( "no resolver found for " + mrid + ": no source or javadoc artifact lookup"); } else { ArtifactOrigin mainArtifact = resolver.locate(mdBuilder.getMainArtifact()); if (!ArtifactOrigin.isUnknown(mainArtifact)) { String mainArtifactLocation = mainArtifact.getLocation(); if (sourcesLookup) { ArtifactOrigin sourceArtifact = resolver.locate(mdBuilder.getSourceArtifact()); if (!ArtifactOrigin.isUnknown(sourceArtifact) && !sourceArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("source artifact found for " + mrid); mdBuilder.addSourceArtifact(); } else { // it seems that sometimes the 'src' classifier is used instead of 'sources' // Cfr. IVY-1138 ArtifactOrigin srcArtifact = resolver.locate(mdBuilder.getSrcArtifact()); if (!ArtifactOrigin.isUnknown(srcArtifact) && !srcArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("source artifact found for " + mrid); mdBuilder.addSrcArtifact(); } else { Message.debug("no source artifact found for " + mrid); } } } else { Message.debug("sources lookup disabled"); } if (javadocLookup) { ArtifactOrigin javadocArtifact = resolver .locate(mdBuilder.getJavadocArtifact()); if (!ArtifactOrigin.isUnknown(javadocArtifact) && !javadocArtifact.getLocation().equals(mainArtifactLocation)) { Message.debug("javadoc artifact found for " + mrid); mdBuilder.addJavadocArtifact(); } else { Message.debug("no javadoc artifact found for " + mrid); } } else { Message.debug("javadocs lookup disabled"); } } } }