Repository navigation
Conversation
| cmdLine.add("com.google.googlejavaformat.java.Main"); | ||
| // TODO add more options, see details at https://github.com/google/google-java-format/blob/master/core/src/main/java/com/google/googlejavaformat/java/UsageException.java#L30 | ||
| // cmdLine.add("--replace"); | ||
| cmdLine.add("--version"); |
There was a problem hiding this comment.
Remove "--version" to actually see the reformated code on the console.
Uncomment "--replace" to replace all .java source files with the formatted output.
48f248d to
47f7831
Compare
Based on https://github.com/google/google-java-format -- a program that reformats Java source code to comply with Google Java Style: https://google.github.io/styleguide/javaguide.html Prior to this commit, the "fake-guava" module baked into pro's internal modules prevented classes to be loaded from the "all-deps" JAR. Using java auto-module feature makes the format program execution possible. Validation mode is default now; use the following to actually format all sources: set("formatter.rawArguments", list("--replace")) run("formatter")
|
After the |
|
For the javac-9-dev-r3297-1-shaded.jar, it would be cool if google-java-format had an option to use javac through the service interface as we do in the compiler plugin instead of using its own version. |
|
Sure. That would simplify the integration work. |
|
|
||
| private List<Path> listAllJavaFiles(FormatterConf formatter) { | ||
| Predicate<Path> filter = pathFilenameEndsWith(".java"); | ||
| // TODO include "module-info.java" files, blocked by https://github.com/google/google-java-format/issues/75 |
There was a problem hiding this comment.
that bug is fixed, are there still blockers?
There was a problem hiding this comment.
Didn't check for a long time. Will rebase and retry.
There was a problem hiding this comment.
Works like a charm. Removed the filter.
|
@forax How can I help Using this boot strap commands: compileAndPackagePlugin("formatter", () -> {
String gjfVersion = "1.5";
String guavaVersion = "24.1";
String javacShadedVersion = "9+181-r4173-1";
set("resolver.dependencies", list(
// "Google Java Format"
"com.google.googlejavaformat=com.google.googlejavaformat:google-java-format:" + gjfVersion,
"com.google.guava=com.google.guava:guava:" + guavaVersion,
"com.google.errorprone=com.google.errorprone:javac-shaded:" + javacShadedVersion,
"com.google.j2objc=com.google.j2objc:j2objc-annotations:1.1",
"org.codehaus.animal.sniffer.annotations=org.codehaus.mojo:animal-sniffer-annotations:1.14"
));
}); |
|
The Manifest of the jar do not contains the property Automatic-Module-Name so the module API try to gess a name and fail. The best is to ask @cushon to add the property Automatic-Module-Name. In the meantime, the only workaround i see is to download the jar by hand, rename it and commit it in the git repo. |
|
GJF 1.6 will include it: google/google-java-format@4d728e7 Thought there was a chance to "modulefix" it. :) |
|
I'll stick with the external |
|
Superseded by #57 |
|
@cushon said he'll fix the modular problems within error-prone. Looks like we may move from '-all-deps.jar' and spawing another process to a real module-based plugin. See google/google-java-format#266 (comment) and a minimal running test at https://github.com/sormuras/bach/tree/master/demo/03-google-java-format-as-library (placing error-prone on the class-path) |
Overview
Based on google-java-format -- a program that reformats Java source code to comply with Google Java Style.
The current implementation uses the
--module-pathoption to launch the program. I didn't managed to make modules via module-fixer out of neither the "-all-deps" distro nor the 3 single jars:google-java-format-1.3.jar,guava-19.0.jarandjavac-9-dev-r3297-1-shaded.jarThe "-all-deps" jar is downloaded on-the-fly via
Boostrap.download(...)-- a candidate forProitself?The "-all-deps" jar is stored in a subfolder called
plugins/formatter/libs/. All jars found in that folder are not resolved, nor module-fixed. They are copied over to thetarget/proimage as-is.TODO
javaFiles()configurablejavaprovides a "fake-guava" module which collides with the one bundled in google-java-format--all-deps.jar -- is falling back to "external java" a real option? Solved via 156ec79