Jenkins with JSLint and Violations plugin - plugins

I currently configured a jenkins server that validates my project on javascript errors with JSlint ( with ant). Now i want to show all the errors with the violation plugin. I can generate an xml with all the errors. But it doesn't show this in the graph.
This is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<taskdef name="jslint"
classname="com.googlecode.jslint4java.ant.JSLintTask"
classpath="jslint/jslint4java-2.0.2.jar" />
<property name="reports.dir" value="reports" />
<target name="clean" description="Removes output files created by other targets.">
<delete dir="${reports.dir}" failonerror="true" />
</target>
<target name="jslint" depends="clean">
<mkdir dir="reports" />
<jslint options="white,undef,plusplus,newcap,vars,indent=4">
<predef>jQuery, setTimeout, history, window, document</predef>
<formatter type="xml" destfile="jslint_results.xml"/>
<fileset dir="" includes="**/*.js" excludes="lib/*.js" />
</jslint>
</target>
This is my violations setting:

The pattern is relative to your workspace. So if your report 'lives' in <WORKSPACE>/reports the pattern should be reports/jslint_results.xml or **/jslint_results.xml

Related

Missing output files after running Ant script from Eclipse

I have a simple web application developed in the Eclipse Luna. The directory structure of the application is like:
Project name is SchoolSchedule.
Under the project name, there are Java Resources, build, WebContent folders, and the build.xml file.
Under Java Resources, it is the "src" folder and my Java code package name is under the "src" folder.
Under the WebContent, there are META-INF, WEB-INF and my jsp files
Under the WEB-INF, there are web.xml file and the "lib" directory.
The build.xml is at the project root. This web application runs successfully and produces expected results.
I created an Ant script to compile, build a WAR file, and deploy the WAR. But, even the basic task does not work. I right click on the build.xml --> run as ... --> Ant build. In the console, I can see all the echo messages and no error. However, I do not see any new directories created (I "refresh" the project.). No "class" files compiled from the Java code and not to mention build and deploy those tasks.
There is something I did not get it right. Please help. Here is my Ant script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntWarWebApp" basedir="." >
<echo>Define properties</echo>
<property name="name" value="SchoolSchedule"/>
<property name="src" location="src"/>
<property name="web" location="WebContent"/>
<property name="build" location="build"/>
<property name="classDir" location="${build}/src"/>
<property name="distDir" location="${build}/dist"/>
<property name="warDir" location="${build}/war"/>
<property name="tomcat.webapps" value="C:\apache-tomcat-7.0.70\webapps" />
<echo>time stamp</echo>
<tstamp prefix="build-info">
<format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
<format property="current-time" pattern="hh:mm:ss a z" locale="en" />
<format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>
<echo>clean up previous build directories</echo>
<target name="clean" description="Delete old build directories">
<delete dir="${distDir}"/>
<delete dir="${warDir}"/>
<delete dir="${classDir}"/>
</target>
<echo>create directories</echo>
<target name="init" depends="clean">
<mkdir dir="${build}"/>
<mkdir dir="${classDir}"/>
<mkdir dir="${warDir}"/>
<mkdir dir="${distDir}"/>
<mkdir dir="${warDir}/WEB-INF"/>
<mkdir dir="${warDir}/WEB-INF/classes"/>
</target>
<echo>start compiling</echo>
<target name="compile" depends="clean, init" description="Compile main
source tree java files">
<javac srcdir="${src}" destdir="${classDir}" />
<classpath>
<fileset dir="${basedir}/WebContent/WEB-INF/lib">
<include name="*" />
</fileset>
</classpath>
</target>
<echo>start building WAR file</echo>
<target name="buildwar" depends="clean, init, compile">
<war basedir="${wardir}" destfile="${distDir}/${name}.war"
webxml="${wardir}/WEB-INF/web.xml">
<webinf dir="${wardir}/WEB-INF/">
<include name="**/*.jar" />
</webinf>
<manifest>
<attribute name="Built-On" value="${build-info.current-date}" />
<attribute name="Built-At" value="${build-info.current-time}" />
</manifest>
</war>
</target>
<echo>end building WAR file</echo>
<target name="deploy" depends="init, compile, buildwar" description="Deploy application">
<delete dir="${tomcat.webapps}/*.war" />
<echo>copy WAR file to Tomcat deploy directory</echo>
<copy file="${distdir}/*.war" todir="${tomcat.webapps}" />
</target>
</project>
Aren't you supposed to have some kind of top-level element
<project>
....
</project>
around all this?

How to build and deploy adapter with single ANT script Worklight 6.1

