修改编译构建脚本
WebLogic在编译部分提供了特定的工具wlcompile,ejbgen,wlappc以使编译更方便,如无需重复配置classpath、自动生成EJB源文件等功能。
经实践,可以通过javac、jar、war等命令简单替换这个高级功能,比如wlcompile源路径和输出路径可以进行javac配置,修改可参见如下示例。
- 修改前:
<target name="build.ear" description="Compile EAR for split directory deployment."> <wlcompile srcdir="${dist}" destdir="${examples.build.dir}/${bean.ear}" includes="${ejb.name},${war.name}"> <ejbgen source="${sourceVersion}"/> <javac deprecation="${deprecation}"/> <javac debug="${debug}"/> </wlcompile> <!--"Enhance entity class"--> <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"/> <weave source="${dist}/${war.name}/WEB-INF/classes" target="${dist}/${war.name}/WEB-INF/classes"> <classpath> <path location="${examples.build.dir}/${bean.ear}/${ejb.name}"/> <pathelement path="${java.class.path}"/> </classpath> </weave> <wlappc source="${examples.build.dir}/${bean.ear}" debug="${debug}" deprecation="${deprecation}"/> </target>
- 修改后:
<target name="compile" depends="prepare"> <javac srcdir="${ejb-src}" destdir="${dist-ejb-classes}" debug="on" deprecation="on" optimize="off" includes="**"> <classpath refid="classpath" /> </javac> <javac srcdir="${web-src}" destdir="${dist-web-classes}" debug="on" deprecation="on" optimize="off" includes="**"> <classpath refid="classpath" /> </javac> </target> <target name="jar" depends="compile"> <jar jarfile="${dist}/simpleEJB.jar"> <fileset dir="${dist}/${ejb.name}"> <include name="**/*.*" /> </fileset> </jar> </target> <target name="war" depends="jar"> <war warfile="${dist}/${war.name}.war"> <fileset dir="${dist}/${war.name}"> <include name="**/*.*" /> </fileset> </war> </target> <target name="assemble-app" depends="war"> <jar jarfile="${dist}/${project.name}.ear"> <metainf dir="${dist}/META-INF"> <include name="application.xml" /> </metainf> <fileset dir="${dist}" includes="*.jar,*.war" /> </jar> </target>
父主题: WebLogic到TomEE迁移