In my build.xml I have declared
taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask"
and I get the blessed error
The solution could simply be adding a "classpath" element to the taskdef:
taskdef classpath="${bea.home}/wlserver_10.3/server/lib/weblogic.jar" name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask"
In fact taskdef uses the same attributes as typedef
http://ant.apache.org/manual/Tasks/typedef.html
Showing posts with label ant. Show all posts
Showing posts with label ant. Show all posts
Tuesday, November 1, 2011
Wednesday, August 3, 2011
Ant, Junit and the forked JVM
I have a classpath defined as:
<path id="classpath.test">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement location="/path/to/user_projects/domains/acme_osb/config/osb/"/>
</path>
I can trace it this way:
<echo message="${toString:classpath.test}"/>
and I use it in a junit task
<junit printsummary="true">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false"/>
<test name="com.acme.gu.ft.GUFT" outfile="junitout/GUFT">
<formatter type="xml"/>
</test>
</junit>
The alarming thing is that the Unit test is run NOT with the classpath I specify (classpath.test), but with the classpath being used to run ant.
I can trace it with System.getProperty("java.class.path")
The only way to run the Unit Test with the new Classpath is by specifying fork="on"
<junit printsummary="true" fork="on">
one hour wasted for this....
<path id="classpath.test">
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<pathelement location="/path/to/user_projects/domains/acme_osb/config/osb/"/>
</path>
I can trace it this way:
<echo message="${toString:classpath.test}"/>
and I use it in a junit task
<junit printsummary="true">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false"/>
<test name="com.acme.gu.ft.GUFT" outfile="junitout/GUFT">
<formatter type="xml"/>
</test>
</junit>
The alarming thing is that the Unit test is run NOT with the classpath I specify (classpath.test), but with the classpath being used to run ant.
I can trace it with System.getProperty("java.class.path")
The only way to run the Unit Test with the new Classpath is by specifying fork="on"
<junit printsummary="true" fork="on">
one hour wasted for this....
Sunday, February 28, 2010
Hudson and Ant
Ever tried to run unit tests from Ant inside Hudson, and gotten the infamous:
Could not create task or type of type: junit
?
There is a (pathetic, just like everything concerning Ant technology) workaround:
add
-lib /weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar
before the list of targets you want to be run.
YAPPOS ! (yet another pathetic piece of shit)
ALSO, don't forget to set your Java Otions to:
-DLOCALCLASSPATH=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar
No wonder why people are migrating to .NET....
simple lack of any standardization in Java, everything turns into a complete hack.
Thursday, February 25, 2010
Profiling a Ant build by logging with Log4J
You would think it's an easy task to profile your build, but Ant authors simply neglected this feature.
In order to timestamp each step, do this way:
1) create a log4j.properties file and put it in the classpath:
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=DEBUG, CONSOLE
#log4j.rootCategory=DEBUG, CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.tools.ant=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
2) add to the classpath the log4j.jar file
3) run:
set ANT_OPTS=-Dlog4j.debug -Dlog4j.configuration=file:./log4j.properties
ant -listener org.apache.tools.ant.listener.Log4jListener -verbose -buildfile mybuild.xml build
Terrible, eh?
In order to timestamp each step, do this way:
1) create a log4j.properties file and put it in the classpath:
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=DEBUG, CONSOLE
#log4j.rootCategory=DEBUG, CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.tools.ant=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
2) add to the classpath the log4j.jar file
3) run:
set ANT_OPTS=-Dlog4j.debug -Dlog4j.configuration=file:./log4j.properties
ant -listener org.apache.tools.ant.listener.Log4jListener -verbose -buildfile mybuild.xml build
Terrible, eh?
Labels:
ant
Sunday, February 21, 2010
junit.framework.AssertionFailedError: No tests found in BLA
most likely you forgot to set ANT_HOME to the right value... I am using JUnit4, so I want to use the latest version of Ant:
export ANT_HOME=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.apache.ant_1.7.0.v200706080842
ant -verbose
and remember to set
export CLASSPATH=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar
Ant is a piece of crap, JUnit even more so. Why should a man struggle so much to run Unit Tests.
export ANT_HOME=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.apache.ant_1.7.0.v200706080842
ant -verbose
and remember to set
export CLASSPATH=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar
Ant is a piece of crap, JUnit even more so. Why should a man struggle so much to run Unit Tests.
Friday, May 22, 2009
Beanshell and Ant
forget about doing anything fancy in Ant.
you MUST use:
- if and foreach tasks from ant/contrib project
- beanshell for scripting
From beanshell, you can set a Ant property by doing:
antProjectName.setProperty("myproperty", myvalue);
With these tools, you MIGHT have some chance of getting anything done with Ant. Still, I believe all this is really pathetic, we are in 2009 and we are using pre-WWII technologies.
you MUST use:
- if and foreach tasks from ant/contrib project
- beanshell for scripting
From beanshell, you can set a Ant property by doing:
antProjectName.setProperty("myproperty", myvalue);
With these tools, you MIGHT have some chance of getting anything done with Ant. Still, I believe all this is really pathetic, we are in 2009 and we are using pre-WWII technologies.
Labels:
ant
Wednesday, May 13, 2009
Ant sucks
big time.
Whoever thinks of accomplishing anything non-trivial with Ant is victim of a self-delusion.
Ant contains no easy way to manipulate typed variables,
no flow control mechanisms
no nothing.
It's distilled pain.
You can easily do the same things in Java, with a lot more reusability, debugging, ease of integration of external frameworks....
XML is not meant to write code, it's meant to represent STATIC DATA. If you code in XML, you might as well wash your clothes in a grinder.
Ant SUCKS!
Whoever thinks of accomplishing anything non-trivial with Ant is victim of a self-delusion.
Ant contains no easy way to manipulate typed variables,
no flow control mechanisms
no nothing.
It's distilled pain.
You can easily do the same things in Java, with a lot more reusability, debugging, ease of integration of external frameworks....
XML is not meant to write code, it's meant to represent STATIC DATA. If you code in XML, you might as well wash your clothes in a grinder.
Ant SUCKS!
Labels:
ant
Saturday, February 14, 2009
Running Ant tasks from Java
let's face it, Ant is great but it's a pain in the butt when it comes to writing complex code, with variables, loops, conditions etc.
That's why I love the idea of running Ant tasks directly from Java.
Here is how.
The trick is to bear in mind the Ant object model: A Project contains Targets, a Target contains Tasks. A Task can't run without a Project, otherwise you get a NPE (my compliments to Ant developers for handling so gracefully this exception :o) ).
Of course you can build a "Ant Wrapper" framework on top of this paradygm...
package com.pierre.ant;
import java.io.File;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.taskdefs.Copy;
public class AntRunner {
public static void main(String[] args) {
AntRunner runner = new AntRunner();
runner.scp();
}
/**
Copy file from a to b, locally
*/
public void scp() {
Project project = new Project();
Target target = new Target();
project.addTarget("ciao", target);
Copy scp = new Copy();
scp.setFile(new File("c:/tmp/vacations.xsd"));
scp.setTodir(new File("c:/temp"));
scp.setProject(project);
target.addTask(scp);
target.execute();
}
}
Labels:
ant
Subscribe to:
Posts (Atom)