Skip to content

Split source JS into multiple files, root ant build update #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/nbproject/private/
node_modules/
release/
build/
log4js/target/
log4js/node_modules/
log4js-servlet/target/
log4js-servlet/lib/
log4js-site/build/
261 changes: 129 additions & 132 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
====================================================================== -->
<project name="Log4js" default="dist" basedir=".">
<description>
ANT build file for Log4js, the logging library for JavaScript which is
ANT build file for Log4js, the logging library for JavaScript which is
using almost same API than log4j.
</description>
<!-- The build.properties file defines the parth to local jar files -->
Expand All @@ -34,7 +34,9 @@

<property name="version" value="${version}" />

<property name="src.dir" value="log4js/src/main" />
<property name="src.base" value="log4js" />
<property name="src.target" value="${src.base}/target" />
<property name="src.dir" value="${src.base}/src/main" />
<property name="src.js.dir" value="${src.dir}/js" />

<property name="lib.dir" value="lib" />
Expand All @@ -47,24 +49,26 @@
<!-- build properties -->
<property name="dist.dir" value="build" />
<property name="dist.docs.dir" value="${dist.dir}/docs" />
<property name="dist.reports.dir" value="${dist.dir}/reports" />
<property name="dist.reports.dir" value="${dist.dir}/reports" />

<property name="apidoc.dir" value="${dist.dir}/docs/api" />

<!-- example properties -->
<property name="example.src.dir" value="log4js-examples/src/main/examples" />
<property name="example.webapp.dir" value="${dist.dir}/webapp" />
<property name="example.war.name" value="log4js-example-${version}.war" />
<property name="log4j.jar" value="${lib.dir}/log4j-${tools.log4j.version}.jar" />
<property name="log4j.jar" value="${lib.dir}/log4j-${tools.log4j.version}.jar" />

<property name="servlet-api.jar" value="${lib.dir}/servlet-api-${tools.servlet-api.version}.jar" />

<!-- unit tests -->
<property name="src.test.dir" value="log4js/src/test" />
<property name="src.test.dir" value="{src.base}/src/test" />
<property name="src.test.java.dir" value="${src.test.dir}/java" />
<property name="src.test.js.dir" value="${src.test.dir}/js" />
<property name="src.test.js.dir" value="${src.test.dir}/js" />
<property name="classes.java.dir" value="${dist.dir}/classes" />
<property name="classes.test.java.dir" value="${dist.dir}/test/classes" />
<property name="war.dir" value="${dist.dir}/war" />
<property name="classes.test.java.dir" value="${dist.dir}/test/classes" />

<property name="war.dir" value="${dist.dir}/war" />

<!-- FORREST_HOME must be set as an environment variable -->
<property name="forrest.home" value="${env.FORREST_HOME}" />
Expand All @@ -73,7 +77,80 @@

<!-- release properties -->
<property name="release.dir" value="release" />


<!-- OS specific properties -->
<condition property="isWin">
<os family="windows" />
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<condition property="isMac">
<os family="mac" />
</condition>

<!-- OS specific tasks -->
<target name="-compile-win" if="isWin">
<exec executable="cmd" failonerror="true" dir="${src.base}">
<arg line="/c" />
<arg line="grunt" />
<arg line="concat uglify" />
</exec>
</target>
<target name="-compile-unix" if="isUnix">
<exec executable="grunt" failonerror="true" dir="${src.base}">
<arg line="concat uglify" />
</exec>
</target>
<target name="-compile-mac" if="isMac">
<fail message="Sorry, MAC is not supported." />
</target>


<target name="-doc.api-win" if="isWin">
<exec executable="cmd">
<arg line="/c" />
<arg line="grunt" />
<arg line="jsdoc" />
</exec>
</target>
<target name="-doc.api-unix" if="isUnix">
<exec executable="grunt" failonerror="true" dir="${src.base}">
<arg line="jsdoc" />
</exec>
</target>
<target name="-doc.api-mac" if="isMac">
<fail message="Sorry, MAC is not supported." />
</target>

