-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check java version for azure * Azure java version identification * use winup:matches --------- Co-authored-by: kaiqianyang <kaiqianyang@microsoftcom> Co-authored-by: PhilipCattanach <pcattana@redhat.com>
- Loading branch information
1 parent
ab7882a
commit be700f2
Showing
5 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0"?> | ||
<ruleset id="azure-java-version" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<metadata> | ||
<description> | ||
Check non-LTS Java versions | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" /> | ||
</dependencies> | ||
<sourceTechnology id="springboot"/> | ||
<sourceTechnology id="eap" versionRange="[7,8)" /> | ||
<targetTechnology id="azure-spring-apps"/> | ||
<targetTechnology id="azure-appservice"/> | ||
<targetTechnology id="azure-aks"/> | ||
<targetTechnology id="azure-container-apps"/> | ||
<tag>version</tag> | ||
</metadata> | ||
<rules> | ||
<rule id="azure-java-version-01000"> | ||
<when> | ||
<xmlfile matches="//m:java.version[windup:matches(text(), '{v}')]" in="pom.xml" as="result"> | ||
<namespace prefix="m" uri="http://maven.apache.org/POM/4.0.0"/> | ||
</xmlfile> | ||
</when> | ||
<perform> | ||
<iteration over="result"> | ||
<hint title="Non-LTS version Java" category-id="potential" effort="3"> | ||
<message> | ||
<![CDATA[ | ||
The application is using non-LTS version Java. | ||
JDK on LTS version is recommended, i.e. JAVA_8, JAVA_11 or JAVA_17. | ||
]]> | ||
</message> | ||
</hint> | ||
</iteration> | ||
</perform> | ||
<where param="v"> | ||
<matches pattern="(9|10|12|13|14|15|16|19|20).*"/> | ||
</where> | ||
</rule> | ||
<rule id="azure-java-version-02000"> | ||
<when> | ||
<xmlfile matches="//m:java.version[windup:matches(text(), '{v}')]" in="pom.xml" as="result"> | ||
<namespace prefix="m" uri="http://maven.apache.org/POM/4.0.0"/> | ||
</xmlfile> | ||
</when> | ||
<perform> | ||
<iteration over="result"> | ||
<hint title="Java version found to be lower than JAVA_8" category-id="potential" effort="3"> | ||
<message> | ||
<![CDATA[ | ||
The application is using Java version lower than JAVA_8. | ||
JDK on LTS version is recommended, i.e. JAVA_8, JAVA_11 or JAVA_17. | ||
]]> | ||
</message> | ||
</hint> | ||
</iteration> | ||
</perform> | ||
<where param="v"> | ||
<matches pattern="1\.[0-7]"/> | ||
</where> | ||
</rule> | ||
</rules> | ||
</ruleset> |
34 changes: 34 additions & 0 deletions
34
rules/rules-reviewed/azure/tests/azure-java-version.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="azure-java-version-test" xmlns="http://windup.jboss.org/schema/jboss-ruleset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> | ||
<testDataPath>data/azure-java-version</testDataPath> | ||
<rulePath>../azure-java-version.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="azure-java-version-test-01000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The application is using non-LTS version Java." /> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="non-LTS JAVA version hint was not found!" /> | ||
</perform> | ||
</rule> | ||
<rule id="azure-java-version-test-02000"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The application is using Java version lower than JAVA_8." /> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="JAVA version lower than java_8 hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
41 changes: 41 additions & 0 deletions
41
rules/rules-reviewed/azure/tests/data/azure-java-version/java-17/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.0.6</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.example</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>demo</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>17</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
41 changes: 41 additions & 0 deletions
41
rules/rules-reviewed/azure/tests/data/azure-java-version/java-19/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.0.6</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.example</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>demo</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>19</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
41 changes: 41 additions & 0 deletions
41
rules/rules-reviewed/azure/tests/data/azure-java-version/java-7/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.5.12</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.example</groupId> | ||
<artifactId>demo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>demo</name> | ||
<description>Demo project for Spring Boot</description> | ||
<properties> | ||
<java.version>1.7</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |