Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn compiler:compile works, mvn compile not

Tags:

maven

I have a project with a maven 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>Minimal-J</groupId>
    <artifactId>Minimal-J</artifactId>
    <version>0.1-SNAPSHOT</version>
    <name>Minimal-J</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.8.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyclient</artifactId>
            <version>10.8.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin</artifactId>
            <version>6.7.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.miglayout</groupId>
            <artifactId>miglayout</artifactId>
            <version>3.7.4</version>
        </dependency>
        <dependency>
            <groupId>commons-dbutils</groupId>
            <artifactId>commons-dbutils</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <version>2.3.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <packaging>pom</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

if I execute

mvn compiler:compile

all 189 of my java classes are compiled

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Minimal-J 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-compiler-plugin:2.4:compile (default-cli) @ Minimal-J ---
[INFO] Compiling 189 source files to C:\projects\open-ech\workspace\minimal-j\MinimalJ\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.386s
[INFO] Finished at: Fri May 11 11:50:54 CEST 2012
[INFO] Final Memory: 13M/37M
[INFO] ------------------------------------------------------------------------

if I simply type

mvn compile

Nothing seems to be done:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Minimal-J 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.120s
[INFO] Finished at: Fri May 11 11:53:36 CEST 2012
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------

In a other project everything works fine.

Where could I possibly have configured something wrong to trigger this behaviour?

like image 964
Bruno Eberhard Avatar asked May 11 '12 10:05

Bruno Eberhard


People also ask

What does Maven compiler do?

The compiler plugin is used to compile the source code of a Maven project. This plugin has two goals, which are already bound to specific phases of the default lifecycle: compile – compile main source files. testCompile – compile test source files.

Which compiler does Maven use?

The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.

What is annotationProcessorPaths in Maven?

<annotationProcessorPaths>The detection itself depends on the configuration of annotationProcessors. Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically.

Does Maven use javac?

During the build of a project, Maven, without toolchains, will use the JDK to perform various steps, like compiling the Java sources, generate the Javadoc, run unit tests or sign JARs. Each of those plugins need a tool of the JDK to operate: javac, javadoc, jarsigner, etc.


1 Answers

It's because of pom packaging. By invoking mvn compiler:compile you run compile goal outside Maven's default lifecycle and that basically compile sources in src/main/java. And by mvn compile you run lifecycle up to compile phase and the actual goals executed in every single phase depend on project's packaging type then. pom-type project does nothing in compile phase, because - in fact - there is nothing to compile with just POM.

I suppose your intention was to have jar packaging and changing that should help.

like image 108
Michał Kalinowski Avatar answered Nov 08 '22 18:11

Michał Kalinowski