Java Code Examples for org.apache.maven.model.Dependency#getGroupId()
The following examples show how to use
org.apache.maven.model.Dependency#getGroupId() .
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: 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 2
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 3
Source File: SimpleScopedArtifactRef.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
public SimpleScopedArtifactRef( final Dependency dependency ) { super( dependency.getGroupId(), dependency.getArtifactId(), isEmpty( dependency.getVersion() ) ? "*" : dependency.getVersion(), dependency.getType(), dependency.getClassifier()); this.scope = dependency.getScope(); }
Example 4
Source File: GenerateMetadataMojo.java From syndesis with Apache License 2.0 | 5 votes |
private Artifact toArtifact(final Dependency dependency) { final ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); final ArtifactType type = registry.get(dependency.getType()); return new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), type.getExtension(), dependency.getVersion(), type); }
Example 5
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 6
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 7
Source File: PomHelper.java From versions-maven-plugin with Apache License 2.0 | 4 votes |
private static void addDependencyAssocations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator, Map<String, PropertyVersionsBuilder> result, List<Dependency> dependencies, boolean usePluginRepositories ) throws ExpressionEvaluationException { if ( dependencies == null ) { return; } for ( Dependency dependency : dependencies ) { String version = dependency.getVersion(); if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 ) { version = StringUtils.deleteWhitespace( version ); for ( PropertyVersionsBuilder property : result.values() ) { final String propertyRef = "${" + property.getName() + "}"; if ( version.contains( propertyRef ) ) { // Any of these could be defined by a property String groupId = dependency.getGroupId(); if ( groupId == null || groupId.trim().length() == 0 ) { // malformed pom continue; } else { groupId = (String) expressionEvaluator.evaluate( groupId ); } String artifactId = dependency.getArtifactId(); if ( artifactId == null || artifactId.trim().length() == 0 ) { // malformed pom continue; } else { artifactId = (String) expressionEvaluator.evaluate( artifactId ); } // might as well capture the current value VersionRange versionRange = VersionRange.createFromVersion( (String) expressionEvaluator.evaluate( dependency.getVersion() ) ); property.addAssociation( helper.createDependencyArtifact( groupId, artifactId, versionRange, dependency.getType(), dependency.getClassifier(), dependency.getScope(), dependency.isOptional() ), usePluginRepositories ); if ( !propertyRef.equals( version ) ) { addBounds( property, version, propertyRef, versionRange.toString() ); } } } } } }
Example 8
Source File: Pom.java From buck with Apache License 2.0 | 4 votes |
public DepKey(Dependency dependency) { groupId = dependency.getGroupId(); artifactId = dependency.getArtifactId(); validate(); }
Example 9
Source File: LocationAwareMavenXpp3Writer.java From netbeans with Apache License 2.0 | 4 votes |
private void writeDependency(Dependency dependency, String tagName, XmlSerializer serializer) throws java.io.IOException { serializer.startTag(NAMESPACE, tagName); flush(serializer); StringBuffer b = b(serializer); int start = b.length(); if (dependency.getGroupId() != null) { writeValue(serializer, "groupId", dependency.getGroupId(), dependency); } if (dependency.getArtifactId() != null) { writeValue(serializer, "artifactId", dependency.getArtifactId(), dependency); } if (dependency.getVersion() != null) { writeValue(serializer, "version", dependency.getVersion(), dependency); } if ((dependency.getType() != null) && !dependency.getType().equals("jar")) { writeValue(serializer, "type", dependency.getType(), dependency); } if (dependency.getClassifier() != null) { writeValue(serializer, "classifier", dependency.getClassifier(), dependency); } if (dependency.getScope() != null) { writeValue(serializer, "scope", dependency.getScope(), dependency); } if (dependency.getSystemPath() != null) { writeValue(serializer, "systemPath", dependency.getSystemPath(), dependency); } if ((dependency.getExclusions() != null) && (dependency.getExclusions().size() > 0)) { serializer.startTag(NAMESPACE, "exclusions"); for (Iterator<Exclusion> iter = dependency.getExclusions().iterator(); iter.hasNext();) { Exclusion o = iter.next(); writeExclusion(o, "exclusion", serializer); } serializer.endTag(NAMESPACE, "exclusions"); } if (dependency.getOptional() != null) { writeValue(serializer, "optional", dependency.getOptional(), dependency); } serializer.endTag(NAMESPACE, tagName).flush(); logLocation(dependency, "", start, b.length()); }
Example 10
Source File: ArtifactHelper.java From maven-dependency-mapper with GNU Lesser General Public License v3.0 | 4 votes |
public static String getId(Dependency dependency){ return dependency.getGroupId() + ":"+ dependency.getArtifactId()+ ":" + dependency.getVersion(); }
Example 11
Source File: AddDependencyPanel.java From netbeans with Apache License 2.0 | 4 votes |
private NBVersionInfo convert2VInfo(Dependency dep) { return new NBVersionInfo(null, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getType(), null, null, null, dep.getClassifier()); }
Example 12
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 13
Source File: Detect.java From Poseidon with Apache License 2.0 | 4 votes |
private Artifact getArtifact(Dependency dependency) { return new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), null, dependency.getVersion()); }
Example 14
Source File: AbstractPomCopyDependencies.java From butterfly with MIT License | 4 votes |
private String getDependencyString(Dependency dependency) { return dependency.getGroupId() + ":" + dependency.getArtifactId(); }
Example 15
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 16
Source File: LocalProject.java From quarkus with Apache License 2.0 | 4 votes |
private AppArtifactKey getKey(Dependency dep) { return new AppArtifactKey(PROJECT_GROUPID.equals(dep.getGroupId()) ? getGroupId() : dep.getGroupId(), dep.getArtifactId()); }
Example 17
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 18
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 19
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 20
Source File: Extensions.java From quarkus with Apache License 2.0 | 4 votes |
public static AppArtifactKey toKey(final Dependency dependency) { return new AppArtifactKey(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType()); }