1

I am creating a custom maven-plugin which requires some json files in the the mojo class and do some further processing on them. I will be taking these files as input from the user. is there any way to pass these files or path of these files with mvn clean install and access them in mojo class.

for ex - mvn clean install C:\Users\john\abc.json

akash patel
  • 163
  • 9
  • 1
    If you write a mojo you should think about using the file as a parameter of the mojo .. This can be enhanced to used on command like this: `mvn clean install -Dmojo.x=abc.json .. apart from that I would strongly discourage using a file which influences the build. Better put that file into the project and let the mojo read it... – khmarbaise Sep 21 '20 at 16:30
  • can you elaborate the 2nd approach you are talking about ? – akash patel Sep 21 '20 at 18:17
  • You should decide a directory in the directory structure of a project for example `src/main/` and put the file `abc.json` into it ...and your mojo should read it from that location to process what you need. that means it is under version control with the rest of the project. Apart from that I would suggest to reconsider writing integration tests for your plugin (see https://github.com/khmarbaise/maven-it-extension).. or use the traditional approaches via maven-invoker-plugin etc. – khmarbaise Sep 21 '20 at 18:30

0 Answers0