From fa8b7740ab74fa5f2104b0f44cc35a960cafb76d Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Tue, 18 Mar 2008 17:22:25 +0000
Subject: [PATCH] * Fix for Issue 218 : Monitor Information Available via SNMP * Update the nbproject to include the snmp source code

---
 opends/build.xml |  227 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 198 insertions(+), 29 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index 826ce66..f4494f0 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -33,6 +33,9 @@
 
   <!-- Build JVM properties -->
   <property name="MEM" value="256M"/>
+  
+  <!-- Build OpenDMK properties -->
+  <property file="build.properties"/>
 
   <!-- General server-wide properties                                 -->
   <property name="src.dir"          location="src/server"              />
@@ -142,23 +145,32 @@
   <property name="msg.package.dir" location="${classes.dir}/messages" />
   <property name="msg.src.dir"     location="src/messages/src" />
 
-
+  <!-- Properties for SNMP extension. -->
+  <property name="snmp.mib.dir"      location="src/snmp/resource/mib" />
+  <property name="snmp.security.dir" location="src/snmp/resource/security" />
+  <property name="snmp.config.dir"   location="src/snmp/resource/config" />
+  <property name="snmp.gen.dir"      location="src/snmp/generated" />
+  <property name="snmp.src.dir"      location="src/snmp/src" />
+  
+  <property name="snmp.classes.dir"  
+            location="${classes.dir}/org/opends/server/snmp" />
+  
   <!-- Create a package bundle containing the DSML library. -->
   <target name="dsml" depends="predsml,package"
        description="Build a Directory Server package bundle with DSML.">
   </target>
-
-
-
-
+ 
+ 
+  
+  
   <!-- The build target that should be used before committing code. -->
   <target name="precommit" depends="checkstyle,clean,checkprecommit,dsml,testwithcoverage"
        description="Perform all processing needed before committing code.">
   </target>
 
 
-
-
+  
+  
   <!-- The build target that should be used for nightly builds. -->
   <target name="nightly"
        depends="checkstyle,dsml,srczip,javadoc,docgen,coverage,testallwithcoverage"
@@ -174,8 +186,8 @@
   </target>
 
 
-
-
+  
+  
   <!-- The build target that should be used to build everything. -->
   <target name="all"
        depends="checkstyle,clean,checkprecommit,dsml,srczip,javadoc,docgen,testallwithcoverage"
@@ -261,7 +273,7 @@
 
 
   <!-- Remove all dynamically-generated build files. -->
-  <target name="clean" depends="cleanadmin,cleanmessages"
+  <target name="clean" depends="cleanadmin,cleanmessages,cleansnmp"
        description="Clean up any files generated during the build process">
 
     <delete dir="${build.dir}" />
@@ -320,7 +332,7 @@
     <path id="quickSetup.classpath">
        <pathelement location="${quicksetup.classes.dir}" />
     </path>
-
+    
     <tstamp>
       <format property="timestamp" pattern="yyyyMMddHHmmss'Z'"
            timezone="UTC" />
@@ -356,6 +368,20 @@
         <isset property="JVM_VENDOR" />
       </not>
     </condition>
+    
+    <condition property="isopendmkpresent">
+     <or>
+     <and>
+       <available file="${opendmk.lib.dir}/jdmkrt.jar"/>
+       <available file="${opendmk.lib.dir}/jdmktk.jar"/>
+     </and>
+     <and>
+       <available file="${ext.dir}/jdmkrt.jar"/>
+       <available file="${ext.dir}/jdmktk.jar"/>
+     </and>
+     </or>
+    </condition>
+    
   </target>
 
 
@@ -689,7 +715,7 @@
         </fileset>
       </classpath>
     </javac>
-
+ 
     <copy todir="${classes.dir}">
       <fileset dir="${src.dir}" includes="**/*.properties" />
       <fileset dir="${quicksetup.src.dir}" includes="**/*.properties, **/*.gif, **/*.png" />
@@ -822,6 +848,7 @@
     <mkdir dir="${pdir}/config/schema"                               />
     <mkdir dir="${pdir}/config/messages"                             />
     <mkdir dir="${pdir}/config/MakeLDIF"                             />
+    <mkdir dir="${pdir}/config/snmp/security"                        />
     <mkdir dir="${pdir}/db"                                          />
     <mkdir dir="${pdir}/import-tmp"                                  />
     <mkdir dir="${pdir}/changelogDb"                                 />
@@ -854,11 +881,11 @@
     <!-- copy the message descriptor registry file -->
     <copy todir="${classes.dir}/org/opends/messages"
           file="${msg.javagen.dir}/org/opends/messages/descriptors.reg" />
-
+    
     <jar jarfile="${pdir}/lib/${SHORT_NAME}.jar"
          basedir="${classes.dir}"
