Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed Apr 1, 2022
1 parent 73b157e commit 0ea6c6d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected String renderTemplateFromResource(final String resourcePattern) throws
if (model instanceof Map) {
((Map<String, Object>) model).putAll(templateVariables);
}
log.debug("Rendering template [{}], using model [{}]", resourcePattern, model);
mustache.execute(writer, model).flush();
return writer.toString();
}
Expand All @@ -131,6 +132,8 @@ protected Map<String, Object> prepareProjectTemplateVariables(final OverlayProje
var boms = configuration.getEnv().getBoms();

var type = project.getBuildSystem().id();
templateVariables.put("type", type);

if (type.equals(CasManagementOverlayBuildSystem.ID)) {
templateVariables.put("casMgmtVersion", project.getCasVersion());
properties.getSupportedVersions()
Expand Down Expand Up @@ -182,6 +185,11 @@ protected Map<String, Object> prepareProjectTemplateVariables(final OverlayProje
templateVariables.put("appName", "casdiscoveryserver");
}

/**
* Starting from CAS 6.5, projects can take advantage of Gradle's
* native support for BOMs. Prior to this version, the dependency management plugin
* must be used to handle BOMs.
*/
var bomCapableVersion = VersionUtils.parse("6.5.0");
var currentCasProject = VersionUtils.parse(project.getCasVersion());
templateVariables.put("springDependencyMgmt", currentCasProject.compareTo(bomCapableVersion) < 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.spring.initializr.generator.packaging.Packaging;
import io.spring.initializr.generator.project.ProjectDescription;
import io.spring.initializr.generator.version.Version;
import io.spring.initializr.metadata.BillOfMaterials;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.support.MetadataBuildItemMapper;
Expand All @@ -16,9 +15,10 @@
import io.spring.initializr.web.project.ProjectRequestPlatformVersionTransformer;
import io.spring.initializr.web.project.ProjectRequestToDescriptionConverter;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public class OverlayProjectRequestToDescriptionConverter implements ProjectRequestToDescriptionConverter<OverlayProjectRequest> {
Expand Down Expand Up @@ -64,12 +64,15 @@ private static void validatePackaging(final String packaging, final InitializrMe

private static void validateDependencies(final ProjectRequest request, final InitializrMetadata metadata) {
var dependencies = request.getDependencies();
dependencies.forEach(dep -> {
var dependency = metadata.getDependencies().get(dep);
if (dependency == null) {
throw new InvalidProjectRequestException("Unknown dependency '" + dep + "' check project metadata");
}
});
dependencies
.stream()
.filter(StringUtils::hasText)
.forEach(dep -> {
var dependency = metadata.getDependencies().get(dep);
if (dependency == null) {
throw new InvalidProjectRequestException("Unknown dependency '" + dep + "' check project metadata");
}
});
}

private static void validateDependencyRange(final Version platformVersion, final List<Dependency> resolvedDependencies) {
Expand All @@ -89,10 +92,15 @@ private static BuildSystem getBuildSystem(final ProjectRequest request, final In
private static List<Dependency> getResolvedDependencies(final ProjectRequest request, final Version platformVersion,
final InitializrMetadata metadata) {
var depIds = request.getDependencies();
return depIds.stream().map(it -> {
var dependency = metadata.getDependencies().get(it);
return dependency.resolve(platformVersion);
}).collect(Collectors.toList());
return depIds
.stream()
.filter(StringUtils::hasText)
.map(it -> {
var dependency = metadata.getDependencies().get(it);
return dependency != null ? dependency.resolve(platformVersion) : null;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
}

private static String determineCasVersion(final OverlayProjectRequest request, final InitializrMetadata metadata) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/resources/common/gradle/build.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dependencies {
*/
{{#managementServer}}
implementation enforcedPlatform("org.apereo.cas:cas-mgmt-support-bom:${project.'casmgmt.version'}")
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
{{/managementServer}}
{{^managementServer}}
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
Expand Down
3 changes: 2 additions & 1 deletion ci/validate-cas-mgmt-overlay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ sleep 30
rm -Rf tmp &> /dev/null
mkdir tmp
cd tmp
curl http://localhost:8080/starter.tgz -d casVersion=${CAS_VERSION} \-d bootVersion=${BOOT_VERSION} -d type=cas-management-overlay -d dependencies="jpasvc" | tar -xzvf -
curl http://localhost:8080/starter.tgz -d casVersion=${CAS_VERSION} -d bootVersion=${BOOT_VERSION} \
-d type=cas-management-overlay -d dependencies="jpasvc" | tar -xzvf -
kill -9 $pid

echo "Building CAS Mgmt Overlay"
Expand Down
3 changes: 2 additions & 1 deletion icm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

rm -Rf ./tmp
curl -k http://localhost:8080/starter.tgz -d dependencies="$1" \
-d type=cas-management-overlay -d baseDir=tmp | tar./gradlew -xzvf -
-d casVersion=6.5.1 -d bootVersion=2.6.3 \
-d type=cas-management-overlay -d baseDir=tmp | tar -xzvf -

0 comments on commit 0ea6c6d

Please sign in to comment.