开发者

Maven 2: eclipse-plugin to generate EAR's dependent projects to .project file

开发者 https://www.devze.com 2023-04-06 17:37 出处:网络
I\'m trying to generate eclipse-project files using Maven2 eclipse-plugin for RAD7.5. All is going well except for the dependencies in the EAR\'s .project file.

I'm trying to generate eclipse-project files using Maven2 eclipse-plugin for RAD7.5. All is going well except for the dependencies in the EAR's .project file.

When I run mvn eclipse:eclipse on a clean maven project, I come up with an EAR such as this:

<projectDescription>
  <name>MyEAR</name>
  <comment>The .project file of MyEAR</comment>
  <projects/>
  <buildSpec>
    <buildCommand>
      <name>org.eclipse.wst.common.project.facet.core.builder</name>
    </buildCommand>
    <buildCommand>
      <name>org.eclipse.wst.validation.validationbuilder</name>
    </buildCommand>
    <buildCommand>
      <name>org.eclipse.jdt.core.javabuilder</name>
    </buildCommand>
    <buildCommand>
      <name>com.ibm.etools.validation.validationbuilder</name>
    </buildCommand>
    <buildCommand>
      <name>com.ibm.sse.model.structuredbuilder</name>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
  </natures>
</projectDescription>

BUT I want to be coming out with something like this:

<projectDescription>
  <name>MyEAR</name>
  <comment>The .project file of MyEAR</comment>
    <projects>
        <project>MyProjectConnector</project>
        <project>MYProjectEJB</project>
        <project>MyProjectDependents</project>
        <project>MyProjectLOG</project>
    </projects>
...
</projectDescription>

RAD7.5 don't understand the project structure unless the dependent projects are listed in the < projects >. But how do I do that with the eclipse-plugin? Where in the pom do I list the dependent projects, so they appear in the .project-file as < projects >?

Edit>> Here's the maven-eclipse-plugin config of my pom-file

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>1.5</wtpversion>
                    <packaging>ear</packaging>
                </configuration>
            </plugin>
        </plugins>
        <finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName>
</build>

<

EDIT2: I must add that the projects builds ok, i.e. mvn clean install works fine, so basically the problem is with the eclipse plugin configuration.

EDI开发者_如何学GoT3: The maven-project is built in the following fashion:

MyEAR-reactor-build
|-- pom.xml
|-- MyEAR
|   |-- pom.xml
|-- MYProjectEJB
|   |-- pom.xml
`-- . . .

ALL HELP GREATLY APPRECIATED!!! (thanks for reading this far :)


Have you declared your modules and dependent projects as dependencies in your EAR's POM?

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>ear</packaging>
    <groupId>so.com</groupId>
    <artifactId>MyEAR</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>so.com</groupId>
            <artifactId>MYProjectEJB</artifactId>
            <scope>runtime</scope>
            <type>ejb</type>
        </dependency>
        . . .
    </dependencies>

    . . .


You may need to create a module reactor build -

MyEAR-reactor-build
|-- pom.xml
|-- MyEAR
|   |-- pom.xml
|-- MYProjectEJB
|   |-- pom.xml
`-- . . .

The reactor build POM would look something like this -

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>so.com</groupId>
    <version>1.0-SNAPSHOT</version>
    <artifactId>MyEAR-reactor-build</artifactId>
    <packaging>pom</packaging>
    . . .
    <modules>
        <module>MyEAR</module>
        <module>MYProjectEJB</module>
        . . .
    </modules>
</project>


Ahh...thanks everybody for the help. The problem turned out to be that higher in the pom hierarchy, another developer had introduced the eclipse-plugin with the element:

<useProjectReferences>false</useProjectReferences>

For some reason having set this to true in my pom didn't override the parent setting. A bug at the eclipse-plugin, perhaps? Anyway, after setting this to true at the parent pom, all worked out. Thanks everybody for help!

0

精彩评论

暂无评论...
验证码 换一张
取 消