简体   繁体   中英

Maven: build ear: skip compile phase?

Here is part of POM
...

   <groupId>com.soft</groupId>
   <artifactId>config-ear</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>ear</packaging>

   <name>Enterprise Application</name>
   <url>http://maven.apache.org</url>

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>      
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>wsgen</goal>
                  </goals>
                  <configuration>
                     <sei>com.soft.WebService</sei>
                     <genWsdl>true</genWsdl>           
                     <keep>true</keep>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.6</version>
            <configuration>
               <version>1.4</version>
               <defaultLibBundleDir>lib</defaultLibBundleDir>
            </configuration>
         </plugin>
      </plugins>
   </build>  
...  

run mvn clean install

[clean:clean]
Deleting directory D:\Development\config-ear\target
[ear:generate]
Generating application.xml
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\Development\config-ear\src\main\resources
[jaxws:wsgen]
Class not found: "com.soft.WebService"  

This class existst in src/main/java/com/soft/WebService.java
Where is compile phase??

From the Maven Lifecycle Reference :

Default Lifecycle Bindings - Packaging ear

generate-resources  ear:generateApplicationXml
process-resources   resources:resources
package             ear:ear
install             install:install
deploy              deploy:deploy

As you can see, the EAR lifecycle does not contain a compile phase

I don't think you're supposed to have Java source code directly in your EAR project. The EAR project should only pull in the other artifacts, eg WAR, EJB or JAR files with your classes.

So if you want some custom classes in your EAR file, you will have to create another project with JAR packaging and then include that as a dependency from your EAR project.

Please take a look at the first answer in this question, it shows the recommended structure for the EAR packaging: Maven2: Best practice for Enterprise Project (EAR file)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM