NimChimpsky
NimChimpsky

Reputation: 47290

maven clean deletes target. This then screws up a normal build

I get no errors, however the class files are no longer copied to target directory ("/WEB-INF/classes/...") when doing my next normal (non clean) build.

Thanks muchly for any help, I am learning maven.

When I say normal build, I am using war:war from within eclipse.

Upvotes: 3

Views: 1565

Answers (3)

Chris Beach
Chris Beach

Reputation: 4392

I find it's helpful to give Eclipse builds a separate directory from Maven CLI builds:

Insert the following into your pom.xml. The existence of the "m2e.version" property will activate the following profile which alters the location of the Eclipse build

<profiles>
  <profile>
    <id>IDE</id>
    <activation>
      <property>
        <name>m2e.version</name>
      </property>
    </activation>
    <build>
      <!-- Put the IDE's build output in a folder other than target, so that IDE builds don't interact with Maven builds -->
      <directory>target-ide</directory>
    </build>
</profile>

Upvotes: 0

Dhanush Gopinath
Dhanush Gopinath

Reputation: 5739

mvn clean is supposed to cleanup the target directory as per the clean lifecycle phase. You have to compile the source again using compile plugin.

You can use mvn clean compile war:war to create the war.

Or you can invoke the default lifecyle by running mvn install

Upvotes: 1

Tarlog
Tarlog

Reputation: 10154

When running mvn war:war, you don't run the normal maven life cycle, which beyond others includes the classes compilation. So basically you have no compiled classes to be added to WEB-INF/classes since you didn't compile them.

Just run mvn install and it should work.

Upvotes: 6

Related Questions