Andrew Martin
Andrew Martin

Reputation: 5731

Allow Maven to automatically create directories in Ubuntu

I am running Maven 3.0.4 in Ubuntu 12.04. I have Java version 1.7.0_25. I am trying to use the mvn package command, but am continually running into errors, which are always along the lines of:

Failure executing javac, but could not parse the error:
javac: directory not found: /......../target/[some folder]

I couldn't figure out what this was originally but now understand from some basic googling that this is because the destination directory has to exist. The generally suggested way to handle this problem is to create an ant script which does it for you (I think).

However, I have no idea what folders actually need to be created. This is not my project I'm compiling, just something I've downloaded. Can an Ant script still be used and, if so, could anybody point me in the right direction as I have never used an ant script before, much less created one, and could quite accurately be called a Ubuntu "noob"!

Full Maven output as requested

Directory is:

flume-sources - containing
    flume.conf
    pom.xml
    src
      main
        java
          com
            cloudera
              flume
                source
                  TwitterSource.java
                  TwitterSourceConstants.java

Maven error is:

andrew@andrew-VirtualBox:~/flume-sources$ mvn package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building flume-sources 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ flume-sources ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/andrew/flume-sources/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ flume-sources ---
[INFO] Compiling 2 source files to /home/andrew/flume-sources/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error:
javac: directory not found: /home/andrew/flume-sources/target/classes
Usage: javac <options> <source files>
use -help for a list of possible options

[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.470s
[INFO] Finished at: Mon Jul 08 12:35:58 BST 2013
[INFO] Final Memory: 9M/59M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project flume-sources: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: directory not found: /home/andrew/flume-sources/target/classes
[ERROR] Usage: javac <options> <source files>
[ERROR] use -help for a list of possible options
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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
andrew@andrew-VirtualBox:~/flume-sources$ 

Upvotes: 3

Views: 2578

Answers (1)

Hilikus
Hilikus

Reputation: 10331

No, you don't need to create the folder by hand or with an ant script.

If the target folder doesn't exist when you run mvn, it will create it

So my guess is that you have a permissions issue

The user running maven can't create folders in /home/andrew/flume-sources

just as a test, run mvn as root

 sudo mvn package

if that works then it is what I said and you will need to 1) chown the folder so that the user running maven can create folders in it (rw) or 2) run mvn from the same user that owns the folder (which i'm guessing is andrew)

Upvotes: 5

Related Questions