-         excludes="${ads.classes.dir}, ${quicksetup.globalcompile.classes.dir}"
-         compress="true" index="true" />
+         excludes="${ads.classes.dir}, ${quicksetup.globalcompile.classes.dir},
+         org/opends/server/snmp/**" compress="true" index="true" />
 
     <jar jarfile="${pdir}/lib/quicksetup.jar"
          basedir="${quicksetup.classes.dir}" compress="true" index="true" />
@@ -866,13 +893,11 @@
     <copy todir="${pdir}/lib">
       <fileset file="${lib.dir}/*.jar" />
     </copy>
-
+    
     <copy todir="${pdir}/lib">
       <fileset file="${lib.dir}/*.exe" />
     </copy>
-
-    <antcall target="example-plugin" />
-
+    
     <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" excludes="*.bat,_client-script.sh,_server-script.sh,_mixed-script.sh,_script-util.sh" eol="lf" />
     <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/lib" includes="_client-script.sh,_server-script.sh,_mixed-script.sh,_script-util.sh" eol="lf" />
     <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" includes="README_WINDOWS.txt" eol="crlf" />
@@ -882,7 +907,9 @@
     <copy todir="${pdir}/config">
       <fileset file="${config.dir}/*" />
     </copy>
-
+    
+    <antcall target="package-snmp" />
+    
     <copy file="${pdir}/config/config.ldif"
          tofile="${pdir}/config/upgrade/config.ldif.${REVISION_NUMBER}" />
 
@@ -1320,7 +1347,7 @@
   </target>
 
 
-
+  
   <!-- Prepare to execute the Directory Server TestNG unit tests. --> 
   <target name="test.OpenDS.package.required" depends="dynamicconstants">
     <condition property="test.OpenDS.package.required">
@@ -1380,7 +1407,7 @@
     <javac srcdir="${unittest.testng.src.dir}" destdir="${unittest.classes.dir}"
            debug="on" debuglevel="${build.debuglevel}" source="1.5"
            target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
-           memoryMaximumSize="${MEM}">
+           memoryMaximumSize="${MEM}" excludes="org/opends/server/snmp/**">
       <compilerarg value="-Xlint:all" />
 
       <classpath>
@@ -1402,6 +1429,9 @@
                includes="**/*.properties" />
     </copy>
 
+    <!-- Compile SNMP Tests if needed -->
+    <antcall target="testsnmpinit"/>
+    
     <!-- Prep the TestNG XML file -->
 
     <condition property="test.groups" value="exclude=slow">
@@ -1871,6 +1901,11 @@
         <fileset dir="${testng.lib.dir}">
           <include name="*.jar" />
         </fileset>
+        
+        <fileset dir="${opendmk.lib.dir}">
+          <include name="*.jar"/>
+        </fileset>
+        
       </classpath>
       <jvmarg  value="-Demma.coverage.out.file=${coverage.data.dir}/unit.emma" />
       <jvmarg value="-Demma.coverage.out.merge=false" />
@@ -1970,8 +2005,8 @@
   </target>
 
 
-
-
+  
+  
   <target name="buildtools" depends="init"
         description="Builds the build tools">
 
@@ -2044,8 +2079,8 @@
     </exec>
   </target>
 
