-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic changes to integrate the new platform model based on the decomp…
…osed 'universe' BOM
- Loading branch information
1 parent
861ace7
commit 994b99f
Showing
37 changed files
with
1,551 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...t-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package io.quarkus.bootstrap.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class PlatformInfo { | ||
|
||
private final String key; | ||
private final List<PlatformStreamInfo> streams = new ArrayList<>(1); // most of the time there will be only one | ||
|
||
public PlatformInfo(String key) { | ||
this.key = key; | ||
} | ||
|
||
public String getPlatformKey() { | ||
return key; | ||
} | ||
|
||
public boolean isAligned(Collection<AppArtifactCoords> importedBoms) { | ||
if (streams.isEmpty()) { | ||
return true; | ||
} | ||
if (streams.size() > 1) { | ||
return false; | ||
} | ||
return streams.get(0).isAligned(importedBoms); | ||
} | ||
|
||
public List<List<String>> getPossibleAlignments(Collection<AppArtifactCoords> importedPlatformBoms) { | ||
if (streams.size() > 1) { | ||
final StringBuilder buf = new StringBuilder(); | ||
buf.append("Imported BOMs "); | ||
final Iterator<AppArtifactCoords> it = importedPlatformBoms.iterator(); | ||
if (it.hasNext()) { | ||
buf.append(it.next()); | ||
while (it.hasNext()) { | ||
buf.append(", ").append(it.next()); | ||
} | ||
} | ||
buf.append(" belong to different platform streams ").append(streams.get(0)); | ||
for (int i = 1; i < streams.size(); ++i) { | ||
buf.append(", ").append(streams.get(i)); | ||
} | ||
throw new RuntimeException(buf.append(" while only one stream per platform is allowed.").toString()); | ||
} | ||
return streams.get(0).getPossibleAlignemnts(importedPlatformBoms); | ||
} | ||
|
||
PlatformStreamInfo getOrCreateStream(String stream) { | ||
PlatformStreamInfo s = getStream(stream); | ||
if (s == null) { | ||
s = new PlatformStreamInfo(stream); | ||
streams.add(s); | ||
} | ||
return s; | ||
} | ||
|
||
Collection<PlatformStreamInfo> getStreams() { | ||
return streams; | ||
} | ||
|
||
PlatformStreamInfo getStream(String stream) { | ||
for (PlatformStreamInfo s : streams) { | ||
if (s.getId().equals(stream)) { | ||
return s; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...cts/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformReleaseInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.quarkus.bootstrap.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Platform release info that is encoded into a property in a platform properties artifact | ||
* following the format {@code platform.release-info@<platform-key>$<stream>#<version>=<bom-coords>(,<bom-coords>)} | ||
*/ | ||
public class PlatformReleaseInfo { | ||
|
||
private final String platformKey; | ||
private final String stream; | ||
private final String version; | ||
private final List<AppArtifactCoords> boms; | ||
|
||
PlatformReleaseInfo(String platformKey, String stream, String version, String boms) { | ||
this.platformKey = platformKey; | ||
this.stream = stream; | ||
this.version = version; | ||
final String[] bomCoords = boms.split(","); | ||
this.boms = new ArrayList<>(bomCoords.length); | ||
for (String s : bomCoords) { | ||
this.boms.add(AppArtifactCoords.fromString(s)); | ||
} | ||
} | ||
|
||
/** | ||
* The platform key. Could be the {@code groupId} of the stack, e.g. {@code io.quarkus.platform} | ||
* | ||
* @return platform key | ||
*/ | ||
public String getPlatformKey() { | ||
return platformKey; | ||
} | ||
|
||
/** | ||
* Platform stream. Could be the {@code major.minor} part of the platform release version. | ||
* | ||
* @return platform stream | ||
*/ | ||
public String getStream() { | ||
return stream; | ||
} | ||
|
||
/** | ||
* The version of the platform in a stream. Ideally, the micro version to make the comparisons easier. | ||
* | ||
* @return version in the stream | ||
*/ | ||
public String getVersion() { | ||
return version; | ||
} | ||
|
||
/** | ||
* Member BOM coordinates. | ||
* | ||
* @return member BOM coordinates | ||
*/ | ||
public List<AppArtifactCoords> getBoms() { | ||
return boms; | ||
} | ||
|
||
String getPropertyName() { | ||
final StringBuilder buf = new StringBuilder(); | ||
buf.append(PlatformReleases.PROPERTY_PREFIX).append(platformKey).append(PlatformReleases.PLATFORM_KEY_STREAM_SEPARATOR) | ||
.append(stream) | ||
.append(PlatformReleases.STREAM_VERSION_SEPARATOR).append(version); | ||
return buf.toString(); | ||
} | ||
|
||
String getPropertyValue() { | ||
final StringBuilder buf = new StringBuilder(); | ||
final List<AppArtifactCoords> boms = getBoms(); | ||
if (!boms.isEmpty()) { | ||
buf.append(boms.get(0).toString()); | ||
for (int i = 1; i < boms.size(); ++i) { | ||
buf.append(',').append(boms.get(i)); | ||
} | ||
} | ||
return buf.toString(); | ||
} | ||
|
||
public String toString() { | ||
return getPropertyName() + '=' + getPropertyValue(); | ||
} | ||
} |
Oops, something went wrong.