"generate source" mojo iterates over the files if source is a dir. - #184
Conversation
The test is that the yaml plugin example actually split the definition in three yaml files, in a dir. This dir is assigned as the plugin's "source" value. Also more docs for api.
|
Note : this modification is because I want to extract the implicit structure from a yaml file into a flatStructure, then from it into corresponding java class. a:
b: c
d: 5would produce A :
b : String
d : int
Root:
a : Aneeds a lot of time to work on it though. The goal is to generate yaml parser from yaml file. And later spring entity from yaml files :D |
| * if it is a dir. Otherwise, return empty stream. | ||
| */ | ||
| @NonNull | ||
| protected Stream <InputStream> streamFiles (File rootFile) |
There was a problem hiding this comment.
We should change the return type to a "pair (InputStream, filename)" so that error messages from the caller can provide more details
There was a problem hiding this comment.
yeah, I was thinking about that. The issue is that eg for urls there is no such a file name to be provided, and when the data is set, it's priority is higher and does not have a file name either.
Was still thinking about it.
| getLog ().info ("while trying to open " + m_sSource + " as a url", e); | ||
| getLog ().error ("while trying to open " + m_sSource + " as a file", fileException); | ||
| getLog ().error ("while trying to open " + m_sSource + " as a url", e); | ||
| } |
There was a problem hiding this comment.
The log errors should be split into the appropriate branches
There was a problem hiding this comment.
No, I did it exactly like this on purpose.
If the first call fails, but not the second, it means there was no point complaining about the file not existing.
When set, the plugin accepts only files containing that param, when the source is a directory
|
@phax the new sourcesFilte param : |
The plugin can now be configured with a directory rather than an url / single file
In the example module, the pom references the
concreteYamldirectory to generate some trivial concrete classes, before the files in that directory were in a single one.This is done at the plugin level so generators should not be changed.
When a dir is found, all the files in it are applied to the generator, on the same JCM which is exported at the end. Therefore, each file must be valid on their own, and should not reference type from another one.
Also more docs for api.
No change is applied otherwise, and it only allows to use directory, so previous behavor did not change