From ce14c9331f01826d8759752065fbdf9fb17698f4 Mon Sep 17 00:00:00 2001 From: Nourhan Shata Date: Wed, 5 Aug 2026 10:50:13 +0200 Subject: [PATCH 1/4] create new archetype --- archetypes/pom.xml | 1 + archetypes/spring-boot4/pom.xml | 35 +++ .../META-INF/maven/archetype-metadata.xml | 62 +++++ .../archetype-resources/__gitignore__ | 14 ++ .../archetype-resources/application/pom.xml | 234 ++++++++++++++++++ .../__packageInPathFormat__/Application.java | 28 +++ .../AsynchronousConfiguration.java | 28 +++ .../SecurityConfiguration.java | 104 ++++++++ .../controllers/HelloWorldController.java | 31 +++ .../models/HelloWorldResponse.java | 17 ++ .../src/main/resources/application.yml | 22 ++ .../src/main/resources/logback-spring.xml | 17 ++ .../src/main/resources/static/index.html | 55 ++++ .../HelloWorldControllerTest.java | 74 ++++++ .../__packageInPathFormat__/UnitTest.java | 17 ++ .../src/test/resources/expected.json | 3 + .../archetype-resources/manifest.yml | 19 ++ .../resources/archetype-resources/pom.xml | 110 ++++++++ .../projects/basic/archetype.properties | 6 + .../test/resources/projects/basic/goal.txt | 0 module-inventory.json | 11 + 21 files changed, 888 insertions(+) create mode 100644 archetypes/spring-boot4/pom.xml create mode 100644 archetypes/spring-boot4/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/__gitignore__ create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/AsynchronousConfiguration.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/SecurityConfiguration.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/controllers/HelloWorldController.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/models/HelloWorldResponse.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/application.yml create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/logback-spring.xml create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/static/index.html create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/UnitTest.java create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/resources/expected.json create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/manifest.yml create mode 100644 archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml create mode 100644 archetypes/spring-boot4/src/test/resources/projects/basic/archetype.properties create mode 100644 archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt diff --git a/archetypes/pom.xml b/archetypes/pom.xml index c524bd27e4..41c1de8d38 100644 --- a/archetypes/pom.xml +++ b/archetypes/pom.xml @@ -32,6 +32,7 @@ spring-boot3 + spring-boot4 scm:git:git://github.com/SAP/cloud-sdk-java.git diff --git a/archetypes/spring-boot4/pom.xml b/archetypes/spring-boot4/pom.xml new file mode 100644 index 0000000000..290aca47ef --- /dev/null +++ b/archetypes/spring-boot4/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + com.sap.cloud.sdk.archetypes + archetypes-parent + 5.33.0-SNAPSHOT + + spring-boot4 + maven-archetype + Archetypes - SAP CP Cloud Foundry + Spring Boot 4 + Archetype for a Spring-based project on SAP Business Technology Platform (Cloud Foundry). + https://sap.github.io/cloud-sdk/docs/java/getting-started + + SAP SE + https://www.sap.com + + + + The Apache Software License, Version 2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + SAP + cloudsdk@sap.com + SAP SE + https://www.sap.com + + + + ${project.basedir}/../../ + + diff --git a/archetypes/spring-boot4/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/spring-boot4/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..920cf8fd3c --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,62 @@ + + + + + + [^_]+ + + + .gitignore + + + + + + + + + manifest.yml + + + + + + + __gitignore__ + Jenkinsfile + .pipeline/config.yml + + + + + + application + + pom.xml + + + + + application/src + + **/*.java + + + + application/src/main/resources + + ** + + + + application/src/test/resources + + ** + + + + diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/__gitignore__ b/archetypes/spring-boot4/src/main/resources/archetype-resources/__gitignore__ new file mode 100644 index 0000000000..14671ce405 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/__gitignore__ @@ -0,0 +1,14 @@ +**/credentials.* +**/target/ +/s4hana_pipeline +**/*.log +**/*.trc +**/.settings/ +**/.project +**/.classpath +**/.idea +**/*.iml +**/.vscode +**/node_modules +**/.DS_Store +.pipeline/commonPipelineEnvironment diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml new file mode 100644 index 0000000000..0af8f5f45d --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml @@ -0,0 +1,234 @@ + + + + 4.0.0 + + ${artifactId} - Application + ${artifactId} - Application + + ${artifactId}-application + ${version} + + + ${groupId} + ${artifactId} + ${version} + + + + false + 1 + * + + + + 1024m + info + + + -Xmx${surefire.maxMemorySize} -Dorg.slf4j.simpleLogger.defaultLogLevel=${surefire.logLevel} + + ${project.build.directory}/coverage-reports/jacoco.exec + * + org.apache.* + + + + + com.sap.cloud.sdk + sdk-core + + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + com.sap.hcp.cf.logging + cf-java-logging-support-logback + 3.7.1 + + + org.springframework.boot + spring-boot-starter-webmvc + + + + + + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.springframework + spring-test + test + + + org.springframework.boot + spring-boot-test + test + + + org.springframework.boot + spring-boot-test-autoconfigure + test + + + org.springframework.security + spring-security-test + test + + + + + + org.skyscreamer + jsonassert + 1.5.1 + test + + + + + com.vaadin.external.google + android-json + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + false + + + + + repackage + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.10 + + ${jacoco.executionDataFile} + ${jacoco.executionDataFile} + ${jacoco.includes} + ${jacoco.excludes} + + + + prepare-agent + + prepare-agent + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.0 + + ${surefire.skipTests} + + ${surefire.include} + + + ${surefire.exclude} + + ${surefire.forkCount} + false + ${surefire.groups} + ${surefire.excludedGroups} + + ${project.build.directory}/surefire-fork/${surefire.forkNumber}/ + + + + + + + + + + + + diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java new file mode 100644 index 0000000000..8954d092ff --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java @@ -0,0 +1,28 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan({"com.sap.cloud.sdk", "${package}"}) +@ServletComponentScan({"com.sap.cloud.sdk", "${package}"}) +public class Application extends SpringBootServletInitializer +{ + @Override + protected SpringApplicationBuilder configure( final SpringApplicationBuilder application ) + { + return application.sources(Application.class); + } + + public static void main( final String[] args ) + { + SpringApplication.run(Application.class, args); + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/AsynchronousConfiguration.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/AsynchronousConfiguration.java new file mode 100644 index 0000000000..eb83cae16a --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/AsynchronousConfiguration.java @@ -0,0 +1,28 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +// Spring Boot asynchronous configuration +import java.util.concurrent.Executor; + +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.AsyncConfigurer; +import org.springframework.scheduling.annotation.EnableAsync; + +import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutors; + +/** + * Implementation that customizes the {@link Executor} instance used when processing @{@link Async} method invocations. + */ +@EnableAsync +@Configuration +public class AsynchronousConfiguration implements AsyncConfigurer +{ + @Override + public Executor getAsyncExecutor() + { + return ThreadContextExecutors.getExecutor(); + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/SecurityConfiguration.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/SecurityConfiguration.java new file mode 100644 index 0000000000..fa8245a684 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/SecurityConfiguration.java @@ -0,0 +1,104 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +// Example for Spring Boot security configuration +/* +import com.sap.cloud.security.spring.config.IdentityServicesPropertySourceFactory; +import com.sap.cloud.security.spring.token.authentication.AuthenticationToken; +import com.sap.cloud.security.token.TokenClaims; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.convert.converter.Converter; +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.web.SecurityFilterChain; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +@Configuration +@EnableWebSecurity( debug = true ) // TODO "debug" may include sensitive information. Do not use in a production system! +@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true ) +@PropertySource( factory = IdentityServicesPropertySourceFactory.class, ignoreResourceNotFound = true, value = { "" } ) +public class SecurityConfiguration +{ + @Autowired + Converter authConverter; // Required only when Xsuaa is used + + @Bean + public SecurityFilterChain filterChain( HttpSecurity http ) + throws Exception + { + // @formatter:off + return http + .sessionManagement(management -> management.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + + .authorizeHttpRequests(registry -> registry + // .requestMatchers("/**").hasAuthority("Display") // optionally check for specific scopes + .requestMatchers("/**").authenticated() + .anyRequest().denyAll()) + + .oauth2ResourceServer(oauth2Config -> oauth2Config + .jwt(jwtConfig -> jwtConfig + .jwtAuthenticationConverter(new MyCustomHybridTokenAuthenticationConverter()))) // Adjust the converter to represent your use case + // Use MyCustomHybridTokenAuthenticationConverter when IAS and XSUAA is used + // Use MyCustomIasTokenAuthenticationConverter when only IAS is used + .build(); + // @formatter: on + } + + //Workaround for hybrid use case until Cloud Authorization Service is globally available. + class MyCustomHybridTokenAuthenticationConverter implements Converter + { + @Override + public AbstractAuthenticationToken convert( Jwt jwt ) + { + if( jwt.hasClaim(TokenClaims.XSUAA.EXTERNAL_ATTRIBUTE) ) { + return authConverter.convert(jwt); + } + return new AuthenticationToken(jwt, deriveAuthoritiesFromGroup(jwt)); + } + + private Collection deriveAuthoritiesFromGroup( Jwt jwt ) + { + Collection groupAuthorities = new ArrayList<>(); + if( jwt.hasClaim(TokenClaims.GROUPS) ) { + List groups = jwt.getClaimAsStringList(TokenClaims.GROUPS); + for( String group : groups ) { + groupAuthorities.add(new SimpleGrantedAuthority(group.replace("IASAUTHZ_", ""))); + } + } + return groupAuthorities; + } + } + + //Workaround for IAS only use case until Cloud Authorization Service is globally available. + class MyCustomIasTokenAuthenticationConverter implements Converter + { + @Override + public AbstractAuthenticationToken convert( Jwt jwt ) + { + final List groups = jwt.getClaimAsStringList(TokenClaims.GROUPS); + final List + groupAuthorities = + groups == null ? + Collections.emptyList() : + groups.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()); + return new AuthenticationToken(jwt, groupAuthorities); + } + } +} +*/ diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/controllers/HelloWorldController.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/controllers/HelloWorldController.java new file mode 100644 index 0000000000..acff3fa5be --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/controllers/HelloWorldController.java @@ -0,0 +1,31 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.controllers; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + + +import ${package}.models.HelloWorldResponse; + +@RestController +@RequestMapping( "/hello" ) +public class HelloWorldController +{ + private static final Logger logger = LoggerFactory.getLogger(HelloWorldController.class); + + @RequestMapping( method = RequestMethod.GET ) + public ResponseEntity getHello( @RequestParam( name = "name", defaultValue = "world" ) final String name ) + { + logger.info("I am running!"); + return ResponseEntity.ok(new HelloWorldResponse(name)); + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/models/HelloWorldResponse.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/models/HelloWorldResponse.java new file mode 100644 index 0000000000..fa33940e94 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/models/HelloWorldResponse.java @@ -0,0 +1,17 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +@SuppressWarnings("PMD.UnusedPrivateField") +public class HelloWorldResponse +{ + @JsonProperty("hello") + private final String name; + + public HelloWorldResponse( final String name ) { + this.name = name; + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/application.yml b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/application.yml new file mode 100644 index 0000000000..7b5c956758 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/application.yml @@ -0,0 +1,22 @@ +server: + port: 8080 + +--- +#-- The below configuration is enabled **only** when activating the 'local' profile for Spring Boot +spring: + config: + activate: + on-profile: + - local + +#-- The following lines are required to run your application locally. Please refer to this documentation for further information: +#-- https://github.com/SAP/cloud-security-xsuaa-integration/tree/main/spring-security#local-setup-fails-with-application-failed-to-start +sap: + security: + services: + xsuaa: + xsappname: your-app-name + uaadomain: uaadomain + clientid: your-client-id + clientsecret: your-client-secret + url: https://yourdomain.uaadomain diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/logback-spring.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..38705e4310 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/logback-spring.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/static/index.html b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/static/index.html new file mode 100644 index 0000000000..f1a56d1e8e --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/resources/static/index.html @@ -0,0 +1,55 @@ + + + Welcome to Your Application! + + + +