<target name="-jshint-win" if="isWin">
<exec executable="cmd" failonerror="false" dir="${src.base}">
<arg line="/c" />
<arg line="grunt" />
<arg line="jshint" />
</exec>
</target>
<target name="-jshint-unix" if="isUnix">
<exec executable="grunt" failonerror="true" dir="${src.base}">
<arg line="jshint" />
</exec>
</target>
<target name="-jshint-mac" if="isMac">
<fail message="Sorry, MAC is not supported." />
</target>

<target name="-site-win" if="isWin">
<exec executable="cmd" failonerror="false" dir="${src.base}">
<arg line="/c" />
<arg line="${env.FORREST_HOME}/bin/forrest.bat" />
</exec>
</target>
<target name="-site-unix" if="isUnix">
<exec executable="${env.FORREST_HOME}/bin/forrest" dir="log4js-site" />
</target>
<target name="-site-mac" if="isMac">
<fail message="Sorry, MAC is not supported." />
</target>

<!-- =================================
target: release
Expand Down Expand Up @@ -122,7 +199,8 @@
<!-- =================================
target: distribute
================================= -->
<target name="dist" depends="dist.api, dist.doc, dist.example" description="--> generate complete distribution">
<!-- TODO: return dist.example -->
<target name="dist" depends="dist.api, dist.doc" description="--> generate complete distribution">

</target>

Expand Down Expand Up @@ -175,40 +253,31 @@
<!-- - - - - - - - - - - - - - - - - -
target: compile
- - - - - - - - - - - - - - - - - -->
<target name="compile" depends="init, jslint">
<mkdir dir="${dist.dir}/lib" />
<exec executable="perl" output="${dist.dir}/lib/log4js-lib.js" failonerror="false">
<arg line="-Tw ${tools.dir}/jsjam.pl --quiet --keep-globals --keep-identifiers ${src.js.dir}/log4js.js" />
</exec>
<target name="compile" depends="init, -compile-win, -compile-unix, -compile-mac">
<copy tofile="${dist.dir}/lib/log4js-lib.js" file="${src.target}/log4js.min.js" overwrite="true" />
</target>

<!-- =================================
target: doc.api
================================= -->
<target name="doc.api" description="generate the API doc" depends="init">
<property name="apidoc.dir" value="${dist.dir}/docs/api" />

<echo level="info">Gererate JSDoc to directory ${apidoc.dir}...</echo>
<mkdir dir="${apidoc.dir}" />

<property name="footer" value="Log4js - Logging API for JavaScript" />
<property name="logo" value="${basedir}/log4js-site/logo/1.0/exports/1.0_70px.jpg" />

<exec executable="perl">
<arg line="${tools.dir}/JSDoc/JSDoc-${tools.jsdoc.version}/jsdoc.pl -r &quot;${src.dir}/js&quot; -d &quot;${apidoc.dir}&quot; -project-name &quot;${ant.project.name} ${version}&quot; -page-footer &quot;${footer}&quot; -logo &quot;${logo}&quot;" />
</exec>
<target name="doc.api" description="generate the API doc" depends="init,-doc.api-win,-doc.api-unix,-doc.api-mac">
<copy todir="${apidoc.dir}">
<fileset dir="log4js/target/docs/"></fileset>
</copy>
</target>


<!-- =================================
target: jslint
================================= -->
<target name="jslint" depends="init" description="--> verify syntax of JavaScripts">
<exec executable="${basedir}/${tools.dir}/jsl/jsl-${tools.jsl.version}/jsl.exe" resultproperty="${jslint.result}">
<arg line="conf ${tools.dir}/jsl/jsl.conf process ${src.js.dir}/*.js" />
</exec>

<echo message="${jslint.result}" />
<target name="jslint" depends="jshint" description="--> (Depricated) verify syntax of JavaScripts">
<echo>Warning!!! This task is renamed into jshint for new library is used</echo>
</target>

