diff --git a/docs/public/alizer-spec.md b/docs/public/alizer-spec.md index 50e3dffb..85c46c93 100644 --- a/docs/public/alizer-spec.md +++ b/docs/public/alizer-spec.md @@ -37,6 +37,7 @@ NOTE: Maven, Gradle and Ant are saved as Tools inside the data structure returne By reading the content of its configuration file and mainly its dependencies section, Alizer is also able to detect frameworks. Currently, it recognizes: +- JakartaEE - Micronaut - OpenLiberty - Quarkus diff --git a/pkg/apis/enricher/framework/java/jakartaee_detector.go b/pkg/apis/enricher/framework/java/jakartaee_detector.go new file mode 100644 index 00000000..e8b70df6 --- /dev/null +++ b/pkg/apis/enricher/framework/java/jakartaee_detector.go @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2021 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v20.html + * + * Contributors: + * Red Hat, Inc. + ******************************************************************************/ + +package enricher + +import ( + "context" + + "github.com/devfile/alizer/pkg/apis/model" +) + +type JakartaEEDetector struct{} + +func (j JakartaEEDetector) GetSupportedFrameworks() []string { + return []string{"JakartaEE"} +} + +func (j JakartaEEDetector) GetApplicationFileInfos(componentPath string, ctx *context.Context) []model.ApplicationFileInfo { + return []model.ApplicationFileInfo{} +} + +// DoFrameworkDetection uses the groupId to check for the framework name +func (j JakartaEEDetector) DoFrameworkDetection(language *model.Language, config string) { + jakartaGroupIds := []string{ + "jakarta.platform", // Jakarta EE Platform BOM + "jakarta.servlet", // Servlet API + "jakarta.ws.rs", // JAX-RS (RESTful Web Services) + "jakarta.persistence", // JPA (Persistence) + "jakarta.enterprise", // CDI (Contexts and Dependency Injection) + } + + for _, groupId := range jakartaGroupIds { + if hasFwk, _ := hasFramework(config, groupId, ""); hasFwk { + language.Frameworks = append(language.Frameworks, "JakartaEE") + return + } + } +} + +// DoPortsDetection is not implemented for JakartaEE as port configuration varies by runtime +func (j JakartaEEDetector) DoPortsDetection(component *model.Component, ctx *context.Context) { +} diff --git a/pkg/apis/enricher/java_enricher.go b/pkg/apis/enricher/java_enricher.go index 23922e50..33190170 100644 --- a/pkg/apis/enricher/java_enricher.go +++ b/pkg/apis/enricher/java_enricher.go @@ -34,6 +34,7 @@ func getJavaFrameworkDetectors() []FrameworkDetectorWithConfigFile { &framework.VertxDetector{}, &framework.WildFlyDetector{}, &framework.JBossEAPDetector{}, + &framework.JakartaEEDetector{}, &framework.WebSphereDetector{}, &framework.WebLogicDetector{}, } diff --git a/resources/projects/jakartaee/pom.xml b/resources/projects/jakartaee/pom.xml new file mode 100644 index 00000000..8c7c0799 --- /dev/null +++ b/resources/projects/jakartaee/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.example + jakartaee-app + 1.0-SNAPSHOT + war + + + 11 + 11 + UTF-8 + + + + + jakarta.platform + jakarta.jakartaee-api + 10.0.0 + provided + + + + + jakartaee-app + + diff --git a/resources/projects/jakartaee/src/main/java/com/example/HelloResource.java b/resources/projects/jakartaee/src/main/java/com/example/HelloResource.java new file mode 100644 index 00000000..1fcce9ef --- /dev/null +++ b/resources/projects/jakartaee/src/main/java/com/example/HelloResource.java @@ -0,0 +1,16 @@ +package com.example; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/hello") +public class HelloResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "Hello, Jakarta EE!"; + } +} diff --git a/test/apis/component_recognizer_test.go b/test/apis/component_recognizer_test.go index f49a4b56..2545e721 100644 --- a/test/apis/component_recognizer_test.go +++ b/test/apis/component_recognizer_test.go @@ -132,6 +132,10 @@ func TestComponentDetectionOnWildFly(t *testing.T) { isComponentsInProject(t, "wildfly", 1, "java", "wildfly") } +func TestComponentDetectionOnJakartaEE(t *testing.T) { + isComponentsInProject(t, "jakartaee", 1, "java", "jakartaee-app") +} + // port detection: java func TestPortDetectionJavaJBossEAP(t *testing.T) { testPortDetectionInProject(t, "jboss-eap", []int{8380}) @@ -431,7 +435,8 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) { func TestComponentDetectionMultiProjects(t *testing.T) { components := getComponentsFromTestProject(t, "") - nComps := 73 + nComps := 74 + if len(components) != nComps { t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components))) }