Flutter: Ant : You must not specify nested elements when using refid - flutter

On my flutter project by using junitreport I am making junit report but it is XML,
flutter test --machine | tojunit --output test.xml
Now by Ant, I want to make Html from it. test.xml is at the root of my project, here I made build.xml:
<project name="genTestReport" default="gen" basedir=".">
<description>
Generate the HTML report from JUnit XML files
</description>
<path id="classpath">
<pathelement location="/opt/homebrew/opt/ant/1.10.12/junit/junit-4.13.2.jar"/>
</path>
<target name="gen">
<property name="genReportDir" location="${basedir}/unitTestReports"/>
<delete dir="${genReportDir}"/>
<mkdir dir="${genReportDir}"/>
<junit printsummary="true" showoutput="true" fork="true">
<classpath refid="classpath">
<fileset dir="${basedir}">
<include name="test.xml"/>
</fileset>
</classpath>
<formatter type="xml"/>
</junit>
<junitreport todir="${basedir}/unitTestReports">
<fileset dir="${basedir}" includes="test.xml"/>
<report format="frames" todir="${genReportDir}/html"/>
</junitreport>
</target>
</project>
Now I run this command in root folder:
alt#Alis-MBP rr-front % ant -buildfile build.xml
Buildfile: /Users/alt/Projects/rr-front/build.xml
gen:
[delete] Deleting directory /Users/alt/Projects/rr-front/unitTestReports
[mkdir] Created dir: /Users/alt/Projects/rr-front/unitTestReports
BUILD FAILED
/Users/alt/Projects/RentReady/rr-portal-front/build.xml:13: You must not specify nested elements when using refid
Does it seem I need some configuration ?

The <junit> task is just for running the tests, which you already did outside Ant. So I think you only need the <junitreport> task in this case to convert the xml to html.
The reason for the error is that you put the fileset inside the classpath in the junit task:
<classpath refid="classpath">
<fileset dir="${basedir}">
<include name="test.xml"/>
</fileset>
</classpath>
When you use a refid, as you have in the classpath, you are saying "use this reference to define the classpath". Hence, if you use a refid and define the classpath with nested elements, there is a conflict.

Related

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>

Creating an ant task interleaving .java and .class files in a .jar?

I created the java project in Eclipse with separate src and bin folders. Now I want a .jar which has them combined in the same folder, just like .jardesc does. I created an ant script which looks like this:
<project name="build-jar" default="build-jar" basedir=".">
<target name="build-jar">
<jar destfile="test.jar"
basedir="."
includes="**/*.java **/*.class"
update="true"
/>
</target>
</project>
But this will create a .jar with bin/ and src/ folders. I want the top level folders all to be the actual packages already and the .class files interleaved with the .java files. How can I achieve that?
EDIT: Current non-working, modified version:
<?xml version="1.0" encoding="UTF-8"?>
<project name="build-jar" default="build-jar">
<target name="build-jar">
<jar destfile="test.jar" update="true">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<fileset dir="bin">
<include name="**/*.class"/>
</fileset>
</jar>
</target>
</project>
How about jar up both directories at once using fileset?
<jar destfile="test.jar" update="true">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<fileset dir="bin">
<include name="**/*.class"/>
</fileset>
</jar>

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...

ant eclipse: package org.apache.log4j does not exist

I'm a java-greenhorn trying to compile my project via ant, but nothing's working.
So, in my class I'm using log4j.jar and import junit. Everything's in Eclipse, either Ant.
Here is the build.xml file:
<path id="master-classpath">
<pathelement path="D:\.a lot of folders..\junit.jar"/>
<!--<pathelement path="D:\...\log4j-1.2.17.jar"/> -->
<fileset dir="D:\apache-log4j-1.2.17">
<include name="log4j-1.2.17.jar"/>
</fileset>
<pathelement path="${buildSrc}"/>
</path>
And compile block:
<target name="compile" depends="init">
<javac includeantruntime="false" srcdir="${src1}" destdir="${buildSrc}"/>
<javac includeantruntime="false" srcdir="${src2}" destdir="${buildSrc}"/>
<javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
<classpath refid="master-classpath"/>
</javac>
<javac includeantruntime="false" srcdir="src" destdir="build/classes" classpath="${buildSrc}"/>
</target>
I've also tried some different approaches, like making the same in the javac-task, using property, etc, to no success. Could you please, identify my mistake and help deal with it?
Thanks in advance.
<javac includeantruntime="false" srcdir="${test}" destdir="${buildTest}">
<classpath refid="master-classpath"/>
</javac>
should work. As should "classpathref" as an attribute on javac itself.
Possibilities:
Typo in folder name
Typo in file name
D drive isn't mapped

Could not find wsdlLocation in additional metadatafiles

I have jax-ws web service (jboss implementation) configured with annotation.
#WebService([...], wsdlLocation = "/WEB-INF/wsdl/service.wsdl")
The wsld file is included into war file. The war file is included into ear file, that is deployed on JBoss (version: 5.0.1.GA).
During deployment I receive error message like that:
"Could not find /WEB-INF/wsdl/service.wsdl in the additional metadatafiles!"
I tried to put the file in many places:
- META-INF folder of war file,
- META-INF folder of ear file,
- classpath of war file,
but I it didn't help.
Anyone knows how should I configure it?
i had the same problem and i solved like this:
#WebService(targetNamespace="http://my.app.it/", wsdlLocation = "WEB-INF/wsdl/additional.wsdl")
(WEB-INF not start with slash)
To address this issue, I placed the WSDLs into the jar file that I had created from the generated stubs. Then set the wsdllocation and all was good.
example of my ant target:
<target name="genclients" depends="clean, -createdirs">
<wsimport
fork="true"
xnocompile="true"
wsdl="${src.resource.dir}\${wsdl.name}"
wsdllocation="/resources/${wsdl.name}"
sourcedestdir="${src.generated.dir}"
verbose="true"
destdir="${target.classes.dir}"
keep="true"
extension="true"
debug="true"
package="com.fedex.ship.stub"
xadditionalHeaders="true"
binding="${basedir}/binding.xml"
>
<arg line="-mark-generated"/>
</wsimport>
<javac srcdir="${src.generated.dir}" destdir="${target.classes.dir}" includeantruntime="false" source="1.6" target="1.6" debug="true" deprecation="false" optimize="false" failonerror="true">
<include name="**/*.java"/>
</javac>
<copy todir="${target.classes.dir}" preservelastmodified="true" overwrite="true">
<fileset dir="${src.dir}" >
<include name="**/*.wsdl"/>
<include name="**/*.xsd"/>
</fileset>
</copy>
<pathconvert property="manifest.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<flattenmapper />
</chainedmapper>
</mapper>
<path>
</path>
</pathconvert>
<mkdir dir="${target.classes.dir}/META-INF"/>
<manifest file="${target.classes.dir}/META-INF/manifest.mf">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
<jar jarfile="${target.jar.dir}/${jar.name}" basedir="${target.classes.dir}" manifest="${target.classes.dir}/META-INF/manifest.mf" excludes=".settings,**/.svn"/>
<!--
<delete failonerror="false" includeEmptyDirs="true">
<fileset dir="${target.classes.dir}"/>
</delete>
-->
</target>