Skip to content

Commit f1fa49a

Browse files
http-client-java, fix format on module-info.java (#9135)
fix Azure/autorest.java#3234 I would use UT from Alan's #9132 (so I will not add UT in this PR) --- Change on pom is just clean up. We should no longer need pom with spotless in resources, as we no longer use Maven spotless plugin for formatting code. --- test Azure/autorest.java#3235 Azure/azure-sdk-for-java#47447
1 parent 8705df1 commit f1fa49a

File tree

7 files changed

+14
-85
lines changed

7 files changed

+14
-85
lines changed

packages/http-client-java/generator/http-client-generator-clientcore-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@typespec/spec-api": "0.1.0-alpha.10",
1717
"@typespec/http-specs": "0.1.0-alpha.28",
1818
"@typespec/json-schema": "1.6.0",
19-
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.5.1.tgz",
19+
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.6.0.tgz",
2020
"@typespec/http-client-java-tests": "file:"
2121
},
2222
"overrides": {

packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/postprocessor/implementation/CodeFormatterUtil.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ private static String importToString(ImportDeclaration importDeclaration) {
191191
private static String formatCode(String file, String fileName, CodeFormatter codeFormatter) throws Exception {
192192
IDocument doc = new Document(file);
193193

194-
boolean isModuleInfo = IModule.MODULE_INFO_JAVA.equals(fileName);
194+
boolean isModuleInfo = fileName.endsWith(IModule.MODULE_INFO_JAVA);
195+
if (isModuleInfo) {
196+
// candidate module-info.java, confirm by check file content about module declaration
197+
CompilationUnit compilationUnit = StaticJavaParser.parse(file);
198+
if (compilationUnit.getModule().isEmpty()) {
199+
// not module-info.java
200+
isModuleInfo = false;
201+
}
202+
}
195203
int kind = isModuleInfo ? CodeFormatter.K_MODULE_INFO : CodeFormatter.K_COMPILATION_UNIT;
196204
kind |= CodeFormatter.F_INCLUDE_COMMENTS;
197205
TextEdit edit = codeFormatter.format(kind, file, 0, file.length(), 0, Constants.NEW_LINE);

packages/http-client-java/generator/http-client-generator-mgmt/src/main/resources/spotless-pom.xml

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/http-client-java/generator/http-client-generator-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@typespec/spec-api": "0.1.0-alpha.10",
1717
"@typespec/http-specs": "0.1.0-alpha.28",
1818
"@azure-tools/azure-http-specs": "0.1.0-alpha.32",
19-
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.5.1.tgz",
19+
"@typespec/http-client-java": "file:../../typespec-http-client-java-0.6.0.tgz",
2020
"@typespec/http-client-java-tests": "file:"
2121
},
2222
"overrides": {

packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,4 @@
2121
<version>1.0.0-beta.1</version>
2222
</dependency>
2323
</dependencies>
24-
25-
<profiles>
26-
<profile>
27-
<id>spotless</id>
28-
<activation>
29-
<property>
30-
<name>spotless</name>
31-
</property>
32-
</activation>
33-
34-
<build>
35-
<plugins>
36-
<!-- All configuration, except the plugin version, in this plugin must be aligned with the Spotless -->
37-
<!-- configurations used in azure-sdk-for-java -->
38-
<plugin>
39-
<groupId>com.diffplug.spotless</groupId>
40-
<artifactId>spotless-maven-plugin</artifactId>
41-
<version>2.40.0</version>
42-
<configuration>
43-
<java>
44-
<includes>
45-
<include>src/main/java/**/*.java</include>
46-
<include>src/samples/java/**/*.java</include>
47-
<include>src/test/java/**/*.java</include>
48-
</includes>
49-
50-
<importOrder/>
51-
<eclipse>
52-
<version>4.21</version>
53-
<file>../eclipse-format-azure-sdk-for-java.xml</file>
54-
</eclipse>
55-
</java>
56-
</configuration>
57-
</plugin>
58-
</plugins>
59-
</build>
60-
</profile>
61-
</profiles>
6224
</project>

packages/http-client-java/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/http-client-java/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@typespec/http-client-java",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding",
55
"keywords": [
66
"TypeSpec"

0 commit comments

Comments
 (0)