我试图说服我的提供者使用ANT而不是Rational Application Development,这样任何人都可以随时随地重新编译,重新检查,重新部署解决方案。 :P

我为一个生成JAR文件但在那里停止的项目启动了一个build.xml,我需要真实的例子来比较注释。 我的好朋友! 我没有接近聊天的人!

到目前为止,这是我的build.xml

===============>>#1 票数:14 已采纳

我的环境:Fedora 8; WAS 6.1(与Rational Application Developer 7一起安装)

该领域的文件很差,缺乏实际的例子。

使用WebSphere Application Server(WAS)Ant任务

要按此处所述运行,您需要使用ws_ant.shws_ant.bat命令从服务器配置文件 bin目录运行它们。

<?xml version="1.0"?>
<project name="project" default="wasListApps" basedir=".">
    <description>
        Script for listing installed apps.
        Example run from:
        /opt/IBM/SDP70/runtimes/base_v61/profiles/AppSrv01/bin
    </description>

    <property name="was_home"
        value="/opt/IBM/SDP70/runtimes/base_v61/">
    </property>
    <path id="was.runtime">
        <fileset dir="${was_home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${was_home}/plugins">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <property name="was_cp" value="${toString:was.runtime}"></property>
    <property environment="env"></property>

    <target name="wasListApps">
        <taskdef name="wsListApp"
            classname="com.ibm.websphere.ant.tasks.ListApplications"
            classpath="${was_cp}">
        </taskdef>
        <wsListApp wasHome="${was_home}" />
    </target>

</project>

命令:

./ws_ant.sh -buildfile ~/IBM/rationalsdp7.0/workspace/mywebappDeploy/applist.xml

部署脚本

<?xml version="1.0"?>
<project name="project" default="default" basedir=".">
<description>
Build/Deploy an EAR to WebSphere Application Server 6.1
</description>

    <property name="was_home" value="/opt/IBM/SDP70/runtimes/base_v61/" />
    <path id="was.runtime">
        <fileset dir="${was_home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${was_home}/plugins">
            <include name="**/*.jar" />
        </fileset>
    </path>
    <property name="was_cp" value="${toString:was.runtime}" />
    <property environment="env" />
    <property name="ear" value="${env.HOME}/IBM/rationalsdp7.0/workspace/mywebappDeploy/mywebappEAR.ear" />

    <target name="default" depends="deployEar">
    </target>

    <target name="generateWar" depends="compileWarClasses">
        <jar destfile="mywebapp.war">
            <fileset dir="../mywebapp/WebContent">
            </fileset>
        </jar>
    </target>

    <target name="compileWarClasses">
        <echo message="was_cp=${was_cp}" />
        <javac srcdir="../mywebapp/src" destdir="../mywebapp/WebContent/WEB-INF/classes" classpath="${was_cp}">
        </javac>
    </target>

    <target name="generateEar" depends="generateWar">
        <mkdir dir="./earbin/META-INF"/>
        <move file="mywebapp.war" todir="./earbin" />
        <copy file="../mywebappEAR/META-INF/application.xml" todir="./earbin/META-INF" />
        <jar destfile="${ear}">
            <fileset dir="./earbin" />
        </jar>
    </target>

    <!-- http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/ant/tasks/package-summary.html -->
    <target name="deployEar" depends="generateEar">
        <taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpath="${was_cp}"/>
        <wsInstallApp ear="${ear}" 
            failonerror="true" 
            debug="true" 
            taskname=""
            washome="${was_home}" />
    </target>

</project>

笔记:

  • 你只能运行一次! 如果正在使用应用程序名称,则无法安装 - 请参阅其他任务,如wsUninstallApp
  • 它可能也不会启动应用程序
  • 您需要在服务器上运行它,脚本非常脆弱

备择方案

我可能会使用Java Management Extensions(JMX)。 您可以编写一个接受EAR的文件上载servlet,并使用部署MBean在服务器上部署EAR。 您只需通过HTTP发布文件即可。 这将避免您的开发/构建计算机上的任何WAS API依赖项,并且可以独立于任何一个项目。

===============>>#2 票数:6

如果您没有可用的WAS ant任务或者不想运行was_ant.bat,则以下是一些相同的功能。 这依赖于路径中存在的wsadmin.bat。

<property name="websphere.home.dir" value="${env.WS6_HOME}" />
<property name="was.server.name" value="server1" />
<property name="wsadmin.base.command" value="wsadmin.bat" />

<property name="ws.list.command" value="$AdminApp list" />
<property name="ws.install.command" value="$AdminApp install" />
<property name="ws.uninstall.command" value="$AdminApp uninstall" />
<property name="ws.save.command" value="$AdminConfig save" />
<property name="ws.setManager.command" value="set appManager [$AdminControl queryNames cell=${env.COMPUTERNAME}Node01Cell,node=${env.COMPUTERNAME}Node01,type=ApplicationManager,process=${was.server.name},*]" />
<property name="ws.startapp.command" value="$AdminControl invoke $appManager startApplication" />
<property name="ws.stopapp.command" value="$AdminControl invoke $appManager stopApplication" />

<property name="ws.conn.type" value="SOAP" />
<property name="ws.host.name" value="localhost" />
<property name="ws.port.name" value="8880" />
<property name="ws.user.name" value="username" />
<property name="ws.password.name" value="password" />

<property name="app.deployed.name" value="${artifact.filename}" />
<property name="app.contextroot.name" value="/${artifact.filename}" />

<target name="websphere-list-applications">
    <exec dir="${websphere.home.dir}/bin" executable="${wsadmin.base.command}" output="waslist.txt" logError="true">
        <arg line="-conntype ${ws.conn.type}" />
        <arg line="-host ${ws.host.name}" />
        <arg line="-port ${ws.port.name}" />
        <arg line="-username ${ws.user.name}" />
        <arg line="-password ${ws.password.name}" />
        <arg line="-c" />
        <arg value="${ws.list.command}" />
    </exec>
</target>

<target name="websphere-install-application" depends="websphere-uninstall-application">
    <exec executable="${websphere.home.dir}/bin/${wsadmin.base.command}" logError="true" outputproperty="websphere.install.output" failonerror="true">
        <arg line="-conntype ${ws.conn.type}" />
        <arg line="-host ${ws.host.name}" />
        <arg line="-port ${ws.port.name}" />
        <arg line="-username ${ws.user.name}" />
        <arg line="-password ${ws.password.name}" />
        <arg line="-c" />
        <arg value="${ws.install.command} ${dist.dir}/${artifact.filename}.war {-appname ${app.deployed.name} -server ${was.server.name} -contextroot ${app.contextroot.name}}" />
        <arg line="-c" />
        <arg value="${ws.save.command}" />
        <arg line="-c" />
        <arg value="${ws.setManager.command}" />
        <arg line="-c" />
        <arg value="${ws.startapp.command} ${app.deployed.name}" />
        <arg line="-c" />
        <arg value="${ws.save.command}" />
    </exec>
    <echo message="${websphere.install.output}" />
</target>

<target name="websphere-uninstall-application">
    <exec executable="${websphere.home.dir}/bin/${wsadmin.base.command}" logError="true" outputproperty="websphere.uninstall.output" failonerror="false">
        <arg line="-conntype ${ws.conn.type}" />
        <arg line="-host ${ws.host.name}" />
        <arg line="-port ${ws.port.name}" />
        <arg line="-username ${ws.user.name}" />
        <arg line="-password ${ws.password.name}" />
        <arg line="-c" />
        <arg value="${ws.setManager.command}" />
        <arg line="-c" />
        <arg value="${ws.stopapp.command} ${app.deployed.name}" />
        <arg line="-c" />
        <arg value="${ws.save.command}" />
        <arg line="-c" />
        <arg value="${ws.uninstall.command} ${app.deployed.name}" />
        <arg line="-c" />
        <arg value="${ws.save.command}" />
    </exec>
    <echo message="${websphere.uninstall.output}" />
</target>

===============>>#3 票数:4

一个好的起点,可能是这个maven插件 ,不是用它,或者可能是的,但是这个maven是建立在ant任务上的。 如果你看到WAS5 + Plugin + Mojo.zip \\ src \\ main \\ scripts \\ was5.build.xml

或者如“McDowell”所述,您可以使用“WebSphere Application Server(WAS)Ant任务”,但可以直接用作ANT任务。

<path id="classpath">
    <fileset file="com.ibm.websphere.v61_6.1.100.ws_runtime.jar"/>
</path>

<taskdef name="wsStartApp" classname="com.ibm.websphere.ant.tasks.StartApplication" classpathref="classpath" />
<taskdef name="wsStopApp" classname="com.ibm.websphere.ant.tasks.StopApplication" classpathref="classpath" />
<taskdef name="wsInstallApp" classname="com.ibm.websphere.ant.tasks.InstallApplication" classpathref="classpath" />
<taskdef name="wsUninstallApp" classname="com.ibm.websphere.ant.tasks.UninstallApplication" classpathref="classpath" />

<target name="startWebApp1" depends="installEar">
    <wsStartApp wasHome="${wasHome.dir}" 
                application="${remoteAppName}" 
                server="${clusterServerName}" 
                conntype="${remoteProdConnType}" 
                host="${remoteProdHostName}" 
                port="${remoteProdPort}" 
                user="${remoteProdUserId}" 
                password="${remoteProdPassword}" />
</target>

<target name="stopWebApp1" depends="prepare">
    <wsStopApp wasHome="${wasHome.dir}"
                application="${remoteAppName}"
                server="${clusterServerName}"
                conntype="${remoteConnType}"
                host="${remoteHostName}"
                port="${remotePort}"
                user="${remoteUserId}"
                password="${remotePassword}"/>
</target>

<target name="uninstallEar" depends="stopWebApp1">
    <wsUninstallApp wasHome="${wasHome.dir}"
                    application="${remoteAppName}"
                    options="-cell uatNetwork -cluster DOL"
                    conntype="${remoteConnType}"
                    host="${remoteHostName}"
                    port="${remoteDmgrPort}"
                    user="${remoteUserId}"
                    password="${remotePassword}"/>
</target>

<target name="installEar" depends="prepare">
    <wsInstallApp ear="${existingEar.dir}/${existingEar}" 
                  wasHome="${wasHome.dir}" 
                  options="${install_app_options}"
                  conntype="${remoteConnType}" 
                  host="${remoteHostName}" 
                  port="${remoteDmgrPort}" 
                  user="${remoteUserId}" 
                  password="${remotePassword}" />
</target>

另一个有用的链接可能是这个

===============>>#4 票数:0

如果您只是想玩,为什么不使用netbeans IDE来生成您的ear文件。 如果您创建企业项目,它将自动为您生成ant文件。 适合原型设计并刚刚入门:-)

甚至还有一个允许自动部署的插件,但这看起来非常不稳定!

  ask by ggasp translate from so

未解决问题?本站智能推荐: