Skip to content

Commit eb26b97

Browse files
datho7561angelozerr
authored andcommitted
Do not generate property for <clinit>
Fixes redhat-developer/vscode-quarkus#1019 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent af0edb8 commit eb26b97

7 files changed

Lines changed: 199 additions & 4 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
.flattened-pom.xml
8+
9+
# Eclipse
10+
.project
11+
.classpath
12+
.settings/
13+
bin/
14+
15+
# IntelliJ
16+
.idea
17+
*.ipr
18+
*.iml
19+
*.iws
20+
21+
# NetBeans
22+
nb-configuration.xml
23+
24+
# Visual Studio Code
25+
.vscode
26+
.factorypath
27+
28+
# OSX
29+
.DS_Store
30+
31+
# Vim
32+
*.swp
33+
*.swo
34+
35+
# patch
36+
*.orig
37+
*.rej
38+
39+
# Local environment
40+
.env
41+
42+
# Plugin directory
43+
/.quarkus/cli/plugins/
44+
# TLS Certificates
45+
.certs/
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>dev.datho7561</groupId>
5+
<artifactId>clinit</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
8+
<properties>
9+
<compiler-plugin.version>3.14.0</compiler-plugin.version>
10+
<maven.compiler.release>21</maven.compiler.release>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
13+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
14+
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
15+
<quarkus.platform.version>3.22.1</quarkus.platform.version>
16+
<skipITs>true</skipITs>
17+
<surefire-plugin.version>3.5.2</surefire-plugin.version>
18+
</properties>
19+
20+
<dependencyManagement>
21+
<dependencies>
22+
<dependency>
23+
<groupId>${quarkus.platform.group-id}</groupId>
24+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
25+
<version>${quarkus.platform.version}</version>
26+
<type>pom</type>
27+
<scope>import</scope>
28+
</dependency>
29+
</dependencies>
30+
</dependencyManagement>
31+
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.quarkus</groupId>
35+
<artifactId>quarkus-rest</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.quarkus</groupId>
39+
<artifactId>quarkus-arc</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.quarkus</groupId>
43+
<artifactId>quarkus-junit5</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.rest-assured</groupId>
48+
<artifactId>rest-assured</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
</dependencies>
52+
53+
<build>
54+
<plugins>
55+
<plugin>
56+
<groupId>${quarkus.platform.group-id}</groupId>
57+
<artifactId>quarkus-maven-plugin</artifactId>
58+
<version>${quarkus.platform.version}</version>
59+
<extensions>true</extensions>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>build</goal>
64+
<goal>generate-code</goal>
65+
<goal>generate-code-tests</goal>
66+
<goal>native-image-agent</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
<plugin>
72+
<artifactId>maven-compiler-plugin</artifactId>
73+
<version>${compiler-plugin.version}</version>
74+
<configuration>
75+
<parameters>true</parameters>
76+
</configuration>
77+
</plugin>
78+
<plugin>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<version>${surefire-plugin.version}</version>
81+
<configuration>
82+
<systemPropertyVariables>
83+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
84+
<maven.home>${maven.home}</maven.home>
85+
</systemPropertyVariables>
86+
</configuration>
87+
</plugin>
88+
<plugin>
89+
<artifactId>maven-failsafe-plugin</artifactId>
90+
<version>${surefire-plugin.version}</version>
91+
<executions>
92+
<execution>
93+
<goals>
94+
<goal>integration-test</goal>
95+
<goal>verify</goal>
96+
</goals>
97+
</execution>
98+
</executions>
99+
<configuration>
100+
<systemPropertyVariables>
101+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
102+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
103+
<maven.home>${maven.home}</maven.home>
104+
</systemPropertyVariables>
105+
</configuration>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
110+
<profiles>
111+
<profile>
112+
<id>native</id>
113+
<activation>
114+
<property>
115+
<name>native</name>
116+
</property>
117+
</activation>
118+
<properties>
119+
<skipITs>false</skipITs>
120+
<quarkus.native.enabled>true</quarkus.native.enabled>
121+
</properties>
122+
</profile>
123+
</profiles>
124+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dev.datho7561.clinit;
2+
3+
import jakarta.ws.rs.GET;
4+
import jakarta.ws.rs.Path;
5+
import jakarta.ws.rs.Produces;
6+
import jakarta.ws.rs.core.MediaType;
7+
8+
@Path("/hello")
9+
public class GreetingResource {
10+
11+
@GET
12+
@Produces(MediaType.TEXT_PLAIN)
13+
public String hello() {
14+
return "Hello from Quarkus REST";
15+
}
16+
}

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus.test/projects/maven/clinit/src/main/resources/application.properties

Whitespace-only changes.

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus.test/src/main/java/com/redhat/microprofile/jdt/quarkus/QuarkusConfigPropertiesTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.eclipse.lsp4mp.commons.MicroProfilePropertiesScope;
2222
import org.eclipse.lsp4mp.jdt.core.BasePropertiesManagerTest;
2323
import org.eclipse.lsp4mp.jdt.core.PropertiesManager;
24-
import org.eclipse.lsp4mp.jdt.core.project.JDTMicroProfileProject;
2524
import org.junit.Assert;
2625
import org.junit.Test;
2726

@@ -293,5 +292,16 @@ public void configPropertiesVerbatimDefaultNamingStrategy() throws Exception {
293292
assertPropertiesDuplicate(infoFromJavaSources);
294293
Assert.assertEquals("Expected Quarkus properties count", EXPECTED_PROPERTIES, nbProperties);
295294
}
295+
296+
@Test
297+
public void configPropertiesQuarkusArcRegression() throws Exception {
298+
IJavaProject javaProject = loadMavenProject(QuarkusMavenProjectName.clinit);
299+
MicroProfileProjectInfo infoFromJavaSourcesAndDeps = PropertiesManager.getInstance().getMicroProfileProjectInfo(
300+
javaProject, MicroProfilePropertiesScope.SOURCES_AND_DEPENDENCIES, ClasspathKind.SRC,
301+
JDT_UTILS, DocumentFormat.Markdown, new NullProgressMonitor());
302+
for (var property : infoFromJavaSourcesAndDeps.getProperties()) {
303+
Assert.assertFalse("Property should not end with <clinit>", property.getName().endsWith("<clinit>"));
304+
}
305+
}
296306

297307
}

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus.test/src/main/java/com/redhat/microprofile/jdt/quarkus/QuarkusMavenProjectName.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public class QuarkusMavenProjectName extends MicroProfileMavenProjectName {
2020
public static String scheduler_quickstart = "scheduler-quickstart";
2121
public static String scheduler_diagnostic = "scheduler-diagnostic";
2222
public static final String quarkus_route = "quarkus-route";
23-
23+
public static final String clinit = "clinit";
2424
public static final String quarkus_builditems = "quarkus-builditems";
25-
}
25+
}

quarkus.jdt.ext/com.redhat.microprofile.jdt.quarkus/src/main/java/com/redhat/microprofile/jdt/internal/quarkus/core/properties/QuarkusConfigMappingProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private void populateConfigObject(IType configMappingType, String prefixStr, Str
137137
if (child.getElementType() == IJavaElement.METHOD) {
138138
IMethod method = (IMethod) child;
139139
if (Flags.isDefaultMethod(method.getFlags()) || method.getNumberOfParameters() > 0
140-
|| "void".equals(method.getReturnType())) {
140+
|| "void".equals(method.getReturnType()) || "<clinit>".equals(method.getElementName())) {
141141
continue;
142142
}
143143

0 commit comments

Comments
 (0)