允许Maven在Ubuntu中自动创建目录

时间:2013-07-08 11:27:19

标签: maven ubuntu

我在Ubuntu 12.04中运行Maven 3.0.4。我有Java版本1.7.0_25。我正在尝试使用mvn package命令,但我不断遇到错误,这些错误始终如下:

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

我无法弄清楚这最初是什么,但现在从一些基本的谷歌搜索中了解到这是因为目标目录必须存在。通常建议的处理这个问题的方法是创建一个蚂蚁脚本,它为你做(我认为)。

但是,我不知道实际需要创建哪些文件夹。这不是我正在编译的项目,只是我下载的内容。是否仍然可以使用Ant脚本,如果是这样,任何人都可以指出我正确的方向,因为我之前从未使用过蚂蚁脚本,更不用说创建了一个,并且可以非常准确地称为Ubuntu“noob”!

按要求输出完整的Maven

目录是:

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

Maven错误是:

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$ 

1 个答案:

答案 0 :(得分:4)

不,您不需要手动或使用ant脚本创建文件夹。

如果运行mvn时target文件夹不存在,则会创建它

所以我的猜测是你有权限问题

运行maven的用户无法在/ home / andrew / flume-sources

中创建文件夹

作为测试,以root身份运行mvn

 sudo mvn package

如果有效则那就是我所说的,你需要1)chown文件夹,以便运行maven的用户可以在其中创建文件夹(rw)或2)从同一用户运行mvn拥有该文件夹(我猜是andrew