At 6.1 the ant jar was split into two jars: worklight-ant-builder.jar and worklight-ant-deployer.jar. I can run the build or the deploy tasks by themselves but I have to change the fileset. I want to run the build adapter and deploy adapter out of a single ant script.
I've tried a few ways to include both jars in the taskdef fileset:
include name="*.jar"
or
filename name="*.jar"
or
include name="worklight-ant-builder.jar"
include name="worklight-ant-deployer.jar"
Its almost like the tasks won't accept multiple jars. The build always works, but the deploy only when the deployer.jar is "include name="worklight-ant-deployer.jar" by itself.
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<fileset dir="${worklight.server.install.dir}/WorklightServer">
<include name="*.jar"/>
<!-- <filename name="*.jar"/> -->
<!-- <include name="worklight-ant-builder.jar"/> -->
<!-- <include name="worklight-ant-deployer.jar"/> -->
</fileset>
</classpath>
</taskdef>
I understand the multi-script answer but I think I shouldn't have to do that. This is my full script:
<?xml version="1.0" encoding="UTF-8"?>
<project name="BuildDeployAdapter" basedir="." default="help">
<property name="worklight.server.install.dir" value="C:/IBM/Worklight61/"/>
<property name="adapter-source-files-folder" value="C:/Worklight/workspaces/base61p/HelloWorklight/adapters/HTTPAdapter"/>
<property name="destination-folder" value="C:/Worklight/workspaces/base61p/HelloWorklight/binANT"/>
<property name="myAdapter.adapter" value="${destination-folder}/HTTPAdapter.adapter"/>
<property name="http.server.port.context" value="http://mydomain:9080/worklight"/>
<taskdef resource="com/worklight/ant/defaults.properties">
<classpath>
<fileset dir="${worklight.server.install.dir}/WorklightServer">
<include name="*.jar"/>
<!-- <filename name="*.jar"/> -->
<!-- <include name="worklight-ant-builder.jar"/> -->
<!-- <include name="worklight-ant-deployer.jar"/> -->
</fileset>
</classpath>
</taskdef>
<target name="buildAdapter">
<adapter-builder
folder="${adapter-source-files-folder}"
destinationfolder="${destination-folder}"/>
</target>
<target name="deployAdapter">
<adapter-deployer deployable="${myAdapter.adapter}"
worklightserverhost="${http.server.port.context}"
userName="username" password="password" />
</target>
</project>
Right now I have to switch the included jar for each task, when I want to use the masked include - either include name=".jar" or filename name=".jar". This seems to be a limititation on the specific task not accepting more than one jar. Am I off base here?
Given the information you provided, it seems that a solution could be to create a separate script that would invoke the build and deploy scripts in sequence, like this:
<project name="Adapter Stuff" default="do.all" basedir=".">
<target name="do.all">
<ant antfile="path/to/worklight-build-adapter.xml"
target="build-target" inheritall="false"/>
<ant antfile="path/to/worklight-deploy-adapter.xml"
target="deploy-target" inheritall="false"/>
</target>
</project>

error CS0246: The type or namespace name 'Form1' could not be found

Currently I am developing a NAnt script to build a Windows forms application. After build the NAnt script, I am getting the error as
error CS0246: The type or namespace name 'Form1' could not be found
(are you missing a using directive or an assembly reference? )
BUILD FAILED
C:\Program
Files\NAnt\examples\SampleWindowsApplication\Sample.Build(24,10):
External Program Failed:
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe (return code was 1)”
Can anyone please advise to resolve this issue?
Please find my code below.
<?xml version="1.0"?>
<project name="SampleWindowsApplication" default="run">
<property name="basename" value="SampleWindowsApplication"/>
<property name="debug" value="true"/>
<target name="clean">
<delete>
<fileset>
<include name="bin/${basename}-??.exe"/>
</fileset>
</delete>
</target>
<target name="build">
<mkdir dir="bin" />
<assemblyfileset id="Sample.assemblies">
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Grid.Base.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Grid.Windows.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Shared.Base.dll" />
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\Sam.Shared.Windows.dll" />
<!--<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Assemblies\System.Windows.Forms.dll" />-->
</assemblyfileset>
<csc target="exe" output="bin/${basename}.exe" debug="${debug}" >
<references refid="Sample.assemblies" />
<resources>
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\licenses.licx"/>
</resources>
<sources>
<include name="C:\Program Files\NAnt\examples\SampleWindowsApplication\SampleWindowsApplication\Program.cs"/>
</sources>
</csc>
</target>
<target name="run" depends="build">
<exec program="bin/${basename}-cs.exe" basedir="."/>
</target>
</project>
Thanks in advance.
This is typically cause when you add a new file to your solution but don't commit them.
Check to make sure that Form1.cs and Form1.Designer.cs have been added to your source control repository. It looks like your project file was added and committed correctly but some source control tools require you to manually add new files before committing them.

Getting gwt hibernate example code to work with eclipse

