The ant script below checks out a java project from a given svn url and runs the downloaded source files against sonar.
Prerequisites:
SVN Client installed
Included jars on classpath : ant.jar, sonar-ant-task-2.1.jar, svnjavahl.jar, svnClientAdapter.jar, svnant.jar
build.xml (Highlighted portions in red are to be set by user/setup dependent)
<?xml version="1.0" encoding="UTF-8"?>
<project name="Update" basedir="." default="update" xmlns:sonar="antlib:org.sonar.ant">
<path id="svnant.classpath">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<property name="project.svn.url" value="your-svn-url-of-project" />
<!-- <taskdef resource="svntask.properties" /> -->
<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="svnant.classpath"/>
<target name="update">
<svn>
<checkout url="${project.svn.url}" revision="HEAD" destPath="MyProject" />
</svn>
</target>
<property name="sonar.jdbc.url" value="jdbc:h2:tcp://localhost:9092/sonar" />
<property name="sonar.jdbc.username" value="sonar" />
<property name="sonar.jdbc.password" value="sonar" />
<property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
<property name="sonar.projectName" value="Sonar Sample Project Ant Run" />
<property name="sonar.projectVersion" value="1.0"/>
<property name="sonar.language" value="java" />
<property name="sonar.sources" value="MyProject/src" />
<!-- <property name="sonar.binaries" value="build/*.jar" />
-->
<property name="sonar.host.url" value="http://localhost:9000" />
<target name="sonar" depends="update">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml" classpathref="svnant.classpath">
</taskdef>
<sonar:sonar/>
</target>
</project>
Prerequisites:
SVN Client installed
Included jars on classpath : ant.jar, sonar-ant-task-2.1.jar, svnjavahl.jar, svnClientAdapter.jar, svnant.jar
build.xml (Highlighted portions in red are to be set by user/setup dependent)
<?xml version="1.0" encoding="UTF-8"?>
<project name="Update" basedir="." default="update" xmlns:sonar="antlib:org.sonar.ant">
<path id="svnant.classpath">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<property name="project.svn.url" value="your-svn-url-of-project" />
<!-- <taskdef resource="svntask.properties" /> -->
<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="svnant.classpath"/>
<target name="update">
<svn>
<checkout url="${project.svn.url}" revision="HEAD" destPath="MyProject" />
</svn>
</target>
<property name="sonar.jdbc.url" value="jdbc:h2:tcp://localhost:9092/sonar" />
<property name="sonar.jdbc.username" value="sonar" />
<property name="sonar.jdbc.password" value="sonar" />
<property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
<property name="sonar.projectName" value="Sonar Sample Project Ant Run" />
<property name="sonar.projectVersion" value="1.0"/>
<property name="sonar.language" value="java" />
<property name="sonar.sources" value="MyProject/src" />
<!-- <property name="sonar.binaries" value="build/*.jar" />
-->
<property name="sonar.host.url" value="http://localhost:9000" />
<target name="sonar" depends="update">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml" classpathref="svnant.classpath">
</taskdef>
<sonar:sonar/>
</target>
</project>
0 comments:
Post a Comment