Skip to content

Commit

Permalink
Fix eclipse-tycho#537 - inherit version/group from parent
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
  • Loading branch information
laeubi committed Jan 31, 2022
1 parent d5c0c2c commit 249cd4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 Christoph Läubrich and others.
* Copyright (c) 2020, 2022 Christoph Läubrich and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -186,6 +186,9 @@ public static Version createOSGiVersionFromArtifact(IArtifactFacade mavenArtifac
}

protected static Version createOSGiVersionFromMaven(String version) {
if (version == null) {
return Version.emptyVersion;
}
try {
int index = version.indexOf('-');
if (index > -1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 Christoph Läubrich and others.
* Copyright (c) 2020, 2022 Christoph Läubrich and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -36,6 +36,7 @@
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.RepositorySystem;
Expand Down Expand Up @@ -188,7 +189,14 @@ public String getName() {

@Override
public String getGroupId() {
return model.getGroupId();
String groupId = model.getGroupId();
if (groupId == null || groupId.isBlank()) {
Parent parent = model.getParent();
if (parent != null) {
return parent.getGroupId();
}
}
return groupId;
}

@Override
Expand All @@ -198,7 +206,14 @@ public String getArtifactId() {

@Override
public String getVersion() {
return model.getVersion();
String version = model.getVersion();
if (version == null || version.isBlank()) {
Parent parent = model.getParent();
if (parent != null) {
return parent.getVersion();
}
}
return version;
}

@Override
Expand Down

0 comments on commit 249cd4b

Please sign in to comment.