I am starting out with GWT and hibernate. I'm going through the tutorial at https://developers.google.com/web-toolkit/articles/using_gwt_with_hibernate.
I downloaded the sample code provided with the tutorial (http://google-web-toolkit.googlecode.com/files/gwt_hibernate_base.zip). This is a simple music store where you can add an account and records. I am able to run this and successfully add accounts and records to the database by doing the following commands:
(in the data directory) java -cp ../lib/hsqldb.jar org.hsqldb.Server
ant build hosted
Here is the build.xml file used to build this:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Guestbook" default="build" basedir=".">
<!-- Define gwt.home, gwt.dev.jar, appengine.sdk.home -->
<property file="build.properties"/>
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.home}/gwt-user.jar"/>
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="libs" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.home}/gwt-servlet.jar" />
<!-- Add any additional server libs that need to be copied -->
<copy todir="war/WEB-INF/lib" flatten="true">
<fileset dir="lib/">
<include name="**/*.jar"/>
</fileset>
</copy>
</target>
<target name="javac" depends="libs" description="Compile java source">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
</target>
<!-- can add additional arguments like -logLevel INFO or -style PRETTY -->
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg value="com.google.musicstore.MusicStore"/>
</java>
</target>
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="-startupUrl"/>
<arg value="MusicStore.html"/>
<arg value="com.google.musicstore.MusicStore"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
</java>
</target>
<target name="build" depends="gwtc" description="Build this project" />
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/musicstore" failonerror="false" />
</target>
Now I would like to get this simple example working in eclipse. I created a project called MusicStore using the gwt eclipse plugin. I then copied over the tutorial files without changing them. I can't post an image but here is a link to my eclipse project structure:
http://oi50.tinypic.com/t6rn2w.jpg
Again, I start by running
(in the data directory) java -cp ../lib/hsqldb.jar org.hsqldb.Server
Then I try to run my project in eclipse but hibernate doesn't work. When I try to add an account in the UI it alerts "Failed to save account" and I get the error java.lang.NoClassDefFoundError: org/hibernate/Session.
Please let me know how I should go about getting the sample code working with eclipse. I think that many users new to hibernate will also want to do this.
Thanks!
Basically eclipse cannot find your hibernate libraries. That is because your build.xml is for building a war file. Eclipse doesn't read it so it doesn't have any of your build information in there.
A quick solution to this is to just go to the "Build Path" properties in Eclipse and make sure your /lib directory is included in the "Libraries" tab. Then eclipse will know where you are keeping your libraries.
A better solution would be to use something like Maven. Then the Maven Plugin for Eclipse will automatically look at the Maven build file and configure the Eclipse project so that it can detect where the libraries are held etc...

NAnt and System.Data.Entity.dll

I am new to NAnt and trying to set up a build file to build a few .Net 4.0 projects and run some NUnit tests. One of the projects contains an EF4.0 Data Model and context and I am running into an issue that even though the System.Data.Entity.dll reference is being included in the NAnt config, none of the System.Data classes contained in it are being found by the build (System.Data.EntityClient, System.Data.Objects, etc). I am using NAnt 0.91 Alpha 2. Anyone else run into this or have any idea how to get around it? Build file below.
Thanks.
<?xml version="1.0" encoding="utf-8" ?>
<project name="ClinicalModel">
<property name="src.dir" value="" />
<property name="output.dir" value="bin/debug" />
<property name="entitysrc" value="..\Entities" />
<property name="debug" value="true" overwrite="false" />
<property name="nant.settings.currentframework" value="net-4.0" />
<property name="framework-get-assembly-directory" value="${framework::get-assembly-directory('net-4.0')}" />
<property name="dotNetReferenceAssemblyPath" value="${framework-get-assembly-directory}\" />
<target name="clean" description="clean up already built files">
<delete file="${output.dir}/Entities.dll" failonerror="false" />
<delete file="${output.dir}/Model.dll" failonerror="false" />
</target>
<target name="build_entities" description="build entities">
<csc target="library" output="${output.dir}\Entities.dll" debug="${debug}">
<sources basedir="${entitysrc}">
<include name="**/*.cs" />
</sources>
</csc>
</target>
<target name="build" depends="build_entities" description="build model">
<csc target="library" output="${output.dir}\Model.dll" debug="${debug}">
<sources>
<include name="**\*.cs" />
</sources>
<references basedir="${output.dir}">
<include name="**\*.dll" />
</references>
</csc>
</target>
</project>
This may not be the solution you are looking for but I would recommend letting msbuild do the actual build work. Since you don't want to build the entire solution you would end up making 4 calls (one for each project you want to build) to msbuild. Here is a snippet from my root build script:
<property name="common.msbuild2010" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe" />
<property name="common.buildType" value="Debug" />
...
<setenv>
<variable name="DevEnvDir" value="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\"/>
</setenv>
<exec program="${common.msbuild2010}" commandline=""${local.someCsProjName}" /t:Rebuild /p:Configuration=${common.buildType}" />