Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java output directory is prepending src #287

Closed
GreyCat opened this issue Oct 27, 2017 · 5 comments · Fixed by kaitai-io/kaitai_struct_compiler#193
Closed

Java output directory is prepending src #287

GreyCat opened this issue Oct 27, 2017 · 5 comments · Fixed by kaitai-io/kaitai_struct_compiler#193
Milestone

Comments

@GreyCat
Copy link
Member

GreyCat commented Oct 27, 2017

Original was submitted by @daviderickson in #1201:

Hi I am overriding both the java package and the output directory (ie --java-package com.test and --outdir ../java). I'd expect my Test.java file to end up in ../java/com/test/Test.java, but instead it is being created as ../java/src/com/test/Test.java

I am assuming this is default behavior, but shouldn't happen when overriding the output directory. The culprit seems to be https://github.com/kaitai-io/kaitai_struct_compiler/blob/2bd8834f65e392d8eb2fc7776861b3050d73d085/shared/src/main/scala/io/kaitai/struct/languages/JavaCompiler.scala#L45

Thanks!

@GreyCat
Copy link
Member Author

GreyCat commented Oct 31, 2017

Uhh, this is kind of awkward and I tend to agree with you now.

Originally, it was more or less organized like that due to tests compilation, as it is kind of useful to have src/ and bin/ separately, and it kind of matches IDEA/Eclipse requirements on basic dirs. However, probably the time has come to reconsider that decision and move forward.

One thing that stops me is how to make it somehow compatible with current implementation. I wonder if stuff like --java-path-prefix, which would be src by default, would work, and final path would be constructed using --out-dir + --java-path-prefix + relevant package dirs?

@jadzdotcom
Copy link

I also suffer from the hard coded source output. I end up running a batch file that generates the sources, and then copies them into the correct folder for my project.

@daviderickson
Copy link

@GreyCat Another option would be to add a flag, something like --no-src-prefix that disables that current default behavior, as I'm not sure someone would really want to use a prefix other than 'src', that they wouldn't just place into the out-dir parameter. You could also indicate that the 'src' prefix is deprecated and schedule removing that behavior entirely for a future release.

@GreyCat
Copy link
Member Author

GreyCat commented Nov 2, 2017

Well, to be frank, probably nobody would ever use --target all and generate multiple per-language paths except for running tests. So may be we could just make that java/src automatic for --target all and that's it...

@brunchboy
Copy link

This is a problem for me as well, because even though I am only generating java classes, because of the multi-language-nature of my Maven project, they need to go into src/main/java/ followed by the package directories. There is no way to configure ksc to do that, so I need to move them after generating them.

ams-tschoening added a commit to ams-ts-kaitai/compiler that referenced this issue Jan 16, 2020
Java and Got seem to be the only languages prepending "src" to their output directories, which make them fail in case a Maven-like directory tree with "src/main/java" is used. "java" itself needs to be the source folder already, not "java/src". Additonally its easy for users to add paths on their own, but difficult to remove those added by KS.

Like has been disucssed in the correpsonding issue, "src" keeps getting added in case "--target all" is given, which is most likely only the case for tests and those use a dir structure of "java/bin|src", where that makes sense.

kaitai-io/kaitai_struct#287
ams-tschoening added a commit to ams-ts-kaitai/compiler that referenced this issue Jan 16, 2020
Java and Got seem to be the only languages prepending "src" to their output directories, which make them fail in case a Maven-like directory tree with "src/main/java" is used. "java" itself needs to be the source folder already, not "java/src". Additonally its easy for users to add paths on their own, but difficult to remove those added by KS.

Like has been disucssed in the correpsonding issue, "src" keeps getting added in case "--target all" is given, which is most likely only the case for tests and those use a dir structure of "java/bin|src", where that makes sense.

kaitai-io/kaitai_struct#287
@GreyCat GreyCat added this to the v0.9 milestone Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants