Skip to content

Instantly share code, notes, and snippets.

@kares
Created April 5, 2010 16:51
Show Gist options
  • Save kares/356576 to your computer and use it in GitHub Desktop.
Save kares/356576 to your computer and use it in GitHub Desktop.
WebLogic MBean Maker - Maven Build Example
<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/xsd/maven-4.0.0.xsd">
<!--
Oracle WebLogic MBean Maker Maven Sample Build
- {weblogic.home} should point to the server installation
- {bea.modules} is expected to hold the weblogic "shared" jars
- sources are expected to live under 'src' folder
- the src folder is expected to contain the SampleAsserter.xml
(change it based on Your needs - should be the mbean XML)
- the sample is working under WL 10.3.2 for other versions
You might need to adjust the WL "modules" jar versions !
-->
<modelVersion>4.0.0</modelVersion>
<groupId>org.kares.weblogic</groupId>
<artifactId>sample_asserter</artifactId>
<version>1.0-SNAPSHOT</version>
<name>sample_asserter</name>
<dependencies>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>10.3.2</version>
<scope>system</scope>
<systemPath>${weblogic.home}/server/lib/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.i18n</artifactId>
<version>${com.bea.core.i18n.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.i18n_${com.bea.core.i18n.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.weblogic.security</artifactId>
<version>${com.bea.core.weblogic.security.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.weblogic.security_${com.bea.core.weblogic.security.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.beaninfo</artifactId>
<version>${com.bea.core.beaninfo.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.beaninfo_${com.bea.core.beaninfo.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.utils.full</artifactId>
<version>${com.bea.core.utils.full.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.utils.full_${com.bea.core.utils.full.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.utils.classloaders</artifactId>
<version>${com.bea.core.utils.classloaders.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.utils.classloaders_${com.bea.core.utils.classloaders.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.descriptor</artifactId>
<version>${com.bea.core.descriptor.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.descriptor_${com.bea.core.descriptor.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.common.security.api</artifactId>
<version>${com.bea.core.common.security.api.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.common.security.api_${com.bea.core.common.security.api.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.weblogic.security.identity</artifactId>
<version>${com.bea.core.weblogic.security.identity.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.weblogic.security.identity_${com.bea.core.weblogic.security.identity.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.mbean.maker</artifactId>
<version>${com.bea.core.mbean.maker.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.mbean.maker_${com.bea.core.mbean.maker.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.management.core</artifactId>
<version>${com.bea.core.management.core.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.management.core_${com.bea.core.management.core.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.logging</artifactId>
<version>${com.bea.core.logging.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.logging_${com.bea.core.logging.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>com.bea.core.weblogic.workmanager</artifactId>
<version>${com.bea.core.weblogic.workmanager.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.weblogic.workmanager_${com.bea.core.weblogic.workmanager.version}.jar</systemPath>
</dependency>
<dependency>
<!--
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.0</version>-->
<groupId>weblogic</groupId>
<artifactId>com.bea.core.apache.commons.collections</artifactId>
<version>${com.bea.core.apache.commons.collections.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.apache.commons.collections_${com.bea.core.apache.commons.collections.version}.jar</systemPath>
</dependency>
<dependency>
<!--
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.3.0</version>-->
<groupId>weblogic</groupId>
<artifactId>com.bea.core.apache.commons.pool</artifactId>
<version>${com.bea.core.apache.commons.pool.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.apache.commons.pool_${com.bea.core.apache.commons.pool.version}.jar</systemPath>
</dependency>
<dependency>
<!--
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.13</version>-->
<groupId>weblogic</groupId>
<artifactId>com.bea.core.apache.log4j</artifactId>
<version>${com.bea.core.apache.log4j.version}</version>
<scope>system</scope>
<systemPath>${bea.modules}/com.bea.core.apache.log4j_${com.bea.core.apache.log4j.version}.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
<properties>
<weblogic.home>${env.BEA_HOME}/wlserver_10.3</weblogic.home>
<bea.modules>${env.BEA_HOME}/modules</bea.modules>
<com.bea.core.i18n.version>1.6.0.0</com.bea.core.i18n.version>
<com.bea.core.weblogic.security.version>1.0.0.0_5-2-0-0</com.bea.core.weblogic.security.version>
<com.bea.core.beaninfo.version>2.4.0.0</com.bea.core.beaninfo.version>
<com.bea.core.utils.full.version>1.7.0.0</com.bea.core.utils.full.version>
<com.bea.core.utils.classloaders.version>1.6.0.0</com.bea.core.utils.classloaders.version>
<com.bea.core.descriptor.version>1.7.0.0</com.bea.core.descriptor.version>
<com.bea.core.common.security.api.version>1.0.0.0_5-2-0-0</com.bea.core.common.security.api.version>
<com.bea.core.weblogic.security.identity.version>1.1.2.0</com.bea.core.weblogic.security.identity.version>
<com.bea.core.mbean.maker.version>1.4.0.0</com.bea.core.mbean.maker.version>
<com.bea.core.management.core.version>2.5.0.0</com.bea.core.management.core.version>
<com.bea.core.logging.version>1.6.0.0</com.bea.core.logging.version>
<com.bea.core.weblogic.workmanager.version>1.7.0.0</com.bea.core.weblogic.workmanager.version>
<com.bea.core.apache.commons.collections.version>3.2.0</com.bea.core.apache.commons.collections.version>
<com.bea.core.apache.commons.pool.version>1.3.0</com.bea.core.apache.commons.pool.version>
<com.bea.core.apache.log4j.version>1.2.13</com.bea.core.apache.log4j.version>
<mbean.generated.source.dir>${project.build.directory}/mbean-gen</mbean.generated.source.dir>
<!--<weblogic.mbeans.dir>${env.DOMAIN_HOME}/weblogic/mbeans</weblogic.mbeans.dir>-->
</properties>
<build>
<finalName>SampleAsserter</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
<includes>
<include>SampleAsserter.xml</include>
<!--
<include>SampleAsserter.properties</include>-->
</includes>
</resource>
<resource>
<directory>${mbean.generated.source.dir}</directory>
<includes>
<include>META-INF/MANIFEST.MF</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>run-mbean-maker</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<property name="src_dir" value="${project.build.sourceDirectory}"/>
<property name="mbean_gen_dir" value="${mbean.generated.source.dir}"/>
<property name="mbean_out_dir" value="${project.build.directory}/mbean-out"/>
<property name="mjf_jar" value="${build.directory}/${build.finalName}.jar"/>
<property name="mdf_xml" value="MSFIdentityAsserter.xml"/>
<!-- ensure that WebLogicMBeanMaker starts from a clean slate -->
<delete dir="${mbean_gen_dir}"/> <mkdir dir="${mbean_gen_dir}"/>
<delete dir="${mbean_out_dir}"/> <mkdir dir="${mbean_out_dir}"/>
<!-- copy **.xml to the generated source directory or it won't work -->
<copy todir="${mbean_gen_dir}" flatten="true">
<fileset dir="${src_dir}">
<include name="**/*.xml"/> <!-- the asserter .xml -->
</fileset>
</copy>
<!-- the MBeanMaker expects commo.dtd in the same dir as the XML : -->
<copy todir="${mbean_gen_dir}" file="${weblogic.home}/server/lib/commo.dtd"/>
<path id="mbeanmaker.path">
<pathelement path="${mbean_gen_dir}"/>
<path refid="maven.compile.classpath"/>
</path>
<!-- Build the MDFs (mbean definition files) for the authenticator : -->
<java classname="weblogic.management.commo.WebLogicMBeanMaker"
classpathref="mbeanmaker.path" fork="false" failonerror="true">
<arg line="-MDF ${mbean_gen_dir}/${mdf_xml}"/>
<arg line="-files ${mbean_gen_dir} -createStubs -verbose"/>
</java>
<!-- Copy all sources and MDF generated files to one dir for MJF : -->
<copy todir="${mbean_out_dir}">
<fileset dir="${src_dir}" includes="**/*.java"/>
<fileset dir="${mbean_gen_dir}"/>
</copy>
<!-- Build the MJF (mbean jar file) for the authenticator, also
generates a set of XML binding classes and a schema : -->
<java classname="weblogic.management.commo.WebLogicMBeanMaker"
classpathref="mbeanmaker.path" fork="true" failonerror="true">
<arg line="-MJF ${mjf_jar} -files ${mbean_out_dir} -g -verbose"/>
</java>
<!-- NOTE: the "only" way to make maven compiler happy (the MBeanMaker
already compiled the generated sources) : -->
<!-- WebLogic needs the MANIFEST.MF generated to validate java types
but the MANIFEST file is only present in the jar build by MJF :
-->
<unjar src="${mjf_jar}" dest="${mbean_gen_dir}">
<patternset>
<include name="META-INF/MANIFEST.MF"/>
</patternset>
</unjar>
<copy todir="${project.build.outputDirectory}" includeEmptyDirs="false">
<fileset dir="${mbean_out_dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</tasks>
</configuration>
</execution>
<!-- copy task that copies artifact to mbeans dir : -->
<!-- to skip copying ... mvn install -Dskip.mbeans.copy=true -->
<!--
<execution>
<id>copy-mbean-jar</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks unless="skip.mbeans.copy">
<echo message="copying ${build.finalName}.jar to ${weblogic.mbeans.dir}"/>
<copy file="${build.directory}/${build.finalName}.jar" todir="${weblogic.mbeans.dir}"/>
</tasks>
</configuration>
</execution>-->
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<!-- <id>add-source</id> -->
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${mbean.generated.source.dir}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment