Eclipse中的Android Maven - 创建活动

时间:2023-01-25 14:19:17

Every time I create an Activity in Eclipse using the Android-Maven plugin, the Activity automatically gets created under src rather than src/main/java.

每次我使用Android-Maven插件在Eclipse中创建Activity时,Activity都会自动在src而不是src / main / java下创建。

For example, I have the src/main/java source file in the Eclipse Package Explorer. Under the source folder I have the com.example.package.name package. I right click the package and select "New" -> "Other" and select "Android Activity". After putting in all the information regarding the new Activity I click "Finish". The problem is, when Eclipse creates the Activity and updates the Manifest, it puts the new Activity under "src/com/example/package/name" and indicates that path in the Manifest. It should be placing the Activity under "src/main/java/com/example/package/name".

例如,我在Eclipse Package Explorer中有src / main / java源文件。在源文件夹下,我有com.example.package.name包。我右键单击包并选择“新建” - >“其他”并选择“Android活动”。在输入有关新活动的所有信息后,单击“完成”。问题是,当Eclipse创建Activity并更新Manifest时,它将新的Activity放在“src / com / example / package / name”下并指示Manifest中的路径。它应该将Activity放在“src / main / java / com / example / package / name”下。

This behavior is correct and expected for ant-based Android builds, but not Maven, as Maven requires a src/main/java and src/main/test folder before it even compiles and launches your Android application! Maven will still compile and build, it's just awkward and does not follow the primary Maven "Convention over Configuration" principle: (http://www.sonatype.org/maven/why)

对于基于ant的Android构建,这种行为是正确的,但不是Maven,因为Maven在编译和启动Android应用程序之前需要src / main / java和src / main / test文件夹! Maven仍然会编译和构建,它只是笨拙并且不遵循主要的Maven“约定优于配置”原则:(http://www.sonatype.org/maven/why)

Anyone else having these sorts of issues? Is manually relocating these Activities and manually updating the Manifest the only method to deal with this?

有其他人有这些问题吗?手动重定位这些活动并手动更新Manifest是解决此问题的唯一方法吗?

1 个解决方案

#1


0  

You should take a look at m2e-android - An Android Configurator for M2E Maven Integration for Eclipse.

您应该看看m2e-android - 用于Eclipse的M2E Maven Integration的Android配置器。

As you can see, it allows you to work with the standard maven directory layout :

如您所见,它允许您使用标准的maven目录布局:

Eclipse中的Android Maven  - 创建活动

#1


0  

You should take a look at m2e-android - An Android Configurator for M2E Maven Integration for Eclipse.

您应该看看m2e-android - 用于Eclipse的M2E Maven Integration的Android配置器。

As you can see, it allows you to work with the standard maven directory layout :

如您所见,它允许您使用标准的maven目录布局:

Eclipse中的Android Maven  - 创建活动