-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow both ZIP/JAR and directory output for GwtIncompatibleStripperCommandLineRunner (like J2clCommandLineRunner) #98
Comments
It's actually more complicated than that: because So the alternative of exposing an API processing one file at a time would be more workable. Currently, not only the ZIP has to be unpacked, but the entry paths also need to be translated (e.g. from The j2cl-maven-plugin currently uses |
Sorry I was out for vacation. It is ok to support directory output similar to J2clCommandLineRunner. We would like to remove the zip completely anyway (including zipping and unzipping). I understood the original request but didn't understand follow up comment. If you pass That doesn't work for you? |
Are you sure about that rule?
That logic is in
but GwtIncompatibleStripper uses the originalPath :j2cl/tools/java/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripper.java Lines 83 to 85 in 69a295d
Gradle doesn't guarantee the working directory (see note in https://docs.gradle.org/6.5/userguide/working_with_files.html#sec:single_file_paths), which forces us to pass absolute file paths. That puts us in that last case (or the previous one if I'm currently doing just that when unzipping (my current code probably doesn't work on Windows, but that should be easily fixable) |
Yes that's the intended behavior; I don't remember any reason not to follow that convention so we can probably change that behavior. We can also make the tool run via stdin/stdout which is probably the simplest contract for such a tool. WDYT? |
If you mean public static void processFile(Reader in, Writer out) throws IOException { // <- could be Readable and Appendable too, or InputStream/OutputStream
String fileContent = CharStreams.toString(in);
String processedFileContent = processFile(fileContent); // <- that's the existing processFile
out.write(processedFileContent);
} |
Does fixing |
Following sounds good to me: public static String strip(String content) throws IOException {} |
According to google#98 (comment) that's the intended behavior.
Is your feature request related to a problem? Please describe.
Currently,
GwtIncompatibleStripperCommandLineRunner
unconditionally outputs into a ZIP file. This makes it impractical tojavac
those sources afterwards in non-Bazel environments as they have to be unzipped first.Describe the solution you'd like
Discriminate on the option value to allow either a ZIP or a directory, like
J2clCommandLineRunner
does.Describe alternatives you've considered
Alternatively, provide a public API that takes the source as a
String
orReader
and returns the output as aString
or write to aWriter
, processing one file at a time (e.g. makeGwtIncompatibleStripper
and itsstatic String processFile(String fileContent)
public)Additional context
For incremental processing (only processing those files that have changed), this would allow just giving the same output directory every time, and the tool would then overwrite those files that it was asked to process (e.g. call it with
-d out src/p/A.java src/p/B.java
, it will outputout/p/A.java
andout/p/B/java
; then assrc/p/A.java
is changed by the developer, the tooling could call it again with-d out src/p/A.java
this time –withoutsrc/p/B.java
– and it would overwriteout/p/A.java
and leaveout/p/B.java
untouched; it would of course be the tooling –Gradle, Maven, whatever– responsibility to deleteout/p/X.java
in casesrc/p/X.java
is deleted by the developer)This works great for
GwtIncompatibleStripper
because it processes files in isolation by design, at the AST level without the need to resolve type dependencies.The text was updated successfully, but these errors were encountered: