如何处理Android / Maven项目中缺少的src / test / java源文件夹? [英] How to deal with missing src/test/java source folder in Android/Maven project?

查看:534
本文介绍了如何处理Android / Maven项目中缺少的src / test / java源文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我并没有与Android结合使用Maven的经验,所以我遵循这些制作新的Android项目的说明。项目创建完成后,我会收到以下错误消息:

I'm not very experienced with Maven in combination with Android yet, so I followed these instructions to make a new Android project. When the project has been created, I get the following error message:


项目'xxx-1.0-SNAPSHOT'缺少必需的源文件夹:
'src / test / java'

Project 'xxx-1.0-SNAPSHOT' is missing required source folder: 'src/test/java'

当我尝试添加一个新的源文件夹New-> Other->使用src / test / java的Java源文件夹,我收到另一个错误消息:

When I try to add a new source folder with New->Other->Java-Source Folder with src/test/java, I get another error message:


该文件夹已经是源文件夹。 >

The folder is already a source folder.

但是我的项目中没有任何src / test / java文件夹。我该怎么处理?什么是干净的方式来设置项目,因为我认为这个说明中缺少一些东西。那么什么是Maven的方式让src / test / java出现?

But I don't have any src/test/java folder in my project. How should I deal with that? What's the clean way to setup the project, because I assume that there is something missing in this instruction. So what is the Maven way to let src/test/java appear?

我正在使用Eclipse Juno,m2e 1.1.0,Android配置为m2e 0.4.2。

I'm using Eclipse Juno, m2e 1.1.0, Android Configuration for m2e 0.4.2.

推荐答案

从最新的m2e-android插件升级(版本0.4.2)开始,我也意识到这个烦人的事情,项目创建和现有项目导入(如果您不使用src / test / java)。

I realise this annoying thing too since latest m2e-android plugin upgrade (version 0.4.2), it happens in both new project creation and existing project import (if you don't use src/test/java).

看起来像m2e-android(或者也许是m2e)现在总是试图添加 src / test / java 作为源文件夹,无论它是否实际存在于项目目录中,在.classpath文件中:

It looks like m2e-android (or perhaps m2e) now always trying to add src/test/java as a source folder, regardless of whether it is actually existed in your project directory, in the .classpath file:

<classpathentry kind="src" output="bin/classes" path="src/test/java">
  <attributes>
    <attribute name="maven.pomderived" value="true"/>
  </attributes>
</classpathentry>

由于它已经添加到项目元数据文件中,所以如果您尝试添加源文件夹, Eclipse,Eclipse会抱怨classpathentry已经存在:

As it is already added in the project metadata file, so if you trying to add the source folder via Eclipse, Eclipse will complain that the classpathentry is already exist:

有几种方法来解决它,最简单的是在文件系统中手动创建src / test / java目录,然后刷新你的项目通过按 F5 并运行Maven - >更新项目(右键单击项目,选择Maven - >更新项目...),这应该修复缺少的必需源文件夹:'src / test / java'错误。

There are several ways to fix it, the easiest is manually create src/test/java directory in the file system, then refresh your project by press F5 and run Maven -> Update Project (Right click project, choose Maven -> Update Project...), this should fix the missing required source folder: 'src/test/java' error.

这篇关于如何处理Android / Maven项目中缺少的src / test / java源文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