Farah
Farah

Reputation: 2621

Command line to create a Maven artifact and having as input *.java files of a directory

I have a directory which contains *.java files generated by a C++ project build.

I need a command line to create a *.jar file which :

  1. contains the generated *.java files. These java files initially exist in a directory that I would specify to the command line;
  2. the *.java files must be placed in a package that I would specify to the command line;
  3. must be a Maven artifact, of type .jar and so which has a version, a groupId, and artifactId that I would specify to the command line;

I need this command line to be executed in a post-build for my C++ project build.

Thank you

Upvotes: 0

Views: 2418

Answers (1)

Steven Pessall
Steven Pessall

Reputation: 993

Assuming you have a correct pom.xml you can start maven with the following command:

mvn clean install -Dproject.build.sourceDirectory=<your directory>

Though maven can be irritating when you don't use the default of "src/main/java"

Regarding 2.:

Passing the java package as a command line parameter is problematic, as the .java-Files must declare the correct package and must be located in a matching directory.

You could use the filtering mechanism of the maven-resources-plugin to replace a wildcard in your source files with the actual package, but you would need an existing pom.xml with the configuration for the plugin.

Upvotes: 1

Related Questions