Java Code Examples for org.apache.maven.model.Dependency#getArtifactId()
The following examples show how to use
org.apache.maven.model.Dependency#getArtifactId() .
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: BomGeneratorMojo.java From camel-spring-boot with Apache License 2.0 | 6 votes |
private Set<String> getProvidedDependencyManagement(String groupId, String artifactId, String version, Set<String> gaChecked) throws Exception { String ga = groupId + ":" + artifactId; gaChecked.add(ga); Artifact bom = resolveArtifact(groupId, artifactId, version, "pom"); MavenProject bomProject = loadExternalProjectPom(bom.getFile()); Set<String> provided = new HashSet<>(); if (bomProject.getDependencyManagement() != null && bomProject.getDependencyManagement().getDependencies() != null) { for (Dependency dep : bomProject.getDependencyManagement().getDependencies()) { if ("pom".equals(dep.getType()) && "import".equals(dep.getScope())) { String subGa = dep.getGroupId() + ":" + dep.getArtifactId(); if (!gaChecked.contains(subGa)) { Set<String> sub = getProvidedDependencyManagement(dep.getGroupId(), dep.getArtifactId(), resolveVersion(bomProject, dep.getVersion()), gaChecked); provided.addAll(sub); } } else { provided.add(comparisonKey(dep)); } } } return provided; }
Example 2
Source File: RepositoryModelResolver.java From archiva with Apache License 2.0 | 6 votes |
public ModelSource resolveModel(Dependency dependency) throws UnresolvableModelException { try { Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), "", "pom", dependency.getVersion()); VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifact, null, null); VersionRangeResult versionRangeResult = this.versionRangeResolver.resolveVersionRange(this.session, versionRangeRequest); if (versionRangeResult.getHighestVersion() == null) { throw new UnresolvableModelException(String.format("No versions matched the requested dependency version range '%s'", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); } else if (versionRangeResult.getVersionConstraint() != null && versionRangeResult.getVersionConstraint().getRange() != null && versionRangeResult.getVersionConstraint().getRange().getUpperBound() == null) { throw new UnresolvableModelException(String.format("The requested dependency version range '%s' does not specify an upper bound", dependency.getVersion()), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); } else { dependency.setVersion(versionRangeResult.getHighestVersion().toString()); return this.resolveModel(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); } } catch (VersionRangeResolutionException var5) { throw new UnresolvableModelException(var5.getMessage(), dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), var5); } }
Example 3
Source File: PropertyInterpolatorTest.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
@Test public void testInteropolateDependencies() throws Exception { final Model model = TestUtils.resolveModelResource( RESOURCE_BASE, "infinispan-bom-8.2.0.Final.pom" ); Project project = new Project( model ); PropertyInterpolator pi = new PropertyInterpolator( project.getModel().getProperties(), project ); String nonInterp = "", interp = ""; // Explicitly calling the non-resolved model dependencies... for ( Dependency d : project.getModel().getDependencyManagement().getDependencies() ) { nonInterp += ( d.getGroupId().equals( "${project.groupId}" ) ? project.getGroupId() : d.getGroupId() ) + ":" + ( d.getArtifactId().equals( "${project.artifactId}" ) ? project.getArtifactId() : d.getArtifactId() ) + System.lineSeparator(); interp += pi.interp( d.getGroupId().equals( "${project.groupId}" ) ? project.getGroupId() : d.getGroupId() ) + ":" + pi.interp( d.getArtifactId().equals( "${project.artifactId}" ) ? project.getArtifactId() : d.getArtifactId() ) + System.lineSeparator(); } assertTrue( nonInterp.contains( "${" ) ); assertFalse( interp.contains( "${" ) ); }
Example 4
Source File: UpdateExtensionDocPageMojo.java From camel-quarkus with Apache License 2.0 | 6 votes |
static boolean detectNativeSsl(Path sourceTreeRoot, Path basePath, String artifactId, List<Dependency> dependencies, Map<String, Boolean> cache) { if (cache.computeIfAbsent(artifactId, aid -> detectNativeSsl(basePath.resolve("../deployment").toAbsolutePath().normalize()))) { return true; } for (Dependency dependency : dependencies) { if ("org.apache.camel.quarkus".equals(dependency.getGroupId()) && !dependency.getArtifactId().endsWith("-component")) { final String depArtifactId = dependency.getArtifactId(); if (cache.computeIfAbsent( depArtifactId, aid -> detectNativeSsl( CqUtils.findExtensionDirectory(sourceTreeRoot, depArtifactId).resolve("deployment")))) { return true; } } } return false; }
Example 5
Source File: AbstractVersionsStep.java From unleash-maven-plugin with Eclipse Public License 1.0 | 5 votes |
private boolean isReactorDependency(MavenProject project, Dependency dependency) { String groupId = dependency.getGroupId(); String artifactId = dependency.getArtifactId(); Model model = this.rawModels.getUnchecked(project); String reactorGroupId = model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId(); String reactorArtifactId = model.getArtifactId(); return Objects.equals(groupId, reactorGroupId) && Objects.equals(artifactId, reactorArtifactId); }
Example 6
Source File: VdbCodeGeneratorMojo.java From teiid-spring-boot with Apache License 2.0 | 5 votes |
private boolean generateOpenApiScoffolding() { List<Dependency> dependencies = project.getDependencies(); for (Dependency d : dependencies) { String gav = d.getGroupId() + ":" + d.getArtifactId(); if (gav.equals("org.teiid:spring-openapi")) { getLog().info("OpenAPI dependency is found in the pom.xml"); return true; } } getLog().info("No OpenAPI dependency is found in the pom.xml, skipping the generation of the OpenAPI classes"); return false; }
Example 7
Source File: SearchClassDependencyInRepo.java From netbeans with Apache License 2.0 | 5 votes |
private Collection<NBVersionInfo> filter(NbMavenProject mavProj, List<NBVersionInfo> nbvis, boolean test) { Map<String, NBVersionInfo> items = new HashMap<String, NBVersionInfo>(); //check dependency already added List<Dependency> dependencies = new ArrayList<Dependency>(); MavenProject prj = mavProj.getMavenProject(); if (test) { dependencies.addAll(prj.getTestDependencies()); } else { dependencies.addAll(prj.getDependencies()); } for (NBVersionInfo info : nbvis) { String key = info.getGroupId() + ":" + info.getArtifactId(); boolean b = items.containsKey(key); if (!b) { items.put(key, info); } for (Dependency dependency : dependencies) { //check group id and ArtifactId and Scope even if (dependency.getGroupId() != null && dependency.getGroupId().equals(info.getGroupId())) { if (dependency.getArtifactId() != null && dependency.getArtifactId().equals(info.getArtifactId())) { if (!test && dependency.getScope() != null && ("compile".equals(dependency.getScope()))) {//NOI18N return Collections.emptyList(); } } } } } List<NBVersionInfo> filterd = new ArrayList<NBVersionInfo>(items.values()); return filterd; }
Example 8
Source File: MavenNbmGrammar.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Enumeration<GrammarResult> getDynamicValueCompletion(String path, HintContext hintCtx, Element lowestParent) { if ("/nbm/dependencies/dependency/type".equals(path)) { //NOI18N return createTextValueList(new String[] { "spec", //NOI18N "impl", //NOI18N "loose" //NOI18N }, hintCtx); } if ("/nbm/moduleType".equals(path)) { //NOI18N return createTextValueList(new String[] { "normal", //NOI18N "autoload", //NOI18N "eager" //NOI18N }, hintCtx); } if ("/nbm/dependencies/dependency/id".equals(path) || //NOI18N "/nbm/libraries/library".equals(path)) { //NOI18N //TODO could be nice to filter out the dependencies that are already being used.. List<GrammarResult> toRet = new ArrayList<GrammarResult>(); MavenProject project = getMavenProject(); if (project != null) { @SuppressWarnings("unchecked") Iterator<Dependency> it = project.getCompileDependencies().iterator(); while (it.hasNext()) { Dependency elem = it.next(); String str = elem.getGroupId() + ":" + elem.getArtifactId(); //NOI18N if (str.startsWith(hintCtx.getCurrentPrefix())) { toRet.add(new MyTextElement(str, hintCtx.getCurrentPrefix())); } } } return Collections.enumeration(toRet); } return null; }
Example 9
Source File: DevMojo.java From quarkus with Apache License 2.0 | 4 votes |
private List<LocalProject> filterExtensionDependencies(LocalProject localProject) { List<LocalProject> ret = new ArrayList<>(); Queue<LocalProject> toRemove = new ArrayDeque<>(); Set<AppArtifactKey> extensionsAndDeps = new HashSet<>(); Set<AppArtifactKey> inProject = new HashSet<>(); for (LocalProject project : localProject.getSelfWithLocalDeps()) { inProject.add(project.getKey()); final Artifact projectDep = this.project.getArtifactMap().get(project.getGroupId() + ':' + project.getArtifactId()); if (project.getClassesDir() != null && ( // if it is not found among project.getArtifacts() it shouldn't be included (e.g. a local test dependency) (localProject != project && projectDep == null) //if this project also contains Quarkus extensions we do no want to include these in the discovery //a bit of an edge case, but if you try and include a sample project with your extension you will //run into problems without this || (Files.exists(project.getClassesDir().resolve("META-INF/quarkus-extension.properties")) || Files.exists(project.getClassesDir().resolve("META-INF/quarkus-build-steps.list"))))) { toRemove.add(project); extensionsAndDeps.add(project.getKey()); } else { ret.add(project); } } if (toRemove.isEmpty()) { return ret; } //we also remove transitive deps of the extensions //this is common in projects that provide a library, and a quarkus extension for that library //all in the same project while (!toRemove.isEmpty()) { LocalProject dep = toRemove.poll(); //we don't need to resolve deps properly, this is all in the same project //so we have all the info we need locally for (Dependency i : dep.getRawModel().getDependencies()) { AppArtifactKey key = new AppArtifactKey(i.getGroupId(), i.getArtifactId()); if (inProject.contains(key) && !extensionsAndDeps.contains(key)) { extensionsAndDeps.add(key); toRemove.add(localProject.getWorkspace().getProject(key)); } } } Iterator<LocalProject> iterator = ret.iterator(); while (iterator.hasNext()) { LocalProject obj = iterator.next(); if (extensionsAndDeps.contains(obj.getKey())) { getLog().warn("Local Quarkus extension dependency " + obj.getKey() + " will not be hot-reloadable"); iterator.remove(); } } return ret; }
Example 10
Source File: AbstractPomCopyDependencies.java From butterfly with MIT License | 4 votes |
private String getDependencyString(Dependency dependency) { return dependency.getGroupId() + ":" + dependency.getArtifactId(); }
Example 11
Source File: GenerateBomMojo.java From sundrio with Apache License 2.0 | 4 votes |
private static String dependencyKey(Dependency dependency) { return dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getType() + ":" + dependency.getClassifier(); }
Example 12
Source File: PomCopyDependenciesTest.java From butterfly with MIT License | 4 votes |
private String s(Dependency dependency) { return dependency.getGroupId() + ":" + dependency.getArtifactId(); }
Example 13
Source File: CombinedQuarkusPlatformDescriptor.java From quarkus with Apache License 2.0 | 4 votes |
DepKey(Dependency dep) { this(dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getType()); }
Example 14
Source File: MavenAssemblyGrammar.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected Enumeration<GrammarResult> getDynamicValueCompletion(String path, HintContext virtualTextCtx, Element element) { if ("/assembly/dependencySets/dependencySet/includes/include".equals(path) || //NOI18N "/assembly/dependencySets/dependencySet/excludes/exclude".equals(path)) { //NOI18N //TODO could be nice to filter out the dependencies that are already being used.. List<GrammarResult> toRet = new ArrayList<GrammarResult>(); MavenProject project = getMavenProject(); if (project != null) { Node previous; // HACK.. if currentPrefix is zero length, the context is th element, otherwise it's the content inside if (virtualTextCtx.getCurrentPrefix().length() == 0) { previous = virtualTextCtx.getParentNode().getParentNode(); } else { previous = virtualTextCtx.getParentNode().getParentNode().getParentNode(); } previous = previous.getPreviousSibling(); String scope = null; while (previous != null) { if (previous instanceof org.w3c.dom.Element) { org.w3c.dom.Element el = (org.w3c.dom.Element)previous; NodeList lst = el.getChildNodes(); if (lst.getLength() > 0) { if ("scope".equals(el.getNodeName())) { //NOI18N scope = lst.item(0).getNodeValue(); break; } } } previous = previous.getPreviousSibling(); } if (scope == null) { scope = "runtime"; //NOI18N } scope = scope.trim(); Iterator it; if ("runtime".equals(scope)) { //NOI18N it = project.getRuntimeDependencies().iterator(); } else if ("test".equals(scope)) { //NOI18N it = project.getTestDependencies().iterator(); } else if ("compile".equals(scope)) { //NOI18N it = project.getCompileDependencies().iterator(); } else { ErrorManager.getDefault().log(ErrorManager.WARNING, "How to process includes/excludes for scope '" + scope + "'? Fallback to 'runtime'."); //NOI18N it = project.getRuntimeDependencies().iterator(); } while (it.hasNext()) { Dependency elem = (Dependency) it.next(); String str = elem.getGroupId() + ":" + elem.getArtifactId(); //NOI18N if (str.startsWith(virtualTextCtx.getCurrentPrefix())) { toRet.add(new MyTextElement(str, virtualTextCtx.getCurrentPrefix())); } } } return Collections.enumeration(toRet); } return null; }
Example 15
Source File: CombinedQuarkusPlatformDescriptorTest.java From quarkus with Apache License 2.0 | 4 votes |
private static String getGa(Dependency d) { return d.getGroupId() + ":" + d.getArtifactId(); }
Example 16
Source File: Extensions.java From quarkus with Apache License 2.0 | 4 votes |
public static AppArtifactCoords toCoords(final Dependency d) { return new AppArtifactCoords(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion()); }
Example 17
Source File: MavenUtils.java From developer-studio with Apache License 2.0 | 4 votes |
private static String getDependencyString(Dependency dependency) { String ds=dependency.getGroupId()+":"+dependency.getArtifactId()+":"+dependency.getVersion()+":"+dependency.getType()+":"; return ds; }
Example 18
Source File: BomGeneratorMojo.java From camel-spring-boot with Apache License 2.0 | 4 votes |
private String comparisonKey(Dependency dependency) { return dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + (dependency.getType() != null ? dependency.getType() : "jar"); }
Example 19
Source File: MavenHelper.java From updatebot with Apache License 2.0 | 4 votes |
public static MavenArtifactKey toMavenDependency(Dependency dependency) { return new MavenArtifactKey(dependency.getGroupId(), dependency.getArtifactId()); }
Example 20
Source File: CompareDependenciesMojo.java From versions-maven-plugin with Apache License 2.0 | 2 votes |
/** * Create a simple message describing the version diff * * @param dep * @param remoteVersion * @return The message */ private StringBuilder writeDependencyDiffMessage( Dependency dep, String remoteVersion ) { String id = dep.getGroupId() + ":" + dep.getArtifactId(); return writeDiffMessage( id, dep.getVersion(), remoteVersion ); }