0

I have a project that I can build successfully with mvn clean install. I can also use the mvn exec:java command to execute scripts contained in the src/com/mycompany/myproject/ folder by fully qualifying the "mainClass" in the POM as:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <configuration>
        <mainClass>com.mycompany.myproject.MyMainClass</mainClass>
    </configuration>
</plugin>

But I would like to execute a script contained in the project top-level folder, i.e. the same folder containing the pom.xml file. This class is an example application that demonstrates the functionality of the project being built, and isn't actually part of the project itself, and that's why it isn't contained in src/com/mycompany/myproject. If I enter the mainClass simply as <mainClass>MyClassInCurrentFolder</mainClass>, then it doesn't find it.

I suppose I could create an entirely separate Maven project which contains only this class under src/com/mycompany/myproject/, and which uses the other project as a dependency. But I'd rather not do that, it's only a very simple demo application for the project after all.

Any ideas on how I can use Maven to execute this file in the top-level folder?

mindthief
  • 12,755
  • 14
  • 57
  • 61

1 Answers1

0

I would recommend to use a separate module as you mentioned by yourself, cause it's the best way to separate the real code and the demo. This would make the usage of Demo simpler and configuration for the Demo module.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • this is what I ended up doing. the other alternative I was considering was to just make the demo app part of the project by adding it to the project src tree, including it in the project package. but that seemed less clean to me, and, you're probably right that separating it out this way will afford more flexibility in future. – mindthief Nov 01 '12 at 20:05