<!-- =================================
target: jshint
================================= -->
<target name="jshint" depends="init,-jshint-win,-jshint-unix,-jshint-mac" description="--> verify syntax of JavaScripts">
</target>

<target name="doc" depends="doc.api" description="generate documentation">
Expand Down Expand Up @@ -243,45 +312,10 @@
C:>myproject\ant download-dependencies dist
</description>

<!-- for compression of JavaScript -->
<get dest="${tools.dir}/jsjam.pl" usetimestamp="true" ignoreerrors="true" src="http://www.anvilon.com/software/download/jsjam" />

<!-- unit testing -->
<get dest="${lib.dir}/junit-${tools.junit.version}.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/junit/jars/junit-${tools.junit.version}.jar" verbose="true" />

<get dest="${lib.dir}/jsunit${tools.jsunit.version}.zip" usetimestamp="true" ignoreerrors="true" src="http://mesh.dl.sourceforge.net/sourceforge/jsunit/jsunit${tools.jsunit.version}.zip" verbose="true" />
<unzip src="${lib.dir}/jsunit${tools.jsunit.version}.zip" dest="${tools.dir}/JSUnit" />

<get dest="${lib.dir}/jstester-${tools.jstester.version}.jar" usetimestamp="true" ignoreerrors="true" src="http://switch.dl.sourceforge.net/sourceforge/jstester/jstester-${tools.jstester.version}.jar" verbose="true" />

<get dest="${lib.dir}/js-${tools.rhino.version}.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/rhino/jars/js-${tools.rhino.version}.jar" verbose="true" />
<get dest="${lib.dir}/commons-logging-${tools.commons-logging.version}.jar" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-${tools.commons-logging.version}.jar" verbose="true" />


<!-- for API documentation -->
<get dest="${lib.dir}/JSDoc-${tools.jsdoc.version}.tgz" usetimestamp="true" ignoreerrors="true" src="http://mesh.dl.sourceforge.net/sourceforge/jsdoc/JSDoc-${tools.jsdoc.version}.tgz" verbose="true" />
<mkdir dir="${tools.dir}/JSDoc" />
<untar compression="gzip" src="${lib.dir}/JSDoc-${tools.jsdoc.version}.tgz" dest="${tools.dir}/JSDoc" />

<!-- install HTML-Template via CPAN -->
<exec executable="perl">
<arg line="-MCPAN -e 'install HTML::Template'" />
</exec>

<!-- JavaScript Lint -->
<get dest="${lib.dir}/jsl-${tools.jsl.version}-win32.zip" usetimestamp="true" ignoreerrors="true" src="http://www.javascriptlint.com/download/jsl-${tools.jsl.version}-win32.zip" />
<unzip src="${lib.dir}/jsl-${tools.jsl.version}-win32.zip" dest="${tools.dir}/jsl" />
<!--
<get dest="${lib.dir}/apache-forrest.zip" usetimestamp="true" ignoreerrors="true" src="http://www.artfiles.org/apache.org/forrest/apache-forrest-0.7.zip" />
<unzip src="${lib.dir}/apache-forrest.zip" dest="${tools.dir}/apache-forrest" />
<copy todir="${ant.home}/lib" file="${env.FORREST_HOME}/lib/core/xml-commons-resolver-1.1.jar" />
-->
<!--
<get dest="${lib.dir}/velocity.zip" usetimestamp="true" ignoreerrors="true" src="http://www.apache.org/dist/jakarta/velocity/velocity-1.4/velocity-1.4.zip" />
-->
<!-- for examples and servlet-->
<get dest="${log4j.jar}" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/log4j/jars/log4j-${tools.log4j.version}.jar" verbose="true" />
<get dest="${servlet-api.jar}" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/javax.servlet/jars/servlet-api-${tools.servlet-api.version}.jar" verbose="true" />
<!-- TODO: handle servlet api library download and log4js lib compilation, as well as example -->
<!-- <get dest="${log4j.jar}" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/log4j/jars/log4j-${tools.log4j.version}.jar" verbose="true" /> -->
<!-- <get dest="${servlet-api.jar}" usetimestamp="true" ignoreerrors="true" src="http://www.ibiblio.org/maven/javax.servlet/jars/servlet-api-${tools.servlet-api.version}.jar" verbose="true" /> -->
</target>


