Java Code Examples for org.apache.maven.model.Model#getGroupId()
The following examples show how to use
org.apache.maven.model.Model#getGroupId() .
These examples are extracted from open source projects.
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 Project: quarkus File: QuarkusJsonPlatformDescriptorResolver.java License: Apache License 2.0 | 6 votes |
private static String getGroupId(Model model) { if (model == null) { return null; } String groupId = model.getGroupId(); if (groupId != null) { return groupId; } final Parent parent = model.getParent(); if (parent != null) { groupId = parent.getGroupId(); if (groupId != null) { return groupId; } } throw new IllegalStateException("Failed to determine the groupId for the POM of " + model.getArtifactId()); }
Example 2
Source Project: carnotzet File: CarnotzetModuleCoordinates.java License: Apache License 2.0 | 6 votes |
public static CarnotzetModuleCoordinates fromPom(@NonNull Path pom) { Model result; try { BufferedReader in = new BufferedReader(Files.newBufferedReader(pom, StandardCharsets.UTF_8)); MavenXpp3Reader reader = new MavenXpp3Reader(); result = reader.read(in); } catch (XmlPullParserException | IOException e) { throw new CarnotzetDefinitionException(e); } String groupId = result.getGroupId(); String version = result.getVersion(); if (groupId == null) { groupId = result.getParent().getGroupId(); } if (version == null) { version = result.getParent().getVersion(); } return new CarnotzetModuleCoordinates(groupId, result.getArtifactId(), version, null); }
Example 3
Source Project: maven-git-versioning-extension File: GAV.java License: MIT License | 6 votes |
public static GAV of(Model model) { String groupId = model.getGroupId(); String artifactId = model.getArtifactId(); String version = model.getVersion(); Parent parent = model.getParent(); if (parent != null) { if (groupId == null) { groupId = parent.getGroupId(); } if (version == null) { version = parent.getVersion(); } } return new GAV(groupId, artifactId, version); }
Example 4
Source Project: quarkus File: ModelUtils.java License: Apache License 2.0 | 5 votes |
public static String getGroupId(Model model) { String groupId = model.getGroupId(); if (groupId != null) { return groupId; } final Parent parent = model.getParent(); if (parent != null) { groupId = parent.getGroupId(); if (groupId != null) { return groupId; } } throw new IllegalStateException("Failed to determine groupId for project model"); }
Example 5
Source Project: spring-cloud-release-tools File: ProjectVersion.java License: Apache License 2.0 | 5 votes |
private String groupId(Model model) { if (model == null) { return ""; } if (StringUtils.hasText(model.getGroupId())) { return model.getGroupId(); } if (model.getParent() != null && StringUtils.hasText(model.getParent().getGroupId())) { return model.getParent().getGroupId(); } return ""; }
Example 6
Source Project: spring-cloud-release-tools File: PomUpdater.java License: Apache License 2.0 | 5 votes |
private String groupId(Model model) { if (hasText(model.getGroupId())) { return model.getGroupId(); } if (model.getParent() != null) { return model.getParent().getGroupId(); } return ""; }
Example 7
Source Project: unleash-maven-plugin File: AbstractVersionsStep.java License: 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 8
Source Project: nexus-public File: MavenUploadHandler.java License: Eclipse Public License 1.0 | 5 votes |
private String getGroupId(Model model) { String groupId = model.getGroupId(); if (groupId == null && model.getParent() != null) { groupId = model.getParent().getGroupId(); } return groupId; }
Example 9
Source Project: versions-maven-plugin File: PomHelper.java License: Apache License 2.0 | 5 votes |
/** * Extracts the groupId from a raw model, interpolating from the parent if necessary. * * @param model The model. * @return The groupId. */ public static String getGroupId( Model model ) { String targetGroupId = model.getGroupId(); if ( targetGroupId == null && model.getParent() != null ) { targetGroupId = model.getParent().getGroupId(); } return targetGroupId; }
Example 10
Source Project: maven-repository-tools File: MavenRepositoryDeployer.java License: Eclipse Public License 1.0 | 5 votes |
public static Gav getCoordinates ( File pomFile ) throws Exception { BufferedReader in = new BufferedReader( new FileReader( pomFile ) ); MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read( in ); // get coordinates and take care of inheritance and default String g = model.getGroupId(); if ( StringUtils.isEmpty( g ) ) { g = model.getParent().getGroupId(); } String a = model.getArtifactId(); if ( StringUtils.isEmpty( a ) ) { a = model.getParent().getArtifactId(); } String v = model.getVersion(); if ( StringUtils.isEmpty( v ) ) { v = model.getParent().getVersion(); } String p = model.getPackaging(); if ( StringUtils.isEmpty( p ) ) { p = MavenConstants.JAR; } Gav gav = new Gav( g, a, v, p ); return gav; }
Example 11
Source Project: quarkus File: MojoUtils.java License: Apache License 2.0 | 4 votes |
public static String[] readGavFromPom(final InputStream resourceAsStream) throws IOException { Model model = readPom(resourceAsStream); return new String[] { model.getGroupId(), model.getArtifactId(), model.getVersion() }; }
Example 12
Source Project: quarkus File: CreateExtensionMojo.java License: Apache License 2.0 | 4 votes |
static String getGroupId(Model basePom) { return basePom.getGroupId() != null ? basePom.getGroupId() : basePom.getParent() != null && basePom.getParent().getGroupId() != null ? basePom.getParent().getGroupId() : null; }
Example 13
Source Project: flatten-maven-plugin File: PomProperty.java License: Apache License 2.0 | 4 votes |
@Override public String get( Model model ) { return model.getGroupId(); }