diff --git a/pkg/apis/enricher/framework/java/micronaut_detector.go b/pkg/apis/enricher/framework/java/micronaut_detector.go index 7c369c82..c2e0adb9 100644 --- a/pkg/apis/enricher/framework/java/micronaut_detector.go +++ b/pkg/apis/enricher/framework/java/micronaut_detector.go @@ -14,6 +14,7 @@ package enricher import ( "context" "os" + "path/filepath" "github.com/devfile/alizer/pkg/apis/model" "github.com/devfile/alizer/pkg/utils" @@ -31,13 +32,13 @@ func (m MicronautDetector) GetApplicationFileInfos(componentPath string, ctx *co { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yml", }, { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yaml", }, } diff --git a/pkg/apis/enricher/framework/java/quarkus_detector.go b/pkg/apis/enricher/framework/java/quarkus_detector.go index 653cdb43..ef3c0b62 100644 --- a/pkg/apis/enricher/framework/java/quarkus_detector.go +++ b/pkg/apis/enricher/framework/java/quarkus_detector.go @@ -33,19 +33,19 @@ func (q QuarkusDetector) GetApplicationFileInfos(componentPath string, ctx *cont { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.properties", }, { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yml", }, { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yaml", }, } diff --git a/pkg/apis/enricher/framework/java/spring_detector.go b/pkg/apis/enricher/framework/java/spring_detector.go index e1ea39bc..0223b597 100644 --- a/pkg/apis/enricher/framework/java/spring_detector.go +++ b/pkg/apis/enricher/framework/java/spring_detector.go @@ -25,7 +25,7 @@ import ( type SpringDetector struct{} func (s SpringDetector) GetSupportedFrameworks() []string { - return []string{"Spring", "Spring Boot"} + return []string{"Spring", "Spring Boot", "Spring Cloud"} } func (s SpringDetector) GetApplicationFileInfos(componentPath string, ctx *context.Context) []model.ApplicationFileInfo { @@ -33,19 +33,19 @@ func (s SpringDetector) GetApplicationFileInfos(componentPath string, ctx *conte { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.properties", }, { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yml", }, { Context: ctx, Root: componentPath, - Dir: "src/main/resources", + Dir: filepath.FromSlash("src/main/resources"), File: "application.yaml", }, } @@ -53,8 +53,14 @@ func (s SpringDetector) GetApplicationFileInfos(componentPath string, ctx *conte // DoFrameworkDetection uses the groupId to check for the framework name func (s SpringDetector) DoFrameworkDetection(language *model.Language, config string) { + if hasFwk, _ := hasFramework(config, "org.springframework.boot", ""); hasFwk { + language.Frameworks = append(language.Frameworks, "Spring Boot") + } + if hasFwk, _ := hasFramework(config, "org.springframework.cloud", ""); hasFwk { + language.Frameworks = append(language.Frameworks, "Spring Cloud") + } if hasFwk, _ := hasFramework(config, "org.springframework", ""); hasFwk { - language.Frameworks = append(language.Frameworks, s.GetSupportedFrameworks()...) + language.Frameworks = append(language.Frameworks, "Spring") } } diff --git a/pkg/apis/enricher/framework/java/vertx_detector.go b/pkg/apis/enricher/framework/java/vertx_detector.go index 549d0182..6e07a7bf 100644 --- a/pkg/apis/enricher/framework/java/vertx_detector.go +++ b/pkg/apis/enricher/framework/java/vertx_detector.go @@ -14,6 +14,7 @@ package enricher import ( "context" "encoding/json" + "path/filepath" "github.com/devfile/alizer/pkg/apis/model" "github.com/devfile/alizer/pkg/utils" @@ -30,7 +31,7 @@ func (v VertxDetector) GetApplicationFileInfos(componentPath string, ctx *contex { Context: ctx, Root: componentPath, - Dir: "src/main/conf", + Dir: filepath.FromSlash("src/main/conf"), File: ".*.json", }, } diff --git a/resources/projects/spring-cloud/pom.xml b/resources/projects/spring-cloud/pom.xml new file mode 100644 index 00000000..ea4b2e27 --- /dev/null +++ b/resources/projects/spring-cloud/pom.xml @@ -0,0 +1,78 @@ + + 4.0.0 + + com.example + spring-cloud + 0.0.1-SNAPSHOT + spring-cloud + jar + + + org.springframework.boot + spring-boot-starter-parent + 3.2.5 + + + + + 17 + 2023.0.1 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.cloud + spring-cloud-starter-config + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/resources/projects/spring-cloud/src/main/java/com/example/demo/DemoApplication.java b/resources/projects/spring-cloud/src/main/java/com/example/demo/DemoApplication.java new file mode 100644 index 00000000..8a2ad5ef --- /dev/null +++ b/resources/projects/spring-cloud/src/main/java/com/example/demo/DemoApplication.java @@ -0,0 +1,22 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@SpringBootApplication +public class DemoApplication { + + @RequestMapping("/") + String home() { + return "Hello World!"; + } + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} \ No newline at end of file diff --git a/resources/projects/spring-cloud/src/main/resources/application.yaml b/resources/projects/spring-cloud/src/main/resources/application.yaml new file mode 100644 index 00000000..abbdf6ae --- /dev/null +++ b/resources/projects/spring-cloud/src/main/resources/application.yaml @@ -0,0 +1,19 @@ +server: + http: + port: 9012 +spring: + application: + name: spring-cloud-sample + cloud: + config: + uri: http://localhost:8888 +eureka: + client: + service-url: + defaultZone: http://localhost:8761/eureka/ +management: + endpoints: + web: + exposure: + include: "*" + diff --git a/resources/projects/spring-cloud/src/test/java/com/example/demo/DemoApplicationTests.java b/resources/projects/spring-cloud/src/test/java/com/example/demo/DemoApplicationTests.java new file mode 100644 index 00000000..2778a6a7 --- /dev/null +++ b/resources/projects/spring-cloud/src/test/java/com/example/demo/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/test/apis/component_recognizer_test.go b/test/apis/component_recognizer_test.go index bee75fc8..0fc24d75 100644 --- a/test/apis/component_recognizer_test.go +++ b/test/apis/component_recognizer_test.go @@ -112,6 +112,10 @@ func TestComponentDetectionOnSpring(t *testing.T) { isComponentsInProject(t, "spring", 1, "java", "spring") } +func TestComponentDetectionOnSpringCloud(t *testing.T) { + isComponentsInProject(t, "spring-cloud", 1, "java", "spring-cloud") +} + func TestComponentDetectionOnVertx(t *testing.T) { isComponentsInProject(t, "vertx", 1, "java", "http-vertx") } @@ -419,7 +423,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) { func TestComponentDetectionMultiProjects(t *testing.T) { components := getComponentsFromTestProject(t, "") - nComps := 70 + nComps := 71 if len(components) != nComps { t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components))) } diff --git a/test/git_test.json b/test/git_test.json index ff423721..318ce41f 100644 --- a/test/git_test.json +++ b/test/git_test.json @@ -273,7 +273,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven" @@ -531,7 +532,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven" @@ -548,7 +550,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven" @@ -565,7 +568,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven" @@ -587,7 +591,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven" @@ -643,7 +648,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Gradle" @@ -662,7 +668,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Gradle" @@ -676,7 +683,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Gradle" @@ -1174,7 +1182,8 @@ { "name": "Java", "frameworks": [ - "Spring" + "Spring", + "Spring Boot" ], "tools": [ "Maven"