I am trying to build my project. Here is my build.xml
<?xml version="1.0"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="WMCOMMONINFRASTRUCTURE-WMINFRASTRUCTURE" default="dist">
<import file="../build.xml" />
<property file="../../build.properties" />
<!-- ===================================================================
- init - initialization for this submodule
- ==================================================================== -->
<target name="init" depends="module-init">
<!-- Submodule properties -->
<property name="submodule.name" value="wminfra" />
<property name="dist.jar.name" value="wminfra-${version}.jar" />
<property name="dist.jar" value="${root.dist.dir}/${dist.jar.name}" />
<!-- Submodule paths -->
<path id="submodule.path">
<path refid="common.path" />
</path>
<path id="test.path">
<path refid="submodule.path" />
<path refid="test.root.path" />
</path>
</target>
<target name="prepare" depends="init">
<mkdir dir="${root.build.dir}" />
<mkdir dir="${root.dist.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${test-classes.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${api.dir}" />
<mkdir dir="${test.docs.dir}" />
<!--<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" sync="true"/>-->
<ivy:retrieve sync="true"/>
</target>
<!-- ===================================================================
- clean - clean all build remnants from this submodule
- ==================================================================== -->
<target name="clean" depends="init">
<echo message="cleaning ${module.name}-${submodule.name}" />
<delete file="${warArtifacts.dir}/${dist.jar.name}" />
<delete file="${earArtifacts.dir}/${dist.jar.name}" />
<delete file="${dist.jar}" />
<delete dir="${build.dir}" />
</target>
<!-- ===================================================================
- checkstyle - ensures all non-generated code meets the company
-
- =================================================================== -->
<target name="checkstyle" depends="init">
<echo message="verifying code adheres to coding standards..." />
<!-- doesn't do anything yet -->
</target>
<!-- ===================================================================
- compile - compile Java source files
- =================================================================== -->
<target name="compile" depends="checkstyle,compile-sources" />
<!-- ===================================================================
- dist - create distribution jars (which will be used for deployment)
- =================================================================== -->
<target name="dist" depends="compile">
<jar jarfile="${dist.jar}">
<fileset dir="${classes.dir}">
<include name="**/*.class" />
</fileset>
<fileset dir="${resources.dir}">
<include name="**/*.*" />
</fileset>
</jar>
<!-- we want the dist jar in the ear file, so copy it over to the
ear staging directory: -->
<copy toDir="${earArtifacts.dir}" file="${dist.jar}" />
<!-- we also want it available to the web application: -->
<copy toDir="${warArtifacts.dir}" file="${dist.jar}" />
<ivy:publish resolver="local" pubrevision="${version}" status="integration" forcedeliver="true" overwrite="true"/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
<delete file="${root.dist.dir}/${dist.jar.name}"/>
</target>
<!-- ===================================================================
- deploy - recreates the platform ear file with only the changes made
- in this submodule, and then deploys this newly created ear
- file, replacing any old one that existed previously.
- =================================================================== -->
<target name="deploy" depends="dist,undeploy,quick-deploy" />
<!-- ===================================================================
- all - everything
- =================================================================== -->
<target name="all" depends="deploy" />
</project>
The above written
<ivy:publish resolver="local" pubrevision="${version}" status="integration" forcedeliver="true" overwrite="true"/>
line gives the error.
My build.properties file is as follows:
project.name=FCPBMain\12.0.1
delta.name=DELTA
root.base.dir=C:/CORE_DELTA/${project.name}
settings.localRepository=C:/FCPBRepository/12.0.1
tomcat.local=D:/apache-tomcat-6.0.35
version=12.0.1
root.artifact.dir=${root.base.dir}
root.src.dir=.
#ivy properties
ivy.user.dir=C:/WmIvyRepository/12.0.1
#ivy shared repository properties
ivy.shared.dir=\\\\iflblw-wm-21/WMIvyRepository/cache
#ivy shared repository ivy.xml retrieve pattern
ivy.shared.ivy.pattern=[organisation]/[module]/ivy-[revision].xml
#ivy shared repository artifact retrieve pattern
ivy.shared.artifact.pattern=[organisation]/[module]/[type]s/[artifact].[ext]
#Added by MP for more deployment options
#Choose the target server
deploy.tomcat=true
deploy.weblogic=false
deploy.weblogic92=false
deploy.websphere=false
#Choose the ear file creation option
deploy.bankonly=false
deploy.custonly=false
deploy.both=true
#True if to be build without integration with core banking
#False when integratiion is done
fcpbkernelserviceadaptor.build=true
#MP: choose the options for customer login sso options
customerlogin.sso=false
I have done the following things:
set ant options as
set ANT_OPTS=-Xmx1024m -XX:MaxPermSize=512m
set path in environment variables as
C:\Program Files\Java\jdk1.6.0_13;C:\Program Files\Java\jdk1.6.0_13\jre\bin;D:\product\11.2.0\dbhome_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;D:\Ant1.7.1\bin;
set ANT_home as environment variable.
When the above xml file is tried to be built, the following directory structure is created successfully C:\CORE_DELTA\FCPBMain12.0.1\build\dist.
In this dist folder earArtifacts, warArtifacts, ivy-12.0.1.xml and wminfra-12.0.1.jar is created. Out of which, the ivy.xml file is always of 0KB, it's empty.
Guess, the problem is in \1 part of project.name property value - it is interpreted as an escape sequence. In my case, same error was caused by non-ASCII symbol ≤ in comment.
Related
Say I have a library and a binary target, let's call them MyLib and MyBin,
MyBin depends on MyLib.
I'm trying to create an Ant buildfile for MyBin that first builds MyLib and then includes it in the classpath when building MyBin.
I've tried using Ant tasks as in Building other, dependent projects with Ant .
However, it's not working, and from ant -v I think the MyBin build-deps target is not even building MyLib. Seems like it's confusing MyBin and MyLib properties? I'm not sure how to prevent this though.
I'm dumping only MyBin/build.xml below, but the MyLib is almost identical, except it does not have the build-deps target.
<project name="MyBin" default="main" basedir=".">
<property name="projectName" value="MyBin" />
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="dist.lib.dir" location="dist/lib" />
<property name="lib.dir" value="lib" />
<target name="build-deps" depends="init">
<!-- MyLib main target does clean -> build -> jar to dist folder -->
<!-- Its build.xml uses many of the same property values as above -->
<ant antfile="../MyLib/build.xml" target="main"/>
</target>
<path id="classpath">
<fileset dir="${basedir}/">
<include name="../MyLib/dist/**/*.jar" />
</fileset>
</path>
<!-- Need classpath to run this -->
<target name="compile" depends="build-deps" description="compile the source ">
<javac includeantruntime="false" srcdir="${src.dir}"
destdir="${build.dir}" classpathref="classpath" />
</target>
<!-- Group all dependencies into a big dependency-all.jar -->
<target name="copy-dependencies">
<mkdir dir="${dist.lib.dir}" />
<jar jarfile="${dist.lib.dir}/dependencies-all.jar">
<zipgroupfileset dir="${lib.dir}">
<include name="**/*.jar" />
</zipgroupfileset>
</jar>
</target>
<!-- jar it, extract above dependency-all.jar and zip it with project files -->
<target name="jar" depends="compile, copy-dependencies"
description="package, output to JAR">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.lib.dir}" />
<jar jarfile="${dist.dir}/${projectName}.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
<zipfileset src="${dist.lib.dir}/dependencies-all.jar"
excludes="META-INF/*.SF" />
</jar>
</target>
<target name="clean" description="clean up">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Default, run this -->
<target name="main" depends="clean, compile, jar" />
</project>
What I see with ant -v in MyBin is something along the lines of:
build-deps:
Project base dir set to: /MyBin
[ant] calling target(s) [main] in build file /MyLib/build.xml
parsing buildfile /MyLib/build.xml with URI = file:/MyLib/build.xml
Project base dir set to: /MyBin
Override ignored for property "projectName"
Override ignored for property "build.dir"
Override ignored for property "dist.dir"
Override ignored for property "dist.lib.dir"
Override ignored for property "lib.dir"
[pathconvert] Set property classpath.name =
[ant] Entering /MyLib/build.xml...
Build sequence for target(s) `main' is [clean, init, copy-dependencies, jar, main]
Complete build sequence is [clean, init, copy-dependencies, jar, main, ]
clean:
[delete] Deleting directory /MyBin/bin
[delete] Deleting directory /MyBin/bin
init:
[mkdir] Created dir: /MyBin/bin
copy-dependencies:
[ant] Exiting /MyLib/build.xml.
On your specific question:
seems like it's confusing MyBin and MyLib properties? I'm not sure how
to prevent this though.
You are using this to invoke the MyLib build:
<ant antfile="../MyLib/build.xml" target="main" />
A build invoked via the <ant> task this way by default inherits all properties from the caller, including basedir, hence the build is run in the wrong place.
Instead you could use, for example:
<ant dir="../MyLib" />
That will run build.xml in the specified directory, set the basedir property, and call the default target, which should be main if you are using a very similar buildfile for the library as you say. If you don't want to inherit properties from MyBin when executing the MyLib task, specify inheritAll=false in the task.
From the <ant> task docs for the dir attribute:
the directory to use as a basedir for the new Ant project (unless
useNativeBasedir is set to true). Defaults to the current project's
basedir, unless inheritall has been set to false, in which case it
doesn't have a default value. This will override the basedir setting
of the called project. Also serves as the directory to resolve the
antfile and output attribute's values (if any).
I am struggling with maven-ant build with eclipse.
I did work like below steps.
[GUI] new java project
add build.xml in project top folder
run ant file and SUCCEED!
trying to code, but somehow auto completion does not work.(guessing eclipse can not read maven-ant dependency.path)
So I tried.
add ~/.m2/repository in build path as a External class folder - does not work - It looks weird to me to include whole this folder. My current project, I need little libraries, but it has whole libraries that I uses in other projects.
add builders with build.xml like Want an eclipse java project to run ant build files automatically - does not work neither.
How can I add this maven-ant libraries properly? Thanks for sharing your experiences and answers XD
=========== Extra Information ====================
This is my build.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project name="HibernateEx2" default="db" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="source.root" value="src"/>
<property name="class.root" value="classes"/>
<property name="data.dir" value="data"/>
<artifact:dependencies pathId="dependency.classpath">
<dependency groupId="hsqldb" artifactId="hsqldb" version="1.8.0.10"/>
<dependency groupId="org.hibernate" artifactId="hibernate-core" version="4.3.10.Final">
<exclusion groupId="javax.transaction" artifactId="jta"/>
</dependency>
<!-- 3.2.4.GA - After hibernate4 need upgrade hibernate-tools -->
<dependency groupId="org.hibernate" artifactId="hibernate-tools" version="4.3.1.CR1"/>
<dependency groupId="org.apache.geronimo.specs" artifactId="geronimo-jta_1.1_spec" version="1.1.1"/>
<!-- java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory -->
<dependency groupId="commons-logging" artifactId="commons-logging" version="1.2"/>
<dependency groupId="log4j" artifactId="log4j" version="1.2.17"/>
<!-- java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder -->
<dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.7.12"/>
</artifact:dependencies>
<path id="project.class.path">
<pathelement location="${class.root}"/>
<path refid="dependency.classpath" />
</path>
<!-- Explaining how to use hibernate -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path"/>
<target name="db" description="Run HSQLDB database management UI against the database file -- use when application is not running">
<java classname="org.hsqldb.util.DatabaseManager" fork="yes">
<classpath refid="project.class.path"/>
<arg value="-driver"/>
<arg value="org.hsqldb.jdbcDriver"/>
<arg value="-url"/>
<arg value="jdbc:hsqldb:${data.dir}/music/"/>
<arg value="-user"/>
<arg value="sa"/>
</java>
</target>
<target name="print-classpath" description="Show the dependency class path">
<property name="class.path" refid="dependency.classpath"/>
<echo>${class.path}</echo>
</target>
<!-- Generate java code -->
<target name="codegen" description="Generate Java source from the OR mapping files">
<hibernatetool destdir="${source.root}">
<configuration configurationfile="${source.root}/hibernate.cfg.xml"/>
<hbm2java/>
</hibernatetool>
</target>
<!-- Creating Sub drectories -->
<target name="prepare" description="Set up build structures">
<mkdir dir="${class.root}"/>
<copy todir="${class.root}">
<fileset dir="${source.root}">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!-- Creating Schema for mapping files -->
<target name="schema" depends="prepare" description="Generate DB schema from the OR mappinf files">
<hibernatetool destdir="${source.root}">
<configuration configurationfile="${source.root}/hibernate.cfg.xml"/>
<hbm2ddl drop="yes"/>
</hibernatetool>
</target>
<!-- Compile Java -->
<!-- added includeantruntime="false" to javac, since terminal compile warning -->
<target name="compile" depends="prepare">
<javac srcdir="${source.root}" destdir="${class.root}"
debug="on" optimize="off" deprecation="on" includeantruntime="false">
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="ctest" depends="compile">
<java classname="org.owls.ht.CreateTest" fork="true">
<classpath refid="project.class.path"/>
</java>
</target>
</project>
and This is what my project looks like.
src
-- source codes (includes hibernate.cfg.xml)
classes
-- compiled classes
data
-- logs and queries
build.xml
FYI, I am doing this with a book named [[Harness Hibernate]] written by James Elliot from O'reilly.
Thanks again b
For what you are trying to do, you need the filesetId and versionsId="dependency.versions" in your declaration of:
<artifact:dependencies filesetId="dependency.fileset" versionsId="dependency.versions"
Then add a copy task like so:
<copy todir="${lib.dir}">
<fileset refid="dependency.fileset" />
<mapper classpathref="maven-ant-tasks.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten" />
</copy>
The to="flatten" will flaten your dependencies into a single folder, then you can include that folder on the classpath of eclipse project or wherever you need it.
I am currently using a ruby gem SASS in order to convert my *.scss files to *.css files on a large project. Here is a mockup of the code I am using:
<?xml version="1.0"?>
<!-- scss to CSS -->
<project name="StackOverflowScssCss" default="sass-compile-to-css" basedir=".">
<property file="build.properties" />
<target name="sass-compile-to-css">
<echo message="Compiling scss files to css..." />
<!-- create the css destination dir if it doesn't already exist -->
<property name="css-dest" location="${css.dir}" />
<echo message="Creating directory at ${css.dir} [if it doesn't yet exist]" />
<mkdir dir="${css-dest}" />
<!-- create subdirs if necessary -->
<echo message="Creating css directories (and temporary .css files) for .scss to be compiled..." />
<touch mkdirs="true">
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="${css.dir}/*.css" />
</touch>
<echo message="Running sass executable against sass files and compiling to CSS directory [${css-dest}] " />
<!-- run sass executable -->
<apply executable="sass" dest="${css-dest}" verbose="true" force="true" failonerror="true">
<arg value="--unix-newlines" />
<!-- Disable creation of map file. THIS SHOULD BE A FLAG -->
<arg value="--sourcemap=none" />
<srcfile />
<targetfile />
<fileset dir="${sass.dir}" includes="**/*.scss" excludes="**/_*" />
<mapper type="glob" from="*.scss" to="*.css" />
</apply>
<echo message="Done compiling scss files!" />
</target>
</project>
Ultimately I want to remove the ruby dependency so I have been looking at this libsass maven plugin. I know that there are many options for libsass but I am trying to stick strictly to Java. Does anyone have any experience with doing this? I don't want to run Node.js, Sass.js ot anything, and I have racked my brain all day on how to do this. Any help is much appreciated!
There is a Java wrapper that can be used with Maven.
If you really want to stick with Java you could either
Use that wrapper and run the mvn task from inside your ant script (see here)
Adapt that wrapper and build your own Ant Task out of it
I ended up using a JRuby dependency in order to run on the JVM. My code is as follows:
<!-- Jruby Dependent SCSS to CSS conversion -->
<path id="JRuby">
<fileset file="packages/jruby-complete-1.7.20.1.jar"/> <!-- Location of JRuby jar file -->
</path>
<target name="compileSass" depends="cleanSass">
<echo message="Compiling scss files..." />
<!-- JRuby Script to convert files into new directory -->
<property name="filesIn" value="${dir.scss}/**/[^_]*.scss" />
<property name="projectDirectory" value="${user.dir}"/>
<script language="ruby" classpathref="JRuby">
<![CDATA[
require ($project.getProperty('projectDirectory')) + '/packages/sass-3.4.14/lib/sass'
require ($project.getProperty('projectDirectory')) + '/packages/sass-3.4.14/lib/sass/exec'
files = Dir.glob($project.getProperty('filesIn'))
files.each do
| file |
newOutDir = File.dirname(file).sub! 'scss', 'css'
FileUtils::mkdir_p newOutDir
puts "[sass compiler] From:" + file
puts "[sass compiler] To:" + newOutDir + "/" + File.basename(file, ".*") + ".css"
opts = Sass::Exec::SassScss.new(["--load-path", File.dirname(file), file, File.join(newOutDir, File.basename(file, ".*") + ".css")], 'scss')
opts.parse
end
]]>
</script>
<echo message="Done compiling scss files!" />
</target>
<target name="cleanSass">
<echo message="removing .css files..." />
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${dir.css}" includes="**/*.css" />
</delete>
<echo message="removing .css.map files..." />
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${dir.css}" includes="**/*.css.map" />
</delete>
</target>
this question is quite silly, but I can't find anyone else in the internet it seems who got the same problem and can't fix it themself.
This is my build.xml
I took it from an forum and changed the lines I knew what to put in.
<project name="RPGEssentials" default="dist" basedir="/var/lib/jenkins/workspace/RPGEssentials">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac includeantruntime="false" srcdir="${src}" destdir="${build}" encoding="iso-
8859-1"> <include name="../APIs/*.jar" /> </javac>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/RPGEssentials-0.0.1.jar" basedir="${build}"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
This is the console output after building:
Started by user G4meM0ment
Building in workspace /var/lib/jenkins/workspace/RPGEssentials
Checkout:RPGEssentials / /var/lib/jenkins/workspace/RPGEssentials -
hudson.remoting.LocalChannel#389329d0
Using strategy: Default
Last Built Revision: Revision 4b5d8a711c78fbe32efb06f91dd88d8f0660f5c0 (origin/master,
origin/HEAD)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Seen 2 remote branches
Commencing build of Revision 4b5d8a711c78fbe32efb06f91dd88d8f0660f5c0 (origin/master,
origin/HEAD)
Checking out Revision 4b5d8a711c78fbe32efb06f91dd88d8f0660f5c0 (origin/master,
origin/HEAD)
Warning : There are multiple branch changesets here
[RPGEssentials] $ ant
Buildfile: /var/lib/jenkins/workspace/RPGEssentials/build.xml
init:
compile:
dist:
BUILD SUCCESSFUL
Total time: 0 seconds
Archiving artifacts
Finished: SUCCESS
I'm pretty sure the error is in the build.xml the but I don't know what could be wrong.
The resulting jar-file contains some empty directories!
http://www.imagebanana.com/view/v68chgps/jarcontains.jpg
Thanks for your help
~Julian
This is a follow up question related to my question from yesterday:
Ant Ear Update Without Full Exploding Ear
I'm using Ant 1.8.2 and am able to update files in an ear, using the example I made in the provided link above.
I have a war file inside my ear file, and I'm hoping to see if there is a way to do a nested update (e.g. update a file in the war that is in the ear).
My other option is to extract the war, update the war, then update the ear with the updated war. If there is a way to do the nested update, I think it would save me time, as my war file is pretty big.
The following is my alternative approach POC, in case anyone is interested. I will use this if we cannot find a "nested" update.
<property name="ear.file1" value="file1.ear"/>
<property name="war.file1" value="war1.war"/>
<property name="war.file" value="war.war"/>
<property name="war.file.backup" value="warBk.war"/>
<property name="text.file1" value="1.txt"/>
<property name="text.file2" value="2.txt"/>
<property name="xml.application1" value="application.xml"/>
<target name="clean">
<delete file="${ear.file1}"/>
<delete file="${war.file}"/>
<delete file="${war.file.backup}"/>
</target>
<target name="run">
<!-- Our war file contains 1.txt, allows us add 2.txt and verify updates properly -->
<copy file="${war.file1}" tofile="${war.file}"/>
<!-- simple ear that will be updated -->
<ear earfile="${ear.file1}" appxml="${xml.application1}">
<fileset dir="." includes="${text.file1}"/>
<fileset dir="." includes="${war.file}"/>
</ear>
<!-- Backup war, for comparision purposes -->
<move file="${war.file}" tofile="${war.file.backup}" overwrite="true" />
<!-- Extact the war we just added -->
<unzip dest="." src="${ear.file1}" overwrite="true" >
<patternset>
<include name="${war.file}" />
</patternset>
</unzip>
<!-- Update the war by adding a file -->
<war destfile="${war.file}" update="true">
<fileset dir="." includes="${text.file2}"/>
</war>
<!-- Update the ear with our updated war -->
<ear earfile="${ear.file1}" appxml="${xml.application1}" update="true">
<fileset dir="." includes="${war.file}"/>
</ear>
</target>
<target name="main" depends="clean,run"/>