Expand All @@ -296,20 +330,14 @@
<!-- =================================
target for forrest: use site to generate the files
================================= -->
<target name="site" description="Generates static HTML documentation" depends="doc.api, compile">


<exec executable="${env.FORREST_HOME}/bin/forrest.bat" dir="log4js-site">
<target name="site" description="Generates static HTML documentation" depends="doc.api, compile, -site-win, -site-unix, -site-mac">
<copy todir="${project.site-dir}">
<fileset dir="log4js-site/build/site"></fileset>
</copy>
<echo>Copy robots.txt into the site...</echo>
<copy todir="${project.site-dir}" file="log4js-site/xdocs/content/xdocs/robots.txt">

</exec>

<copy todir="${project.site-dir}">
<fileset dir="log4js-site/build/site"></fileset>
</copy>
<echo>Copy robots.txt into the site...</echo>
<copy todir="${project.site-dir}" file="log4js-site/xdocs/content/xdocs/robots.txt">

</copy>
</copy>

<mkdir dir="${project.site-dir}/apidocs" />

Expand Down Expand Up @@ -342,54 +370,23 @@
</target>
-->

<!-- =================================
target: compile.test
================================= -->
<target name="compile.test" depends="init" description="--> compiles test clases">
<mkdir dir="${classes.test.java.dir}" />
<javac srcdir="${src.test.java.dir}" destdir="${classes.test.java.dir}">
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>

<!-- =================================
target: test
================================= -->
<target name="test" depends="compile, compile.test" description="--> Unit tests">
<mkdir dir="${dist.reports.dir}" />

<junit printsummary="yes">
<classpath>
<pathelement location="${dist.dir}" />
<pathelement path="${dist.dir}/classes" />
<pathelement path="${classes.test.java.dir}" />
<pathelement path="${src.js.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>

<formatter type="xml" />

<batchtest todir="${dist.reports.dir}">
<fileset dir="${src.test.java.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>

<!-- Create html output from the reports -->
<junitreport todir="${dist.reports.dir}">
<fileset dir="${dist.reports.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${dist.reports.dir}" />
</junitreport>
</target>
<target name="test" depends="compile" description="--> Unit tests">
<mkdir dir="${dist.reports.dir}" />
<exec executable="grunt" failonerror="false" dir="${src.base}">
<arg line="karma" />
</exec>

<!-- TODO: Create html output from the reports -->
<!-- <junitreport todir="${dist.reports.dir}"> -->
<!-- <fileset dir="${dist.reports.dir}"> -->
<!-- <include name="TEST-*.xml" /> -->
<!-- </fileset> -->
<!-- <report format="frames" todir="${dist.reports.dir}" /> -->
<!-- </junitreport> -->
</target>


</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,26 @@ protected EventParser getParser(String contentType)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException {

EventParser parser = this.parserList.get(contentType);
String strippedContentType = contentType.split(";")[0];

EventParser parser = this.parserList.get(strippedContentType);

if (parser == null) {
String p = this.getServletConfig().getInitParameter(
"parser." + contentType);
"parser." + strippedContentType);

if (p == null) {
this.parserList.put(contentType, null);
this.parserList.put(strippedContentType, null);
throw new UnsupportedOperationException(
"Content type not supported: " + contentType);
"Content type not supported: " + strippedContentType);
}

Class<EventParser> c = (Class<EventParser>) Class.forName(p);
parser = c.newInstance();
this.parserList.put(contentType, parser);
this.parserList.put(strippedContentType, parser);
}

return parser;
}

}
}
Loading