Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top