-
-
+  
+  
   <target name="compileadminsubtask">
     <!-- Generate introspection API for core administration components. -->
     <xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/*Configuration.xml" style="${admin.rules.dir}/metaMO.xsl">
@@ -2098,7 +2133,7 @@
       <regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
       <param name="base-dir" expression="${admin.defn.dir}" />
     </xslt>
-
+    
     <!-- Generate manifest file for core administration components. -->
     <tempfile property="admin.temp.dir" destDir="${build.dir}" prefix="tmp" />
     <mkdir dir="${admin.temp.dir}" />
@@ -2152,8 +2187,8 @@
     </zip>
   </target>
 
-
-
+  
+  
   <!-- Generate example plugin package. -->
   <target name="example-plugin" if="pdir">
     <!-- Create folder hierarchy in temporary directory. -->
@@ -2187,4 +2222,138 @@
     </zip>
     <delete dir="${plugin.temp.dir}" />
   </target>
+  
+  <target name="snmpmessagebuild" if="isopendmkpresent">
+      <echo message="SNMP extension will be built and included in the delivery."/>
+      <echo message="OpenDMK jar file location is ${opendmk.lib.dir}/jdmkrt.jar"/>
+  </target>
+  
+  <target name="snmpmessageNotbuild" unless="isopendmkpresent">
+      <echo message="SNMP extension will NOT be built/included in the delivery."/>
+      <echo message="You have to set the opendmk.lib.dir property in"/>
+      <echo message="${basedir}/build.properties file to indicate"/>
+      <echo message="the location of the OpenDMK jar files."/>
+      <echo message="To get the OpenDMK jar files please, go under"/>
+      <echo message="https://opendmk.dev.java.net/"/>
+  </target>
+  
+  <target name="snmpecho" depends="snmpmessageNotbuild,snmpmessagebuild"/>
+  
+  <!-- SNMP targets -->
+  <target name="cleansnmp" description="Clean up any SNMP generated source files">
+    <delete includeemptydirs="true" failonerror="false">
+      <fileset dir="${snmp.gen.dir}" includes="**/*" />
+    </delete>
+  </target>
+  
+  <target name="mibgeneration" if="isopendmkpresent" description="mibgen invocation">
+    <property name="opendmktk.path" location="${opendmk.lib.dir}/jdmktk.jar"/>
+    <mkdir dir="${snmp.gen.dir}/org/opends/server/snmp" />
+    <exec dir="${snmp.mib.dir}" executable="java">
+      <arg line="-classpath ${opendmktk.path}
+        com.sun.jdmk.tools.MibGen -X:use-display-hint 
+        -d ${snmp.gen.dir}/org/opends/server/snmp -mc -desc 
+        -tp org.opends.server.snmp ${snmp.mib.dir}/rfc2605.txt 
+        ${snmp.mib.dir}/mib_core.txt
+        ${snmp.mib.dir}/rfc2021.txt ${snmp.mib.dir}/rfc2788.txt"/>
+    </exec>
+  </target>
+  
+   <target name="compilesnmp"
+       depends="init,checkjavaversion,dynamicconstants,generatemessages,compileadmin,mibgeneration"
+       if="isopendmkpresent"
+       description="Compile the SNMP Connection Handler extension source files.">
+         
+    <mkdir dir="${classes.dir}" />
+
+    <javac srcdir="${snmp.gen.dir}"
+         destdir="${classes.dir}" debug="on" debuglevel="${build.debuglevel}"
+         source="1.4" target="1.4" deprecation="true" fork="true" nowarn="on"
+         memoryInitialSize="${MEM}" memoryMaximumSize="${MEM}">
+      <compilerarg value="-Xlint:all" />
+      
+      <classpath>
+        <fileset dir="${lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+        <fileset dir="${opendmk.lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+      </classpath>
+    </javac>
+    
+     <javac srcdir="${snmp.src.dir}"
+         destdir="${classes.dir}" debug="on" debuglevel="${build.debuglevel}"
+         source="1.5" target="1.5" deprecation="true" fork="true"
+         memoryInitialSize="${MEM}" memoryMaximumSize="${MEM}">
+      <compilerarg value="-Xlint:all" />
+
+      <classpath>
+        <fileset dir="${lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+        <fileset dir="${opendmk.lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+      </classpath>
+    </javac>
+  </target>
+
+    
+  <!-- Package the SNMP Directory Server extension for distribution. -->
+  <target name="package-snmp" if="isopendmkpresent" depends="snmpecho,compilesnmp" 
+          description="Package the SNMP Directory Server extension for distribution.">
+    <property name="pdir" location="${package.dir}/${SHORT_NAME}-${VERSION_NUMBER_STRING}"/>
+    <mkdir dir="${pdir}/lib/extensions" />
+    <mkdir dir="${pdir}/snmp/mib"/>
+    <mkdir dir="${pdir}/config/snmp/security" />
+    <!-- Copy security template files -->
+    <copy todir="${pdir}/config/snmp/security">
+      <fileset dir="${snmp.security.dir}"/>
+    </copy>
+    <!-- Copy the mib -->
+    <copy todir="${pdir}/snmp/mib" file="${snmp.mib.dir}/rfc2605.txt"/>
+    
+    <!-- Update the config.ldif file with snmp config -->
+    <concat destfile="${pdir}/config/config.ldif" append="true">
+        <filelist dir="${snmp.config.dir}" files="config.snmp.ldif"/>
+    </concat>
+    
+    <!-- Create the jar file -->
+    <jar jarfile="${pdir}/lib/extensions/snmp-mib2605.jar"
+         basedir="${classes.dir}"
+         includes="org/opends/server/snmp/**"
+         compress="true" index="true" />
+    <echo message="SNMP Extension is built"/>
+    <echo message="${pdir}/lib/extensions/snmp-mib2605.jar"/>
+  </target>
+  
+  <target name="testsnmpinit" if="isopendmkpresent">
+    <!-- Compile the SNMP test cases -->
+    <mkdir dir="${unittest.classes.dir}" />
+    <javac srcdir="${unittest.testng.src.dir}" destdir="${unittest.classes.dir}"
+           debug="on" debuglevel="${build.debuglevel}" source="1.5"
+           target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
+           memoryMaximumSize="${MEM}" includes="org/opends/server/snmp/**">
+      <compilerarg value="-Xlint:all" />
+
+      <classpath>
+        <fileset dir="${lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+
+        <fileset dir="${testng.lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+        
+        <fileset dir="${opendmk.lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+
+        <path refid="run.classpath" />
+        <path refid="quickSetup.classpath" />
+      </classpath>
+    </javac>
+  </target>
+    
 </project>

--
Gitblit v1.10.0