11

I'm making some tests and I would like to understand why after execute the command mvn clean I need to execute "Maven > Update Project" before run mvn package, otherwise I get a compilation error in one of my dependencies during the packaging.

It looks like my project doesn't compile correctly my project before running "Maven > Update Project", but I'm not sure. Is this normal?

  • I'm using Eclipse and run the commands {mvn clean} and {mvn package} via "Run as > Maven Build".

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.project</groupId>
    <artifactId>myProject</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <jmockit.version>0.0.1</jmockit.version>
    </properties>

    <build>
        <testSourceDirectory>src/test/java/junit</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/java/selenium</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>

        <pluginManagement>
            <plugins>
                <!-- Need Java 5, which is the default since v2.3 of the maven-compiler-plugin. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warSourceExcludes>src/main/resources/conf_development</warSourceExcludes>
                    <webResources>
                        <resource>
                            <directory>src/main/resources/conf_production</directory>
                            <targetPath>WEB-INF/classes/</targetPath>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </resource>
                        <resource>
                            <directory>src/main/resources/conf</directory>
                            <targetPath>WEB-INF/classes/</targetPath>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        -javaagent:"${settings.localRepository}"/mockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
                    </argLine>
                </configuration>
            </plugin>
        </plugins>
    </build>


<dependencies>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>1.5.3</version>
    </dependency>
    <dependency>
        <groupId>bouncycastle</groupId>
        <artifactId>bcprov-jdk14</artifactId>
        <version>140</version>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1</version>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0-oracle-thin-extras</artifactId>
        <version>0.9.0.2</version>
    </dependency>
    <dependency>
        <groupId>commons-betwixt</groupId>
        <artifactId>commons-betwixt</artifactId>
        <version>0.7</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-email</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.4.2</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.ehcache-spring-annotations</groupId>
        <artifactId>ehcache-spring-annotations</artifactId>
        <version>1.1.3</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.1.2</version>
    </dependency>
    <dependency>
        <groupId>net.sf.json-lib</groupId>
        <artifactId>json-lib</artifactId>
        <version>2.4</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>net.fckeditor</groupId>
        <artifactId>java-core</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>backport-util-concurrent</groupId>
        <artifactId>backport-util-concurrent</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.icu</groupId>
        <artifactId>icu4j</artifactId>
        <version>3.8</version>
    </dependency>
    <dependency>
        <groupId>mockit</groupId>
        <artifactId>jmockit</artifactId>
        <version>${jmockit.version}</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>atg.taglib.json</groupId>
        <artifactId>json-taglib</artifactId>
        <version>0.4.1</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.5</version>
    </dependency>
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>1.8.4</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.25.0</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-agent</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>2.5.6.SEC03</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-config-browser-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-convention-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-jasperreports-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-jfreechart-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-json-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-spring-plugin</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.6.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity-tools</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>com.yahoo.platform.yui</groupId>
        <artifactId>yuicompressor</artifactId>
        <version>2.4.6</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jodreports</groupId>
        <artifactId>jodreports</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-oxm</artifactId>
        <version>1.5.9</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>1.5.9</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-oxm-tiger</artifactId>
        <version>1.5.9</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core-tiger</artifactId>
        <version>1.5.9</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-xjc</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.commons.axiom
        </groupId>
        <artifactId>axiom-api</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.commons.axiom
        </groupId>
        <artifactId>axiom-impl</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxrpc-api</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium.client-drivers</groupId>
        <artifactId>selenium-java-client-driver</artifactId>
        <version>1.0.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.acegisecurity</groupId>
        <artifactId>acegi-security</artifactId>
        <version>1.0.7</version>
    </dependency>
    <dependency>
        <groupId>citizen</groupId>
        <artifactId>citizen</artifactId>
        <version>citizen</version>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>3.5.3</version>
    </dependency>
</dependencies>
</project>

The error:

