You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Martin Gainty <mg...@hotmail.com> on 2011/03/07 21:26:45 UTC

changes for log4j:log4j plugin (version 1.2.15)

Folks:

I had to refactor log4j-plugin pom.xml to work with the new refactored /src/ntdll/build.xml to compile and produce a viable artifact
Would appreciate a ping from the author to coordinate these changes to 1.2.16 or 1.2.17 distro
target mods for /src/ntdll/build.xml: 
mc
windres
javah

src/ntdll/build.xml looks like:
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<project name="ntdll" default="build" basedir=".">
  <property name="m2.antlib.resource" value="antlib.xml" />
  <property name="m2.antlib.uri" value="antlib:org.apache.maven.artifact.ant" />

   <property name="target.dir" value="target"/>
   <property name="object.dir" value="target/obj"/>
   <property name="src.dir" location="${basedir}"/>
   <property name="failonerror" value="false"/>
   <property name="failifexecutionfails" value="${failonerror}"/>
   <property name="jni.include.dir" location="${java.home}/../include"/>
   <property environment="env"/>
   <condition property="jni.win32.include.dir" value="${jni.include.dir}/win32">
    <available file="${jni.include.dir}/win32"/>
   </condition>
   <property name="jni.win32.include.dir" value="${env.JNI_WIN32_INCLUDE_DIR}"/>
   <available property="jni_md.h_available" file="${jni.win32.include.dir}/jni_md.h"/>
  
   <target name="clean" description="Deletes generated files">
        <delete dir="${target.dir}"/>
   </target>

   <path id="classes.dir">
      <pathelement location="./target/classes"/>
   </path>

    <!--
        Regenerates resource files from EventLogCategories.mc.  Avoids
        need for Microsoft Platform SDK unless you are modifying EventLogCategories.mc
    -->
    <target name="mc" description="Update EventLogCategories.rc from .mc">
        <exec executable="mc">
            <arg value="-h"/>
            <arg file="${basedir}"/>
            <arg value="-r"/>
            <arg file="${basedir}"/>
            <arg file="EventLogCategories.mc"/>
        </exec>
    </target>

   <target name="windres" description="Compiles resources">
       <condition property="mingw-prefix" value="">
          <os family="windows"/>
       </condition>
       <property name="mingw-prefix" value="i586-mingw32msvc-"/>
        <mkdir dir="/target/obj"/>
     <exec executable="$CYGWIN/bin/windres.exe">
            <arg value="--output-format=RC"/>
            <arg value="--input=NTEventLogAppender.rc"/>
            <arg value="--output=./target/obj/NTEventLogAppender.o"/>
       
           <!-- dir="C:/Maven-plugin/Log4j/src" -->
       <!-- resultproperty="windres_status" -->
      <!-- failonerror="true" -->
      <!-- failifexecutionfails="true" -->
              <!-- arg value="-o" file="./target/obj/NTEventLogAppender.o"/  -->              
        </exec>
        <condition property="windres_success">
         <equals arg1="${windres_status}" arg2="0"/>
        </condition>
        <condition property="do_compile">
        <and>
                <isset property="windres_success"/>
                <isset property="jni_md.h_available"/>
            </and>
        </condition>
   </target>

   <typedef name="javah" classname="org.apache.tools.ant.taskdefs.optional.javah.SunJavah"/> 
   <target name="compile" depends="windres" if="do_compile">
    <fail unless="classes.dir">-Dclasses.dir=/path/to/log4j/classes must be specified</fail>
     <exec executable="$JDK_HOME/bin/Javah.exe">
            <arg value="-d=${object.dir}"/>
            <arg value="-classpath=${classes.dir}"/>
               <arg value="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"/>
         </exec>
    <!-- javah class="org.apache.log4j.nt.NTEventLogAppender,org.apache.log4j.Priority"
           destdir="${object.dir}"
           classpath="${classes.dir}"/ -->
    <echo>-Wall Turns on all optional warnings which are desirable for normal code </echo>
    <echo>-D JNI_IMPLEMENTATION_ Predefine name as a macro, with definition 1.</echo>
    <echo>-I identifies the INCLUDE folders</echo>
    <echo>-o OutputFile</echo>
    <exec executable="$CYGWIN_HOME/bin/gcc.exe">
      <arg value="-Wall"/>
      <arg value="-D JNI_IMPLEMENTATION_"/>
      <arg value="-I${jni.win32.include.dir}"/>
      <arg value="-I${jni.include.dir}"/>
      <arg value="-I${object.dir}"/>
      <!-- arg value="-shared"/ -->
      <arg file="${src.dir}/nteventlog.cpp"/>
      <arg file="${object.dir}/NTEventLogAppender.o"/>
      <arg value="-o"/>
      <arg file="${target.dir}/NTEventLogAppender.dll"/>
    </exec>
   </target>

   <target name="windres-echo" depends="windres" unless="windres_success">
    <echo>${mingw-prefix}windres could not be found or failed, NTEventLogAppender.dll build skipped.</echo>
   </target>

   <target name="jni_md.h-echo" unless="jni_md.h_available">
    <echo>${jni.win32.include.dir}/jni_md.h not found, NTEventLogAppender.dll build skipped.</echo>
   </target>

   <target name="build" depends="compile, windres-echo, jni_md.h-echo">
   </target>

</project>

change $CYGWIN_HOME to base folder of gcc,mc and windres binaries so these resolved
$CYGWIN_HOME/bin/mc.exe
$CYGWIN_HOME/bin/gcc.exe
$CYGWIN_HOME/bin/windres.exe

the refactored maven-antrun-plugin in pom.xml looks like:
  <properties>
    <currentVersion>1.2.15</currentVersion>
    <log4j.classes>./target/classes</log4j.classes>
  </properties>  

<build>
  <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
              <target>
                <property name="compile_classpath" refid="maven.compile.classpath"/>
                <property name="classpath" refid="maven.compile.classpath"/>
                <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                <property name="test_classpath" refid="maven.test.classpath"/>
                <property name="plugin_classpath" refid="maven.plugin.classpath"/>
                <property name="classes.dir" value="./target/classes"/>
        <property name="do_compile" value="true"/>
                      <ant antfile="./src/ntdll/build.xml">
                 </ant>
               </target>
             </configuration>
             <goals>
                    <goal>run</goal>
             </goals>
           </execution>
         </executions>  
       </plugin>          
.................
   </plugins>


thanks,
Martin Gainty 
______________________________________________ 
Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Ez az
üzenet bizalmas.  Ha nem ön az akinek szánva volt, akkor kérjük, hogy
jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának
készítése nem megengedett.  Ez az üzenet csak ismeret cserét szolgál és
semmiféle jogi alkalmazhatósága sincs.  Mivel az electronikus üzenetek
könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet
ezen üzenet tartalma miatt.

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.