Search code examples
intellij-ideabuild-processartifactsintellij-15

Several artifacts, how to force build order?


I have a (standard non-maven, non-gradle, non-whatsoever) project in IntelliJ IDEA that consists of several modules.

One of those modules results in a jar that is used by one of the other modules.

I have two artifacts. The first one creates a war file. This one depends on the jar file built from the second artifact.

How can I order the build process of the two artifacts so that the second one creates the jar file and copies it to the lib folder of the first, before the first one builds, without the need to recreate both artifacts?

As soon as I select "Build/Build Artifacts/All Artifacts" it always tries to build the first one first.

EDIT: Maybe a better question: What is the recommended way to manually build several artifacts in order of their dependencies?


Solution

  • How can I [configure IDEA] ... so that [it] ... creates the jar file and copies it to the lib folder of the first...

    You can't really configure IDEA to do this directly. While you can configure Artifacts in the Project Structure dialog, there are no provisions for copying artifacts. IntelliJ IDEA is an IDE, not a build tool. While it can do a lot regarding complying and building, it has its limits.

    One possible hackish way would be to go to the Artifact definition in the project structure. There, there are "Pre-processing" and "post-processing" tabs, They have the option to run an Ant target. So you could create a simple Ant target to do the copying. But in the end, I think the best answer to your question:

    Maybe a better question: What is the recommended way to manually build several artifacts in order of their dependencies?

    is to use a build tool such as Ant, Maven, or Gradle for building the project.