(Remembering that the lib with error it's an internal lib and it work just fine after "Maven > Update Project")

[INFO] Compiling 2595 source files to C:\Users\user\Documents\Dev\workspace\project\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34] cannot access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
        Resolution2Locator r2 = new Resolution2Locator ();
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:09.448s
[INFO] Finished at: Fri Mar 22 11:55:14 BRT 2013
[INFO] Final Memory: 25M/274M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project project: Compilation failure
[ERROR] C:\Users\user\Documents\Dev\workspace\project
\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38
,34] cannot access org.apache.axis.client.Service
[ERROR] class file for org.apache.axis.client.Service not found
[ERROR] Resolution2Locator r2 = new Resolution2Locator();
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project u
nico: Compilation failure
C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38,34] can
not access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
        Resolution2Locator r2 = new Resolution2Locator ();

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
C:\Users\user\Documents\Dev\workspace\project\src\main\java\com\project\jobs\citizen\model\service\CitizenService.java:[38,34] can
not access org.apache.axis.client.Service
class file for org.apache.axis.client.Service not found
        Resolution2Locator r2 = new Resolution2Locator ();

    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Pmt
  • 1,122
  • 3
  • 13
  • 27
  • 1
    just to confirm : are you using eclipse ? and do you run `mvn clean` and `mvn package` from eclipse ? and what kind of error do you get ? – benzonico Mar 20 '13 at 19:08
  • Yes, I'm using Eclipse and run the commands {mvn clean} and {mvn package} via "Run as > Maven Build". I get a compilation error in one of my dependencies. – Pmt Mar 20 '13 at 19:22
  • The maven-eclipse integration is totally buggy. If you are learning maven, I strongly suggest to use the command line or any other IDE. (i.e. the fact that you need to run update dependencies is because of those bugsss in eclipse, it is not required when run maven only) – ben75 Mar 20 '13 at 19:28
  • Really? Well, I'll try it in command line and tell you the results. – Pmt Mar 20 '13 at 19:58
  • what do you exactly mean by compilation error in dependency? Are you missing dependency? And also why would you want to run mvn clean and package from eclipse? Eclipse mhandleshandles your builds atomaticaly – Hurda Mar 20 '13 at 20:21
  • Which plugin are you using? m2e-wtp to deploy to the server? You have to understand the difference between the result of mvn commands (which does the same as executing them from command line) and the eclipse deployment, which is done by m2e-wtp without the needing of running the command. – Aritz Mar 20 '13 at 21:20
  • @ben75 Same error in command line. Any suggestions? – Pmt Mar 21 '13 at 19:21
  • @Hurda I don't need to! I just think it is easier. Anyway, I'm testing in command line and the same error occurs – Pmt Mar 21 '13 at 19:24
  • @XtremeBiker I'm using "Maven Integration for Eclipse WTP (Incubation)" and "Maven Integration for Eclipse". The same is happening out of Eclipse. Do you have any suggestion? – Pmt Mar 21 '13 at 19:30
  • if you are building multiple modules at once, then you need to install the modules you have just build before compiling the modules depending on them... so run `mvn clean install` (it will recusively and in the correct order compiling, packaging and installing all your modules) – ben75 Mar 21 '13 at 20:13
  • @Hurda , I added the error log at the question body. – Pmt Mar 22 '13 at 15:09
  • @PimentaDev. Where exactly is `org.apache.axis.client.Service` defined? Can we see the dependency declaration? When you say it's an internal lib, you mean it's not in any public repository? – Nathaniel Waisbrot Mar 22 '13 at 15:26
  • @NathanielWaisbrot, I added the dependencies at the question body. About the lib, it's exactly this. Someone in here made this lib and we just refer it. The `org.apache.axis.client.Service` is called from inside of this lib. Do you think this jar it's the problem? I thought the problem is Maven because everything work perfectly after `"Maven > Update Project"`. (The lib it's available in our Artifactory) Thanks again for the persistence! – Pmt Mar 22 '13 at 16:50
  • @PimentaDev. I'm pretty puzzled. Most of what "Update Project" does is only for Eclipse and has no effect on Maven. The only thing that's global is that it updates missing and old artifacts. Are you using a non-standard `settings.xml` in Eclipse? I guess I'd try doing a `mvn clean`, then wiping your local repository under `.m2` and then a `mvn package`. And don't have Eclipse running in case it's trying to auto-build at the same time. – Nathaniel Waisbrot Mar 22 '13 at 17:40
  • @NathanielWaisbrot When I run `mvn clean` directly from prompt, all the folder _target_ are deleted. Then when I try to run `mvn package` (or ANY other goal) the package is created, but it looks like incomplete. I guess that the error are leaving the folder inconsistent or something like this. So the "Maven > Update Project" are correcting the folder. – Pmt Mar 22 '13 at 20:42
  • @NathanielWaisbrot I already tested all the process with Eclipse closed, and the result was the same. I'm thinking that it's a problem with my jar or with some of the dependencies in it. I don't know. Maybe the order of the libs during the loading? - My settings.xml is defined into .m2 folder. No link with Eclipse. – Pmt Mar 22 '13 at 20:43
  • @PimentaDev, I'm facing the same problem with my maven project. Did you resolve the issue? – Dmitry D Mar 25 '13 at 17:23
  • Here is what happens (like you explained earlier): mvn clean deletes target dir. During execution of mvn package you we get CompilationError. That's why we have incomplete target folder. After updating project I admit Eclipse makes compilation by yourself (without maven). So, we have all the classes compiled. And finally build succeeds because maven compiles nothing at that moment. – Dmitry D Mar 25 '13 at 17:31
  • We get compilation error because javac cannot find the class imported in some another class from one of dependency jars. The only thing I don't understaffed why it behaves in such way? It seems like it tries co compile dependent jar... – Dmitry D Mar 25 '13 at 17:36
  • @dmiandre No, I didn't! I also tried to execute each one of the other commands (validade, process-sources, test-compile, etc) and nothing worked. I don't know what to do, so I'm running "Maven > Update Project" always after `mvn clean`. – Pmt Mar 25 '13 at 18:08
  • @PimentaDev It could be only a temporary solution, because in this case you can't actually build your project with maven. It seems like Elipse builds it, using it's own project structure (when you call Maven > Update Project). – Dmitry D Mar 25 '13 at 18:31
  • 1
    I think something wrong with maven configuration or project's pom.xml. After adding dependency with required class I successfully compiled project with maven. But it's transitive dependency. Even dependency plugin reports that it's unnecessary. – Dmitry D Mar 25 '13 at 18:37
  • @dmiandre Thanks man!! It was exactly this! I added the dependency into my pom and everything ran perfectly outside Eclipse! The problem was that my internal lib wasn't build with Maven, so the dependencies inside de jar wasn't explicit to my main project. So the `axis` wasn't added to my build path, resulting in the compilation problem showed above. I just can't understand why it works in Eclipse. I thought Tomcat could be the reason, but I didn't find the lib inside the servlet container. Do you have any idea? Please, answer the question to let me mark it as resolved. Thank you all. – Pmt Mar 25 '13 at 20:25
  • Maybe you have additional classpath variables in eclipse -> preferences -> java -> build path -> classpath variables? Or maybe you have this class in CLASSPATH environment variable. – Dmitry D Mar 26 '13 at 15:42
  • @dmiandre I checked but couldn't find it. I really don't know... – Pmt Mar 26 '13 at 17:00

3 Answers3

27

Here is what happens:

  1. mvn clean deletes the target directory
  2. mvn package performs some work, but then encounters a compilation error due to a missing dependency. That's why the target folder is in error.
  3. Running Maven > Update Project in Eclipse causes Eclipse to perform its own compilation, separate from Maven. Eclipse has a different classpath than Maven, so its compilation succeeds. Now the target directory has all the compiled classes.
  4. Re-running mvn package now succeeds, because it finds all the classes already compiled and doesn't need to perform any compilation.

Ultimately, the problem is in the project configuration in pom.xml. I had the same problem, and after adding the missing dependency I successfully compiled project with Maven.

Dmitry D
  • 760
  • 12
  • 24
2

The Eclipse m2e plugin (this is a simplification) reads the POM file and translates it into instructions for Eclipse so that Eclipse can do its thing. Because Eclipse is in control the whole time, your view gets updated correctly and things are pretty smooth. Some more advanced Maven actions with plugins are not supported by m2e, and so those actions just won't happen. Some simple stuff, like the classpath is different from how Maven does things -- m2e uses the "test" classpath no matter what because Eclipse can't predict what you'll want to run.

On the other hand, performing "Run as > Maven ..." actually calls Maven, a program completely outside of Eclipse, and asks it to run. Eclipse doesn't automatically know when files have been created or deleted by Maven.

I would generally stay away from the "Run as > Maven" commands. The integration is poor, the Eclipse console interface is ugly, it's just easier to call mvn from the command line if you need to run specific Maven goals.

If you just want to develop a Maven project, I find the m2e integration works very well. I use Jenkins to handle the packaging and deployment for me, so I'm only using Eclipse to edit and test my code.

Nathaniel Waisbrot
  • 23,261
  • 7
  • 71
  • 99
  • Thanks a lot for the explanation!! The idea it's to run it with Jenkins to, but until the migration isn't done, we will need to execute those commands locally. Unfortunately the same error occurs when I execute `mvn clean` directly from prompt. Do you have any idea of what I should do? Thanks again. – Pmt Mar 21 '13 at 19:35
  • 1
    @PimentaDev. what is the error that you see when you run `mvn clean`? – Nathaniel Waisbrot Mar 21 '13 at 20:47
  • `mvn clean` it's running fine. The problem it's `mvn package` *after* that. One of my libs get a compilation error, but I don't know why. The error only stops if I open Eclipse and run "Maven > Update Project"! – Pmt Mar 21 '13 at 21:26
  • These sound like great reasons to stay away from Eclipse. IntelliJ has no problems letting Maven run the build. – Greg Chabala Aug 14 '13 at 16:59
  • 1
    @GregChabala For projects where you need to do something complex or strange with Maven, then I wouldn't recommend Eclipse. But for a user already familiar with Eclipse who just needs to be able to clean and build a project, m2e is pretty great. – Nathaniel Waisbrot Aug 14 '13 at 17:31
0

It will update the files if any new updates avialable.you can use maven install after maven clean

PSR
  • 39,804
  • 41
  • 111
  • 151
  • But why the command `mvn package` work? And there isn't any updates to be done, just rebuild the project. – Pmt Mar 20 '13 at 20:00