使用maven作为Weblogic 10.3的构建工具

时间:2008-11-13 16:02:27

标签: maven-2 integration weblogic

我正在尝试设置Weblogic Server 10.3(以及Portal等)以使用maven作为构建工具。我试图找到一个体面的教程或文档如何做到这一点。有一些教程适用于9.0等旧版本,但版本10的信息很少。

我正在寻找一种使用maven构建weblogic的ear文件的方法。人们真的这样做吗?使用maven值得麻烦吗?

我想使用maven,以便更轻松地与Hudson等持续集成工具集成。

编辑:似乎有办法直接导出maven文件http://edocs.bea.com/wlw/docs102/guide/ideuserguide/build/conMavenScript.html。但这些文件是蚂蚁的简单包装。

5 个答案:

答案 0 :(得分:17)

我正在使用maven构建一个部署WebLogic Server 10.3的EAR。棘手的部分是:

  • 查找weblogic-maven-plugin的所有依赖项
  • 将所有依赖项放在maven repo中(我真的推荐Sonatype Nexus
  • 将noExit设置为true(否则你会在哈德森遇到问题!)

我在EAR项目中使用以下目录结构:

pom.xml
src/
   main/
        app/
            META-INF/
                     weblogic-application.xml

以下内容取自我的pom.xml:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <displayName>My Project</displayName>
                <earSourceDirectory>src/main/app</earSourceDirectory>
                <modules>
                    <webModule>
                        <groupId>com.somecompany</groupId>
                        <artifactId>webapp</artifactId>
                    </webModule>
                </modules>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>weblogic-maven-plugin</artifactId>
            <version>2.9.1</version>
            <executions>
                <execution>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy</goal>
                        <goal>start</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <name>my-project</name>
                <adminServerHostName>${wls.adminServerHostName}</adminServerHostName>
                <adminServerPort>${wls.adminServerPort}</adminServerPort>
                <adminServerProtocol>t3</adminServerProtocol>
                <userId>${wls.userId}</userId>
                <password>${wls.password}</password>
                <upload>true</upload>
                <remote>true</remote>
                <verbose>false</verbose>
                <debug>false</debug>
                <targetNames>AdminServer</targetNames>
                <noExit>true</noExit>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.5</version>
                    <scope>system</scope>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>weblogic</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>webservices</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.utils.full</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.i18n</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.rmi.client</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>javax.enterprise.deploy</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>webserviceclient</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.security.wls</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.security.identity</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.security</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>wlclient</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.transaction</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.utils.classloaders</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>wljmsclient</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.management.core</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>wls-api</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.descriptor</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.logging</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.socket.api</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.security.digest</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.workmanager</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.weblogic.lifecycle</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.utils.wrapper</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>wlsafclient</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.management.jmx</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>weblogic</groupId>
                    <artifactId>com.bea.core.descriptor.wl</artifactId>
                    <version>${weblogic.version}</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

答案 1 :(得分:9)

如果您的Weblogic 10.3位于本地方框中,请尝试使用Cargo - 设置起来要容易得多。以下是我必须添加到pom.xml的内容:

    <plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <configuration>
            <container>
                    <containerId>weblogic103x</containerId>
                    <home>/path/to/your/wlserver_10.3</home>
            </container>
    </configuration>
    </plugin>

答案 2 :(得分:3)

http://mojo.codehaus.org/weblogic-maven-plugin/是以前用于将ear项目部署到weblogic的插件但是看起来很乏味。 Oracle已经发布了weblogic的后续插件。 此插件相对更容易使用和配置http://download.oracle.com/docs/cd/E17904_01/web.1111/e13702/maven_deployer.htm

答案 3 :(得分:1)

您也可以使用Maven ANTRUN插件,如我在此博客中所示:

http://loutilities.wordpress.com/2012/06/20/use-your-maven-build-to-auto-deploy-to-weblogic-10-3/

答案 4 :(得分:0)