Skip to content
Merged
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
5 changes: 3 additions & 2 deletions pkg/apis/enricher/framework/java/micronaut_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package enricher
import (
"context"
"os"
"path/filepath"

"github.com/devfile/alizer/pkg/apis/model"
"github.com/devfile/alizer/pkg/utils"
Expand All @@ -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",
},
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/enricher/framework/java/quarkus_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}
Expand Down
16 changes: 11 additions & 5 deletions pkg/apis/enricher/framework/java/spring_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,42 @@ 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 {
return []model.ApplicationFileInfo{
{
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",
},
}
}

// 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")
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/enricher/framework/java/vertx_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
},
}
Expand Down
78 changes: 78 additions & 0 deletions resources/projects/spring-cloud/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>spring-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-cloud</name>
<packaging>jar</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
</properties>

<dependencies>
<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Cloud Config Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

<!-- Spring Cloud Discovery Client (Eureka) -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

<!-- Actuator for health checks -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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: "*"

Original file line number Diff line number Diff line change
@@ -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() {
}

}
6 changes: 5 additions & 1 deletion test/apis/component_recognizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)))
}
Expand Down
27 changes: 18 additions & 9 deletions test/git_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand Down Expand Up @@ -531,7 +532,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand All @@ -548,7 +550,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand All @@ -565,7 +568,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand All @@ -587,7 +591,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand Down Expand Up @@ -643,7 +648,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Gradle"
Expand All @@ -662,7 +668,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Gradle"
Expand All @@ -676,7 +683,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Gradle"
Expand Down Expand Up @@ -1174,7 +1182,8 @@
{
"name": "Java",
"frameworks": [
"Spring"
"Spring",
"Spring Boot"
],
"tools": [
"Maven"
Expand Down
Loading