NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

OMG too much information!

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
aybiss



Joined: 05 Mar 2010
Posts: 9

PostPosted: Fri Mar 05, 2010 1:48 pm    Post subject: OMG too much information! Reply with quote

Hi, I've been searching now for about an hour and I still can't find the tiny little piece of syntax I need to launch a command before (or after) a build.

I know there is an ant script (I don't know ant) and yes there's 20 points at which you can run a task and like 10 times as many values you can retrieve from the IDE and ant is the bee's knees and so on...

But can someone just put me out of my misery and paste the XML that runs a program as a pre or post compile action?

I think I'm on the right track with

<target name="-post-compile">
<exec dir="Extensions" executable="javac">
<arg ???/>
</exec>
</target>

...but I don't even know how to tell if this is doing anything at all - where does the output for the build go? More importantly how do I put a simple command line argument string?

I'll also add my vote that something this obvious needs to be something I can edit within the IDE, without hacking up my build.xml myself and potentially stuffing up my whole project. The learning curve is just too steep, leaving users fumbling around with this stuff when they just want to get back to Java coding.

Many thanks in advance for any useful info.
Back to top
Brett M. Bergquist
Posted via mailing list.





PostPosted: Fri Mar 05, 2010 3:22 pm    Post subject: OMG too much information! Reply with quote

A few questions and I should be able to help you:

* What type of project are you building. It does make a difference
as to what type of build step needs to be augmented
* Do you want to run a command before/after a build or before/after
some files are compiles. There is a difference. A Java
application project typically builds a JAR in the "dist"
directory, so do you want the command to be run after this?

Let me know and I will give you a hand.

Brett

aybiss wrote:
Quote:
Hi, I've been searching now for about an hour and I still can't find the tiny little piece of syntax I need to launch a command before (or after) a build.

I know there is an ant script (I don't know ant) and yes there's 20 points at which you can run a task and like 10 times as many values you can retrieve from the IDE and ant is the bee's knees and so on...

But can someone just put me out of my misery and paste the XML that runs a program as a pre or post compile action?

I think I'm on the right track with

<target name="-post-compile">
<exec dir="Extensions" executable="javac">
<arg ???/>
</exec>
</target>

...but I don't even know how to tell if this is doing anything at all - where does the output for the build go? More importantly how do I put a simple command line argument string?

I'll also add my vote that something this obvious needs to be something I can edit within the IDE, without hacking up my build.xml myself and potentially stuffing up my whole project. The learning curve is just too steep, leaving users fumbling around with this stuff when they just want to get back to Java coding.

Many thanks in advance for any useful info.





Back to top
Nan Null
Posted via mailing list.





PostPosted: Sat Mar 06, 2010 2:50 pm    Post subject: OMG too much information! Reply with quote

First, switch to Files tab, right click edit the build.xml file

Before the last entry </project>, add the following:

<target name="-post-compile">
<echo message="----------------------------------------------Hello
world---------------------------------------------------------------"
/>
</target>

Switch back to your project tab and right click on the project and build.

You should see Hello world message in the output window.

Next, your job is to replace the echo message with the real command
that you want to run. Reading your message, it appears you need to
compile some Java code. To find the correct task (don't use exec for
that because it's complicated, although you can), just use javac task.

For reference of core ant tasks, it's here:

http://ant.apache.org/manual/index.html

For the javac task:

http://ant.apache.org/manual/CoreTasks/javac.html

They have a bunch of examples. Here's one for you:

<target name="-post-compile">
<javac srcdir="${src}"
destdir="${basedir}/build/classes"
classpath="<your class path jar goes here>"
debug="on"
source="1.5"
/>
</target>

${basedir}/build/classes" will output it to your build/classes folder
inside your project directory.
${PROPERTY} is a way to extract the value out of a variable named
PROPERTY. Simple like that. A variable or property can be defined
using property tag.

I will figure that will work for a simple case. But when you have 1
or more jars, and 1 or more source directories, then may want to do
this:

<target name="-post-compile">
<javac
destdir="${basedir}/build/classes"
debug="on"
source="1.5"
/>
<classpath >
<pathelement path="${classpath}"/>
<pathelement location="lib/helper.jar"/>
</classpath>
<src path="${src}"/>
<src path="${src2}"/>
</target>

You can also define the classpath somewhere else, and refer to it by
name here. But that is a start. I suggest, next time waste about 10
minutes like I just did, and it would help you greatly.

On Fri, Mar 5, 2010 at 8:48 AM, aybiss <address-removed> wrote:
Quote:
Hi, I've been searching now for about an hour and I still can't find the tiny little piece of syntax I need to launch a command before (or after) a build.

I know there is an ant script (I don't know ant) and yes there's 20 points at which you can run a task and like 10 times as many values you can retrieve from the IDE and ant is the bee's knees and so on...

But can someone just put me out of my misery and paste the XML that runs a program as a pre or post compile action?

I think I'm on the right track with

Back to top
aybiss



Joined: 05 Mar 2010
Posts: 9

PostPosted: Sat Mar 06, 2010 3:03 pm    Post subject: Thanks Reply with quote

Thanks for the replies, I will post again if I need more information.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo