Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jakartaee8 platform for versionless #30017

Open
wants to merge 3 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Subsystem-Version: 8.0.0
kind=ga
edition=core
WLP-Activation-Type: parallel
WLP-Platform: javaee-8.0
WLP-Platform: javaee-8.0,jakartaee-8.0
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ private Collection<String> collectConfiguredPlatforms(Repository repo, Collectio

for (String plat : rootPlatforms) {
//needs check for duplicate platforms with different versions, ex. can't have javaee7.0 and javaee8.0
plat = plat.trim();

ProvisioningFeatureDefinition platformFeature = allCompatibilityFeatures.get(plat.toLowerCase());
ProvisioningFeatureDefinition platformFeature = allCompatibilityFeatures.get(plat);

if (platformFeature == null) {
selectionContext.getResult().addMissingPlatform(plat);
Expand Down Expand Up @@ -416,6 +414,19 @@ private boolean featureListContainsFeatureBaseName(Collection<String> featureLis
return false;
}

/**
* Trim and lowercase the platform list
* @param rootPlatforms
* @return
*/
private List<String> normalizeRootPlatforms(Collection<String> rootPlatforms){
List<String> normalizedPlatforms = new ArrayList<String>();
for(String plat : rootPlatforms){
normalizedPlatforms.add(plat.trim().toLowerCase());
}
return normalizedPlatforms;
}

//////// BEGIN - deprecated resolveFeatures() methods without platforms

@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -571,15 +582,17 @@ public Result doResolve(Repository repository,
Collection<String> rootPlatforms) {

SelectionContext selectionContext = new SelectionContext(repository, allowedMultipleVersions, supportedProcessTypes);
Collection<String> rootPlatformFeatures = new ArrayList<String>();

if (hasRootVersionlessFeatures(repository, rootFeatures)) {
selectionContext.setHasVersionlessFeatures();
processCompatibilityFeatures(repository.getFeatures());

rootPlatforms = collectConfiguredPlatforms(repository, rootPlatforms, selectionContext);
rootPlatforms.addAll(collectEnvironmentPlatforms(repository, rootPlatforms, selectionContext));
rootPlatforms.addAll(collectFeaturePlatforms(repository, rootPlatforms, rootFeatures, selectionContext));
for (String platform : rootPlatforms) {
rootPlatforms = normalizeRootPlatforms(rootPlatforms);
rootPlatformFeatures = collectConfiguredPlatforms(repository, rootPlatforms, selectionContext);
rootPlatformFeatures.addAll(collectEnvironmentPlatforms(repository, rootPlatformFeatures, selectionContext));
rootPlatformFeatures.addAll(collectFeaturePlatforms(repository, rootPlatformFeatures, rootFeatures, selectionContext));
for (String platform : rootPlatformFeatures) {
selectionContext.getResult().addResolvedPlatform(repository.getFeature(platform).getPlatformName());
}
}
Expand All @@ -595,8 +608,8 @@ public Result doResolve(Repository repository,
// This will ensure that the root and pre-resolved features do not conflict
Collection<String> rootFeaturesList = new ArrayList<String>(rootFeatures);
//Implementation for platform element
if (rootPlatforms != null && selectionContext.getHasVersionlessFeatures()) {
rootFeaturesList.addAll(rootPlatforms);
if (rootPlatformFeatures != null && selectionContext.getHasVersionlessFeatures()) {
rootFeaturesList.addAll(rootPlatformFeatures);
}

//add versionless after normal resolution for packaging
Expand All @@ -606,7 +619,7 @@ public Result doResolve(Repository repository,
}
//preresolve versionless features for regular resolution
else if (selectionContext.getHasVersionlessFeatures()) {
preresolveVersionless(rootFeaturesList, selectionContext, rootPlatforms, filteredVersionless);
preresolveVersionless(rootFeaturesList, selectionContext, rootPlatformFeatures, filteredVersionless);
}

selectionContext.primeSelected(preResolved);
Expand Down Expand Up @@ -639,7 +652,7 @@ else if (selectionContext.getHasVersionlessFeatures()) {
if (!filteredVersionless.isEmpty() && allowedMultipleVersions != null) {
addBackVersionless(filteredVersionless, selectionContext);
} else if (selectionContext.getHasVersionlessFeatures()) {
finalizeVersionlessResults(selectionContext, filteredVersionless);
finalizeVersionlessResults(selectionContext, filteredVersionless, rootPlatforms);
}

// Finally return the selected result
Expand Down Expand Up @@ -964,7 +977,7 @@ private boolean shouldAddCompatibleFeature(FeatureResolverResultImpl result, Str
* @param selectionContext
* @param filteredVersionless
*/
private void finalizeVersionlessResults(SelectionContext selectionContext, List<String> filteredVersionless) {
private void finalizeVersionlessResults(SelectionContext selectionContext, List<String> filteredVersionless, Collection<String> rootPlatforms) {
FeatureResolverResultImpl result = selectionContext.getResult();
result._resolved.addAll(filteredVersionless);

Expand All @@ -976,8 +989,18 @@ private void finalizeVersionlessResults(SelectionContext selectionContext, List<
for (String feature : result.getResolvedFeatures()) {
ProvisioningFeatureDefinition featureDef = selectionContext.getRepository().getFeature(feature);
if (featureDef.isCompatibility()) {
if (existingPlatforms.contains(featureDef.getPlatformName())) {
result.addResolvedPlatform(featureDef.getPlatformName());
boolean addedPlatform = false;
if(!rootPlatforms.isEmpty()){
for(String platName : featureDef.getPlatformNames()){
if(rootPlatforms.contains(platName)){
result.addResolvedPlatform(platName);
addedPlatform = true;
}
}
}
if (existingPlatforms.contains(featureDef.getPlatformName()) && !addedPlatform) {
String platforms = featureDef.getPlatformName();
result.addResolvedPlatform(platforms);
}
}
}
Expand Down Expand Up @@ -1037,7 +1060,9 @@ private void processCompatibilityFeatures(List<ProvisioningFeatureDefinition> fe
allCompatibilityFeatures = new HashMap<>();
for (ProvisioningFeatureDefinition feature : features) {
if (feature.isCompatibility()) {
allCompatibilityFeatures.put(feature.getPlatformName().toLowerCase(), feature);
for(String platformName : feature.getPlatformNames()){
allCompatibilityFeatures.put(platformName.toLowerCase(), feature);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,9 @@ private void updateMaps(SubsystemFeatureDefinitionImpl def) {
publicFeatureNameToSymbolicName.put(lowerFeature(attr.symbolicName), attr.symbolicName);
} else if (def.getVisibility() == Visibility.PRIVATE) {
if ((attr.platforms != null) && !attr.platforms.isEmpty()) {
putCompatibilityFeature(def.getPlatformName(), def);
for(String plat : def.getPlatformNames()){
putCompatibilityFeature(plat, def);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public void versionless_NoFeatureVersionExistsForPlatform() throws Exception {
startServer_CheckLogs("CWWKF0054E:");
}

@Test // 54E
public void versionless_NoFeatureVersionExistsForPlatformJakartaee8() throws Exception {

initTest(SERVER_NAME_NO_VERSION_OF_FEATURE_EXISTS_FOR_PLATFORM, "jakartaee-8.0", "data", null);

// Expect message: "CWWKF0054E: The {0} versionless feature does not have a version that belongs to the {1} platform.
allowedMessages = new String[] { "CWWKF0050E", "CWWKF0055E", "CWWKF0054E" };
startServer_CheckLogs("CWWKF0054E:");
}

@Test // 55E
public void versionless_NoConfiguredPlatform() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class VersionlessServletToMicroProfileTest extends VersionlessTest {
public static final String SERVER_NAME_SERVLET6_HEALTH = "Servlet6toHealth";
public static final String SERVER_NAME_SERVLET6_METRICS = "Servlet6toMetrics";

public static final String SERVER_JAKARTAEE8 = "jakartaee8";

public static final String[] ALLOWED_ERRORS = { "CWWKF0001E", "CWWKF0048E" };

public static final TestCase[] TEST_CASES = {
Expand Down Expand Up @@ -91,6 +93,11 @@ public class VersionlessServletToMicroProfileTest extends VersionlessTest {
new TestCase("servlet6MetricsMin", SERVER_NAME_SERVLET6_METRICS,
PlatformConstants.MICROPROFILE_ASCENDING,
new String[] { "mpMetrics-5.0" }, TestCase.NO_FAILURES, ALLOWED_ERRORS,
TestCase.JAVA_11),

//JAKARTA8 TEST
new TestCase("jakartaee8", SERVER_JAKARTAEE8, "",
new String[] { "servlet-4.0", "jpa-2.2"}, TestCase.NO_FAILURES, ALLOWED_ERRORS,
TestCase.JAVA_11)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ public void withServer(String serverName, String[] allowedErrors, String preferr
String[] expectedResolved,
FailableConsumer<LibertyServer, Exception> action) throws Exception {
LibertyServer server = LibertyServerFactory.getLibertyServer(serverName);
server.addEnvVar("PREFERRED_PLATFORM_VERSIONS", preferredVersions);
if(!preferredVersions.isEmpty()){
server.addEnvVar("PREFERRED_PLATFORM_VERSIONS", preferredVersions);
}

server.startServer();
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################################################
# Copyright (c) 2017 IBM Corporation and others.
# All rights reserved. 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
# http://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
bootstrap.include=../testports.properties
com.ibm.ws.logging.trace.specification=*=info
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
Copyright (c) 2017, 2024 IBM Corporation and others.
All rights reserved. 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
http://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

Contributors:
IBM Corporation - initial API and implementation
-->
<server>

<featureManager>
<platform>jakartaee-8.0</platform>
<feature>servlet</feature>
<feature>jpa</feature>
</featureManager>

<include location="../fatTestCommon.xml"/>

</server>