Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/public/alizer-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions pkg/apis/enricher/framework/java/jakartaee_detector.go
Original file line number Diff line number Diff line change
@@ -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) {
}
1 change: 1 addition & 0 deletions pkg/apis/enricher/java_enricher.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func getJavaFrameworkDetectors() []FrameworkDetectorWithConfigFile {
&framework.VertxDetector{},
&framework.WildFlyDetector{},
&framework.JBossEAPDetector{},
&framework.JakartaEEDetector{},
&framework.WebSphereDetector{},
&framework.WebLogicDetector{},
}
Expand Down
30 changes: 30 additions & 0 deletions resources/projects/jakartaee/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>jakartaee-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>jakartaee-app</finalName>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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!";
}
}
7 changes: 6 additions & 1 deletion test/apis/component_recognizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)))
}
Expand Down
Loading