I've recently been experimenting with an ANT script for setting up a small application (with various paths and other variables) using AntForm. AntForm has a file selector, but I would have to write something custom to validate the path (i.e., make sure it is the path to the thing that I asked the user for). I was wondering if anyone had experience with using using AntForm in this way. What I want is something like a Wizard page with a file selector, and when the user clicks "next" or when the file is selected some sort of a validation task is executed, and the wizard proceeds from there. The absolute best would be if I could gray out the "next" button or add an "invalid path" message, but that's getting a little complicated for what it seems that AntForm was designed for. Below is an example XML file to get started. Note that it expects AntForm.jar to be in the ./bin directory.
<?xml version="1.0"?>
<project name="My App Setup" default="getPath" basedir=".">
<property name="app.dir" value="${user.home}/appXYZ"/>
<path id="runtime.cp">
<pathelement location="bin/"/>
<fileset dir="lib" includes="antform.jar"/>
</path>
<taskdef name="antform" classname="com.sardak.antform.AntForm"
classpathref="runtime.cp"/>
<taskdef name="antmenu" classname="com.sardak.antform.AntMenu"
classpathref="runtime.cp"/>
<!-- test wizard behaviour, step 1 -->
<target name="getPath"
description="Check for App XYZ in path">
<antform title="Choose directory of app xyz"
lookAndFeel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
okMessage="Next"
nextTarget="wizard2"
>
<fileSelectionProperty
label="App XYZ Distribution"
property="app.dir"
directoryChooser="true" />
<!-- TODO: how to validate and choose where to go from this form? -->
</antform>
</target>
<!-- test wizard behaviour, step 1 -->
<target name="wizard2"
description="continue setup">
<antform title="did we validate?"
lookAndFeel="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
okMessage="Finish"
previousTarget="getPath"
>
<label>Did we validate the path before we got here?</label>
</antform>
</target>
</project>
Related
I'm trying to get Jasper Reports working from my app in VB.Net. So, after considering many options, I decided to create a small program in java to launch it, and reference it in my .Net project, using JNI4NET.
I don't know if I'm doing something wrong, but, when I launch the proxygen tool, it gives me a "OK/Completed" message, it creates two directories, java and csharp, with two files that I think are the two proxies.
The problem comes when I follow the Wiki instructions(https://github.com/jni4net/jni4net/wiki/Generating-Proxies) and there says that it should be a "build.cmd" file that creates the dll that will be included later in my project. I don't have that file. What am I missing?
I launched the proxy with the command line .\proxygen.exe ProxyGenJasperTest.xml, being the xml:
<?xml version="1.0" encoding="utf-8" ?>
<jni4net-proxygen xmlns="http://jni4net.sf.net/0.8.8.0/toolConfig.xsd">
<!-- Location where .java files will be generated into. It's relative or absolute path. -->
<TargetDirJvm>java</TargetDirJvm>
<!-- Location where .cs files will be generated into. It's relative or absolute path. -->
<TargetDirClr>csharp</TargetDirClr>
<!-- List of class paths (.jar files or directories) which define known classes for generator-->
<ClassPath Path="lib/com.springsource.com.informix.jdbc-3.0.0.JC3.jar"/>
<ClassPath Path="lib/commons-beanutils-1.9.2.jar"/>
<ClassPath Path="lib/commons-collections-3.2.2.jar"/>
<ClassPath Path="lib/commons-digester-2.1.jar"/>
<ClassPath Path="lib/commons-logging-1.2.jar"/>
<ClassPath Path="lib/ecj-4.3.1.jar"/>
<ClassPath Path="lib/groovy-all-2.4.5.jar"/>
<ClassPath Path="lib/itext-2.1.7.jar"/>
<ClassPath Path="lib/jasperreports-6.2.2.jar"/>
<ClassPath Path="lib/jasperreports-fonts-6.2.2.jar"/>
<ClassPath Path="lib/jasperreports-functions-6.2.2.jar"/>
<ClassPath Path="lib/jasperreports-javaflow-6.2.2"/>
<ClassPath Path="lib/joda-time-2.4.jar"/>
<ClassPath Path="lib/ojdbc6.jar"/>
<ClassPath Path="JasperTest.jar"/>
<!-- List of Java classes which should have proxy generated -->
<JavaClass TypeName="jaspertest.JasperTest"/>
</jni4net-proxygen>
XML vilely stolen from samples and changed.
Any help? Thanks.
I have jar file having some properties files in it like log4j.properties and config.properties. Following is my ant script for yguard. Everything else is working but the properties file updation.
<target name="yguard">
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="lib/yguard.jar" />
<yguard>
<inoutpairs resources="none">
<fileset dir="${basedir}">
<include name="MyApp.jar" />
</fileset>
<mapper type="glob" from="MyApp.jar" to="MyAppObs.jar" />
</inoutpairs>
<externalclasses>
<pathelement location="lib/log4j-1.2.17.jar" />
</externalclasses>
<rename conservemanifest="true" mainclass="com.amit.Application" >
<adjust replaceContent="true" >
<include name="**/*.properties" />
</adjust>
</rename>
</yguard>
</target>
config.properties file
com.amit.Application.param1 = something
I found some question in stackoverflow but they didn't help. One place it was mentioned that the file (like jsp, xml, properties) should be in the jar file which I already have. But my yguard obfuscated file just get the files copied as it is.
I tried many combinations with rename & adjust tags but nothing worked for me.
Following post I already visited
Is it possible to manage logs through Obfuscation with yGuard?
How to include obfuscated jar file into a war file
Apparently you want yGuard to obfuscate the name of the field param1, because com.amit.Application is obviously your entry point and yGuard excludes the given main class automatically. So basically you want the outcome to be something like
com.amit.Application.AÖÜF = something
This isn't possible, because yGuard can only adjust class names in property files, as state here: yGuard Manual
I am new to JaCoCo and trying to figure out why the html report that I am generating is not linked with my source.
The coverage numbers look correct and I can browse down to each class and then each method but I can not see the source. I have tried many different things inside the sourcefiles tag but nothing is working. Has anyone else had this issue? Here is a snippet of my ant script:
...
<test name="test.fw.UITestSuite" todir="${logdir}"/>
</junit>
</jacoco:coverage>
<fail if="TestFailed" status="1" message="UI junit test failure detected"/>
<echo message="${src}"/>
<jacoco:report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="UI">
<classfiles>
<fileset dir="${build}/fw"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="fw" includes="**./*.java"/>
</sourcefiles>
</structure>
<html destdir="report"/>
</jacoco:report>
</target>
...
Your fileset definition seems odd.
The include must be (the first . is misplaced):
includes="**/*.java
Try simply pointing it to the root of your src dir (there is no need for the includes)
<fileset dir="fw" />
But fw has to be the root of your sources, i.e. it contains the package folders like:
src
-org
-module
-MyClass1.java
-MyClass2.java
I’ve seen this break when using Scala-style package directory names, e.g.,
src/main/java/com.example.foo.bar/Foo.java
for fewer levels of nesting, faster autocompletion, &c., compared to the standard
src/main/java/com/example/foo/bar/Foo.java
Most tools support the first version just fine, but usually if you try it out and everything works fine, by the time you notice something like the jacoco reports not showing the source anymore, you’ve long forgotten the directory name change …
I am using the ant task <record> to create a log file of the output and activity of my ant build script. The problem is:
i am not seeing the names of the targets that are being executed.
For instance: When my target called cleanFW is being executed, i only see the stuff being done inside the target and NOT the name of the target it self. Since this is happening, i have no way of telling when cleanFW began in the log file.
Is there a way to get this cleanFW target name to appear? It was appearing when i was using the flag -logfile. But i had to switch to <record> because i want to record log file and see the output in console.
Using Ant 1.8.2
simple solution
My simple solution to this is to just put an echo in each one of the targets. Just wondering if there was a better way.
sample code where it is not working
<project name="foobar">
<record name="test.txt" action="start" append="true" loglevel="verbose" />
... lots of property stuff here ...
<target name="cleanFW">
<record name="test.txtaction="start" append="true" loglevel="verbose"/>
<mkdir dir="${FOOBAR_OUTPUT}"/>
<mkdir dir="${FOOBAR_GEN}"/>
<delete includeemptydirs="true">
<fileset dir="${FOOBAR_BIN}" includes="**/*"/>
<fileset dir="${FOOBAR_GENERATED}" includes="**/*"/>
<fileset dir="${FOOBAR_NODES}" includes="**/*"/>
<fileset dir="${FOOBAR_GEN}" includes="**/*"/>
</delete>
<mkdir dir="${FOOBAR_OUTPUT}"/>
<record name="test.txt" action="stop"/>
</target>
<record name="test.txt" action="stop"/>
</project>
The reason why i have the first record name="test.txt" action="start" append="true" loglevel="verbose" /> at the top, is because i want all of the statements and stuff that are before the targets to be displayed too. Like my property sets and all that jazz. I left that junk out because it is not important.
I'm at a bit of a loss to explain why exactly, but I think you need to omit the last record 'stop' task - the one that is outside of a target.
Having said that, you can probably omit all of the record tasks except the first 'start', and get the result you want.
It sounds a little far fetched to me, but is there an ANT task for watching a directory for changes and then running a particular ANT class when the directory changes?
If files can only be added to or changed in the watched directory, then you can use this simple OutOfDate task from antcontrib.
<property name="watched-dir.flagfile"
location="MUST be not in watched dir"/>
<outofdate>
<sourcefiles>
<fileset dir="watched-dir"/>
</sourcefiles>
<targetfiles>
<pathelement location="${watched-dir.flagfile}"/>
</targetfiles>
<sequential>
<!--Tasks when something changes go here-->
<touch file="${watched-dir.flagfile}"/>
</sequential>
</outofdate>
If files can disappear from the watched-dir, then you have more complicated problem, that you can solve by creating shadow directory structure of the watched dir and checking if its consistent with the watched-dir. This task is more complex, but I'll give you a script to create a shadow directory, as it is not straight forward:
<property name="TALK" value="true"/>
<property name="shadow-dir"
location="MUST be not in watched dir"/>
<touch
mkdirs="true"
verbose="${TALK}"
>
<fileset dir="watched-dir">
<patterns/>
<type type="file"/>
</fileset>
<!-- That's the tricky globmapper to make touch task work -->
<globmapper from="*" to="${shadow-dir}/*"/>
</touch>
<!--
Due to how touch task with mapped fileset is implemented, it
truncates file access times down to a milliseconds, so if you
would have used outofdate task on shadow dir it would always
show that something is out of date.
Because of that, touching all files in ${shadow-dir} again fixes
that chicken and egg problem.
-->
<touch verbose="${TALK}">
<fileset dir="${shadow-dir}"/>
</touch>
With shadow directory created, I'll leave the task of checking directory consistency as an exercise for the reader.
Yes there is an Ant Task that will do this:
https://github.com/chubbard/WatchTask
It requires 1.7+. It can watch any number of filesets, and invoke any target depending on which fileset it came from.
You might be able to use the Waitfor task to achieve what you want. It blocks until one or more conditions (such as the presence of a particular file) become true.
You can combine the apply task with a fileset selector
<apply executable="somecommand" parallel="false">
<srcfile/>
<fileset dir="${watch.dir}">
<modified/>
</fileset>
</apply>
The fileset will check the files against a stored MD5 checksum for changes. You'll need to put ANT into a loop in order to repeatedly run this check. this is easy to do in Unix:
while true
> do
> ant
> sleep 300
> done