Ealon
Ealon

Reputation: 4898

Does IntelliJ IDEA skip maven build lifecycle?

In my pom.xml, I have a plugin copying files from one folder to another.

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>install</phase> <!--Other phases don't work in IntelliJ IDEA either-->
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/src/main/resources</outputDirectory>
                <resources>
                    <resource>
                        <directory>${basedir}/src/main/ui/build</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

When I run mvn clean install, the files are copied successfully. But you know, I seldom use maven to build and deploy the app, I always click the button in IntelliJ IDEA to deploy the app. In this way, the files are not copied.

enter image description here

So does the deployment process in IntelliJ IDEA skip maven install? How can I make this work? Thanks.

Upvotes: 1

Views: 1372

Answers (2)

Naman
Naman

Reputation: 31878

I would suggest you to Edit the Run configuration that you are using as in the image shared by you and add Maven Goal to the build step. Try this

  • Edit Configurations..
  • Before launch -> Add -> Run Maven Goal -> mvn clean install (Command Line) -> OK
  • You can reorder Make, Run Maven Goal according to your preference.

Attaching a sample image that can help you add the before launch task -

enter image description here

So next time when you press the Start button here the maven goal is automatically executed.

PS : -> relates to (Select/Input)

Upvotes: 1

Klaus Groenbaek
Klaus Groenbaek

Reputation: 5035

When your run configuration is like the screenshot indicates, intellij just compiles the module (with the module output paths), and then it runs the target main with the module classpath selected.

If you want to run any maven goals before hand, you need to set those on the Run Configuration in the "Before Launch" where make is.

It looks like you are having problems with resources. These should be automatically copied by IntelliJ into the classpath. This is configured in Setting => Compiler => Resource Pattern.

Upvotes: 1

Related Questions