Welcome to Your Application!

+ + + + + +

+ This is your SAP Business Technology Platform Cloud Foundry Spring application + powered by the SAP Cloud SDK. +

+
    +
  • + Change to the application/ directory and execute + mvn spring-boot:run. +
  • +
  • + Visit the HelloWorldController. + You can find its source code in application/src/main/java/. +
  • +
  • + Additional static content can be placed inside application/src/main/resources/static/. +
  • +
+

+ Further help and examples are available in the SAP Cloud SDK documentation. +

+ + + diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java new file mode 100644 index 0000000000..ee059ba169 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java @@ -0,0 +1,74 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import static java.lang.Thread.currentThread; + +import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor; +// import com.sap.cloud.security.config.Service; +// import com.sap.cloud.security.test.api.SecurityTestContext; +// import com.sap.cloud.security.test.extension.SecurityTestExtension; +// import com.sap.cloud.security.token.TokenClaims; +import org.apache.commons.io.IOUtils; +// import org.apache.http.HttpHeaders; +import org.junit.jupiter.api.Test; +// import org.junit.jupiter.api.extension.RegisterExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource( + properties = { + "sap.security.services.xsuaa.uaadomain=http://localhost:9001", + "sap.security.services.xsuaa.xsappname=xsapp!t0815", + "sap.security.services.xsuaa.clientid=sb-clientId!t0815" } ) +class HelloWorldControllerTest +{ + @Autowired + private MockMvc mvc; + + /* + @RegisterExtension + static SecurityTestExtension extension = SecurityTestExtension.forService(Service.XSUAA) // or Service.IAS + .setPort(9001); + + private String jwt; + */ + + @Test + void test(/*SecurityTestContext context*/) + { + /* + jwt = context.getPreconfiguredJwtGenerator() + .withLocalScopes("Display") + .withClaimValue(TokenClaims.XSUAA.ORIGIN, "sap-default") // optional + .withClaimValue(TokenClaims.USER_NAME, "John") // optional + .createToken() + .getTokenValue(); + jwt = "Bearer " + jwt; + */ + + final InputStream inputStream = currentThread().getContextClassLoader().getResourceAsStream("expected.json"); + + ThreadContextExecutor.fromNewContext().execute(() -> { + mvc + .perform(MockMvcRequestBuilders.get("/hello") + // .header(HttpHeaders.AUTHORIZATION, jwt) + ) + .andExpect(status().isOk()) + .andExpect(content().json(IOUtils.toString(inputStream, StandardCharsets.UTF_8))); + }); + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/UnitTest.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/UnitTest.java new file mode 100644 index 0000000000..edd25390a1 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/UnitTest.java @@ -0,0 +1,17 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class UnitTest +{ + @Test + void test() + { + assertTrue(true); + } +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/resources/expected.json b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/resources/expected.json new file mode 100644 index 0000000000..f2a886f39d --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/resources/expected.json @@ -0,0 +1,3 @@ +{ + "hello": "world" +} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/manifest.yml b/archetypes/spring-boot4/src/main/resources/archetype-resources/manifest.yml new file mode 100644 index 0000000000..fe2543ba75 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/manifest.yml @@ -0,0 +1,19 @@ +--- +applications: + +- name: ${artifactId} + memory: 1500M + timeout: 300 + random-route: true + path: application/target/${artifactId}-application.jar + env: + TARGET_RUNTIME: main + SPRING_PROFILES_ACTIVE: 'cloud' + JBP_CONFIG_SAPJVM_MEMORY_SIZES: 'metaspace:128m..' + JBP_CONFIG_COMPONENTS: 'jres: [''com.sap.xs.java.buildpack.jre.SAPMachineJRE'']' + JBP_CONFIG_SAP_MACHINE_JRE: '{ use_offline_repository: false, version: 17.+ }' +# services: +# - my-application-logs +# - my-xsuaa +# - my-destination +# - my-connectivity diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..f5d556bf66 --- /dev/null +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,110 @@ + + + + 4.0.0 + + ${artifactId} - Root + ${artifactId} - Root + + ${groupId} + ${artifactId} + ${version} + pom + + + 4.0.7 + + 17 + 5.33.0-SNAPSHOT + + ${java.version} + full + + UTF-8 + UTF-8 + UTF-8 + + + + + + com.sap.cloud.sdk + sdk-bom + ${cloud-sdk.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + org.junit.jupiter + junit-jupiter-api + 5.10.0 + test + + + org.junit.platform + junit-platform-commons + 1.10.0 + test + + + + + + application + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + + + rulesets/java/maven-pmd-plugin-default.xml + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.4.1 + + + SAP Cloud SDK Project Structure Checks + + enforce + + + + + 3.5 + + + ${java.version} + + + project.artifactId + [^_]+ + "The artifactId should not contain underscores (_) as this causes issues when deploying to Cloud Foundry." + + + + true + + + + + + + diff --git a/archetypes/spring-boot4/src/test/resources/projects/basic/archetype.properties b/archetypes/spring-boot4/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..8676bf3cf9 --- /dev/null +++ b/archetypes/spring-boot4/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,6 @@ +#Mon May 08 13:37:59 CEST 2017 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic +gitignore=.gitignore diff --git a/archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt b/archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/module-inventory.json b/module-inventory.json index 348da66b0a..2a4d6be6cf 100644 --- a/module-inventory.json +++ b/module-inventory.json @@ -21,6 +21,17 @@ "parentArtifactId": "archetypes-parent", "excludeFromBlackDuckScan": false }, + { + "groupId": "com.sap.cloud.sdk.archetypes", + "artifactId": "spring-boot4", + "packaging": "maven-archetype", + "releaseAudience": "Public", + "releaseMaturity": "Stable", + "pomFile": "archetypes/spring-boot4/pom.xml", + "parentGroupId": "com.sap.cloud.sdk.archetypes", + "parentArtifactId": "archetypes-parent", + "excludeFromBlackDuckScan": false + }, { "groupId": "com.sap.cloud.sdk.cloudplatform", "artifactId": "caching", From f6b2d62828e8385a3c49285853b04fd6c2b3e768 Mon Sep 17 00:00:00 2001 From: Nourhan Shata Date: Thu, 6 Aug 2026 13:49:21 +0200 Subject: [PATCH 2/4] fix archetype --- .../archetype-resources/application/pom.xml | 12 +++++++++++- .../java/__packageInPathFormat__/Application.java | 2 +- .../HelloWorldControllerTest.java | 2 +- .../src/main/resources/archetype-resources/pom.xml | 12 ------------ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml index 0af8f5f45d..3d3552e638 100644 --- a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/pom.xml @@ -63,6 +63,10 @@ org.springframework.boot spring-boot-starter-webmvc + + org.springframework.boot + spring-boot-web-server + + + org.springframework.boot + spring-boot-webmvc-test + test + org.springframework.security spring-security-test @@ -161,7 +171,7 @@ org.jacoco jacoco-maven-plugin - 0.8.10 + 0.8.13 ${jacoco.executionDataFile} ${jacoco.executionDataFile} diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java index 8954d092ff..507c9632a2 100644 --- a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/main/java/__packageInPathFormat__/Application.java @@ -6,7 +6,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.server.servlet.context.ServletComponentScan; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java index ee059ba169..2f6b6614e0 100644 --- a/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/application/src/test/java/__packageInPathFormat__/HelloWorldControllerTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; // import org.junit.jupiter.api.extension.RegisterExtension; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml index f5d556bf66..b03cdf1265 100644 --- a/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml @@ -41,18 +41,6 @@ pom import - - org.junit.jupiter - junit-jupiter-api - 5.10.0 - test - - - org.junit.platform - junit-platform-commons - 1.10.0 - test - From be7affcad9a0ca43db5f30ae04f8ff275f631767 Mon Sep 17 00:00:00 2001 From: Nourhan Shata Date: Thu, 6 Aug 2026 15:02:08 +0200 Subject: [PATCH 3/4] fix archetype --- .../spring-boot3/src/test/resources/projects/basic/goal.txt | 0 .../spring-boot4/src/test/resources/projects/basic/goal.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 archetypes/spring-boot3/src/test/resources/projects/basic/goal.txt delete mode 100644 archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt diff --git a/archetypes/spring-boot3/src/test/resources/projects/basic/goal.txt b/archetypes/spring-boot3/src/test/resources/projects/basic/goal.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt b/archetypes/spring-boot4/src/test/resources/projects/basic/goal.txt deleted file mode 100644 index e69de29bb2..0000000000 From 9be69e24eb1d5b699b0b17e9adf62426cdb5a5b5 Mon Sep 17 00:00:00 2001 From: Nourhan Shata Date: Thu, 6 Aug 2026 15:46:18 +0200 Subject: [PATCH 4/4] snapshot version fix --- archetypes/spring-boot4/pom.xml | 2 +- .../spring-boot4/src/main/resources/archetype-resources/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archetypes/spring-boot4/pom.xml b/archetypes/spring-boot4/pom.xml index 290aca47ef..9640788f4c 100644 --- a/archetypes/spring-boot4/pom.xml +++ b/archetypes/spring-boot4/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.archetypes archetypes-parent - 5.33.0-SNAPSHOT + 5.34.0-SNAPSHOT spring-boot4 maven-archetype diff --git a/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml index b03cdf1265..6fb939e111 100644 --- a/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/spring-boot4/src/main/resources/archetype-resources/pom.xml @@ -15,7 +15,7 @@ 4.0.7 17 - 5.33.0-SNAPSHOT + 5.34.0-SNAPSHOT ${java.version} full