Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 22262 invoked from network); 29 Aug 2003 18:02:11 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 29 Aug 2003 18:02:11 -0000 Received: (qmail 72333 invoked by uid 500); 29 Aug 2003 18:01:34 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 72259 invoked by uid 500); 29 Aug 2003 18:01:32 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 72017 invoked from network); 29 Aug 2003 18:01:29 -0000 Received: from unknown (HELO hematita.dcc.ufmg.br) (150.164.10.11) by daedalus.apache.org with SMTP; 29 Aug 2003 18:01:29 -0000 Received: from turmalina.dcc.ufmg.br (turmalina [150.164.10.1]) by hematita.dcc.ufmg.br (8.12.8/8.12.8) with ESMTP id h7TH8Igs009449 for ; Fri, 29 Aug 2003 14:08:19 -0300 (EST) Date: Fri, 29 Aug 2003 14:08:08 -0300 (EST) From: Aloizio Pereira da Silva To: Ant Users List Subject: Re: New Task and Classpath In-Reply-To: <002101c36e37$33d30570$020200c0@DJ0X820J> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N It's good. Now, my new ant class is working. Thanks. ***************************************************** * Federal University of Minas Gerais * * Department of Computer Science * * Master Degree in Computer Science * * * * Aloizio Silva * * http://www.dcc.ufmg.br/~aloizio * * * * Mobile Computer and Network Optimization * ***************************************************** = =20 On Fri, 29 Aug 2003, Antoine Levy-Lambert wrote: > You get your parameters in the main method of IniciarGeracao, in the arra= y > of strings. > Antoine > ----- Original Message ----- > From: "Aloizio Pereira da Silva" > To: "Ant Users List" > Sent: Friday, August 29, 2003 3:43 PM > Subject: Re: New Task and Classpath >=20 >=20 > I created a new class IniciarGeracao() that get the parameters from > TaskGeraRelatorio(). In the execute() method of TaskGeraRelatorio() I pu= t > setClassname("org.apache.tools.ant.taskdefs.IniciarGeracao") > This class is executed, but it could not get the parameters from the > TaskGeraRelatorio() class. I created some public methods into > TaskGeraRelatorio() that return each attribute of the class. But they > does not retun anything. What can be happing? I show the > IniciarGeracao() code below: >=20 > public class IniciarGeracao { >=20 > public IniciarGeracao () > { >=20 > } >=20 > public static void iniciaGeracao() > { > try > { > TaskGeraRelatorio tarefa =3D new TaskGeraRelatorio(); > GerarRelatorio gerador =3D new GerarRelatorio(); > gerador.atribuirDiretorioSaida(tarefa.getDiretorioSaida()); > System.out.println(tarefa.getDiretorioSaida()); > gerador.atribuirArqPrestacao(tarefa.getArqPrestacao()); > gerador.atribuirArqNomeRelatorio(tarefa.getArqNomeRelatorio()); > //obter parmetros do banco > StringTokenizer stBanco =3D new > StringTokenizer(tarefa.getBanco(),",",false); > if(stBanco.countTokens() =3D=3D 2) > { > gerador.atribuirBanco("",stBanco.nextToken().toLowerCase().trim(), > stBanco.nextToken().toLowerCase().trim()); > } > else if(stBanco.countTokens() =3D=3D 3) > { > gerador.atribuirBanco(stBanco.nextToken().toLowerCase().trim(), > stBanco.nextToken().toLowerCase().trim(), > stBanco.nextToken().toLowerCase().trim()); > } >=20 > gerador.atribuirCaminhoBancosInterBase(tarefa.getCaminhoBancosInterBase()= ); > gerador.atribuirVersaoJar(tarefa.getVersaoJar()); > gerador.atribuirUsarID(tarefa.getUsarID()); > gerador.gerarRelatorio(); > }catch (Exception ex) > { > ex.printStackTrace(); > } > } >=20 > public static void main(String[] args) > { > iniciaGeracao(); > } >=20 > } >=20 > ***************************************************** > * Federal University of Minas Gerais * > * Department of Computer Science * > * Master Degree in Computer Science * > * * > * Aloizio Silva * > * http://www.dcc.ufmg.br/~aloizio * > * * > * Mobile Computer and Network Optimization * > ***************************************************** >=20 > On Thu, 28 Aug 2003, [iso-8859-1] Antoine L=E9vy-Lambert wrote: >=20 > > you should move the code of iniciarGeracao to another class, and call t= he > > equivalent of iniciarGeracao in the other class > > public static void main(String [] argv). > > in TaskGeraRelatorio, you should say > > setClassNames("the name of your new class") > > this is the way the java class works, it is made to invoke main methods= =2E > > Cheers, > > Antoine > > ----- Original Message ----- > > From: "Aloizio Pereira da Silva" > > To: "Ant Users List" > > Sent: Thursday, August 28, 2003 11:11 PM > > Subject: Re: New Task and Classpath > > > > > > > Of course, I made what Antoine suggested. I need to instantiate anot= her > > > class from new task code. But when I call iniciarGeracao() I get > > > error. Because the jars files are not found. I display this below: > > > > > > > > > > > > public void execute() throws BuildException > > > { > > > setTaskName(getTaskName()); > > > System.out.println(getTaskName()); > > > setClasspath(createClasspath()); > > > setClassname("org.apache.tools.ant.taskdefs.TaskGeraRelatorio"); > > > createArg().setValue(diretorioSaida); > > > createArg().setValue(arqprestacao); > > > createArg().setValue(arqNomeRelatorio); > > > createArg().setValue(banco); > > > createArg().setValue(caminhoBancosInterBase); > > > createArg().setValue(versaoJar); > > > createArg().setValue(usarID); > > > setFork(true); > > > super.execute(); > > > try > > > { > > > iniciarGeracao(); > > > } > > > catch (Exception ex) > > > { > > > ex.printStackTrace(); > > > } > > > } > > > > > > public void iniciarGeracao() > > > { > > > try > > > { > > > GerarRelatorio gerador =3D new GerarRelatorio(); > > > gerador.atribuirDiretorioSaida(diretorioSaida); > > > gerador.atribuirArqPrestacao(arqprestacao); > > > gerador.atribuirArqNomeRelatorio(arqNomeRelatorio); > > > //obter parmetros do banco > > > StringTokenizer stBanco =3D new StringTokenizer(banco,",",false); > > > if(stBanco.countTokens() =3D=3D 2) > > > { > > > > gerador.atribuirBanco("",stBanco.nextToken().toLowerCase().trim(), > > > stBanco.nextToken().toLowerCase().trim()); > > > } > > > else if(stBanco.countTokens() =3D=3D 3) > > > { > > > gerador.atribuirBanco(stBanco.nextToken().toLowerCase().trim(), > > > stBanco.nextToken().toLowerCase().trim(), > > > stBanco.nextToken().toLowerCase().trim()); > > > } > > > gerador.atribuirCaminhoBancosInterBase(caminhoBancosInterBase); > > > gerador.atribuirVersaoJar(versaoJar); > > > gerador.atribuirUsarID(usarID); > > > gerador.gerarRelatorio(); > > > }catch (Exception ex) > > > { > > > ex.printStackTrace(); > > > } > > > } > > > > > > ***************************************************** > > > * Federal University of Minas Gerais * > > > * Department of Computer Science * > > > * Master Degree in Computer Science * > > > * * > > > * Aloizio Silva * > > > * http://www.dcc.ufmg.br/~aloizio * > > > * * > > > * Mobile Computer and Network Optimization * > > > ***************************************************** > > > > > > On Thu, 28 Aug 2003, Matt Benson wrote: > > > > > > > You have not set the classpath. Your code is > > > > instantiating a new task, then setting its > > > > classpath to the value returned by createClasspath(), > > > > which is a new (and empty) Path. Your code should not > > > > be nearly as big as it is to be extending the Java > > > > task. Carefully read what Antoine has suggested, > > > > which is what I had suggested. Your code should > > > > really consist of not much more than a constructor and > > > > settors for any attributes you may need specific to > > > > the Java class you want to call. Unless there is > > > > something really special happening it sounds like you > > > > could do what you want without coding Java at all, > > > > just do it all in the xml file with a properly > > > > configured task. > > > > > > > > -Matt > > > > > > > > --- Aloizio Pereira da Silva > > > > wrote: > > > > > I used org.apache.tools.ant.taskdefs because I > > > > > intend to put this task > > > > > like standard ant task. But this is not a problem. > > > > > > > > > > The problem is I call a java class into the new ant > > > > > task. If you look the > > > > > execute() method it call iniciarGeracao() that > > > > > instantiate > > > > > GeradorRelatorio() class. In this case, during the > > > > > execution the jars > > > > > files is not found. In spite of I have set the > > > > > classpath. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ***************************************************** > > > > > * Federal University of Minas > > > > > Gerais * > > > > > * Department of Computer > > > > > Science * > > > > > * Master Degree in Computer > > > > > Science * > > > > > * > > > > > * > > > > > * Aloizio Silva > > > > > * > > > > > * > > > > > http://www.dcc.ufmg.br/~aloizio * > > > > > * > > > > > * > > > > > * Mobile Computer and Network > > > > > Optimization * > > > > > > > > > > > > > > ***************************************************** > > > > > > > > > > > > > > > On Thu, 28 Aug 2003, Antoine Levy-Lambert wrote: > > > > > > > > > > > 1)the package name of your class does not need to > > > > > be and should not be > > > > > > org.apache.tools.ant.taskdefs, > > > > > > rather should belong to your company's package > > > > > structure > > > > > > > > > > > > 2) I notice that your class extends the Java task > > > > > of ant, this is fine. > > > > > > In this case you do not need to override methods > > > > > which stay the same such as > > > > > > CreateClasspath. > > > > > > You can rewrite your execute method more simply : > > > > > > > > > > > > setTaskName("TaskGeraRelatorio"); > > > > > > createArg().setValue(diretorioSaida); > > > > > > createArg().setValue(arqprestacao); > > > > > > createArg().setValue(arqNomeRelatorio); > > > > > > createArg().setValue(banco); > > > > > > createArg().setValue(caminhoBancosInterBase); > > > > > > createArg().setValue(versaoJar); > > > > > > createArg().setValue(usarID); > > > > > > setFork(true); > > > > > > super.execute(); > > > > > > > > > > > > > > > > > > Antoine > > > > > > ----- Original Message ----- > > > > > > From: "Aloizio Pereira da Silva" > > > > > > > > > > > To: "Ant Users List" > > > > > > Sent: Thursday, August 28, 2003 8:33 PM > > > > > > Subject: Re: New Task and Classpath > > > > > > > > > > > > > > > > > > > > > > > > > > This did not work. I am sending attached files > > > > > If anyone could help me. > > > > > > > build.xml e new ant task java class. > > > > > > > > > > > > > > thanks. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ***************************************************** > > > > > > > * Federal University of > > > > > Minas Gerais * > > > > > > > * Department of Computer > > > > > Science * > > > > > > > * Master Degree in Computer > > > > > Science * > > > > > > > * > > > > > * > > > > > > > * Aloizio Silva > > > > > * > > > > > > > * > > > > > http://www.dcc.ufmg.br/~aloizio * > > > > > > > * > > > > > * > > > > > > > * Mobile Computer and Network > > > > > Optimization * > > > > > > > > > > > > > > > > ***************************************************** > > > > > > > > > > > > > > On Thu, 28 Aug 2003, Antoine Levy-Lambert wrote: > > > > > > > > > > > > > > > You should set in the classpath that you > > > > > define in build.xml your new > > > > > > task > > > > > > > > and all its dependencies. > > > > > > > > Also none of these should be in the CLASSPATH > > > > > environment variable > > > > > > before > > > > > > > > you start ant. > > > > > > > > If this does not help, can you post your > > > > > build.xml > > > > > > > > Antoine > > > > > > > > ----- Original Message ----- > > > > > > > > From: "Aloizio Pereira da Silva" > > > > > > > > > > > > > To: "Ant Users List" > > > > > > > > Sent: Thursday, August 28, 2003 6:59 PM > > > > > > > > Subject: Re: New Task and Classpath > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I made what you suggested. But, my ant task > > > > > java class has a call for > > > > > > > > > another java class that use some libraries. > > > > > And I set this libraries > > > > > > > > > in Build.xml. Then I get the following > > > > > error: > > > > > > > > > > > > > > > > > > Why the setting classpath does not remain to > > > > > the another java class? > > > > > > > > > BUILD FAILED > > > > > > > > > java.lang.NoClassDefFoundError: > > > > > > > > > > > > > synergia/persistencia/principal/ExcecaoPersisten > > > > > > > > > cia at > > > > > > > > > > > > > > > > > > org.apache.tools.ant.taskdefs.TaskGeraRelatorio.iniciarGeracao(Unkn= ow > > > > > > > > > n Source) at > > > > > > > > > > > > > > > > > > org.apache.tools.ant.taskdefs.TaskGeraRelatorio.execute(Unknown > > > > > > > > > Source) > > > > > > > > > > > > > > > > > > > > > > > > > > > ***************************************************** > > > > > > > > > * Federal University of > > > > > Minas Gerais * > > > > > > > > > * Department of > > > > > Computer Science * > > > > > > > > > * Master Degree in > > > > > Computer Science * > > > > > > > > > * > > > > > * > > > > > > > > > * Aloizio Silva > > > > > * > > > > > > > > > * > > > > > http://www.dcc.ufmg.br/~aloizio * > > > > > > > > > * > > > > > * > > > > > > > > > * Mobile Computer and > > > > > Network Optimization * > > > > > > > > > > > > > > > > > > ***************************************************** > > > > > > > > > > > > > > > > > > On 28 Aug 2003, Stefan Bodewig wrote: > > > > > > > > > > > > > > > > > > > On Wed, 27 Aug 2003, Aloizio Pereira da > > > > > Silva > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > messages: [gerar_relatorio] > > > > > java.lang.NoClassDefFoundError: > > > > > > > > > > > org/apache/tools/ant/Task > > > > > > > > > > > > > > > > > > > > You need to add ant.jar to the > > > > > explicitly (or do that > > > > > > > > > > inside of execute() as the task > > > > > that you use internally tries > > > > > > > > > > to keep the environment clean of Ant's own > > > > > classes. > > > > > > > > > > > > > > > > > > > > Stefan > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------= -- > > > > > > > > > > To unsubscribe, e-mail: > > > > > user-unsubscribe@ant.apache.org > > > > > > > > > > For additional commands, e-mail: > > > > > user-help@ant.apache.org > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -------------------------------------------------------------------= -- > > > > > > > > > To unsubscribe, e-mail: > > > > > user-unsubscribe@ant.apache.org > > > > > > > > > =3D=3D=3D message truncated =3D=3D=3D > > > > > > > > > > > > __________________________________ > > > > Do you Yahoo!? > > > > Yahoo! SiteBuilder - Free, easy-to-use web site design software > > > > http://sitebuilder.yahoo.com > > > > > > > > -------------------------------------------------------------------= -- > > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > > > For additional commands, e-mail: user-help@ant.apache.org > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > > For additional commands, e-mail: user-help@ant.apache.org > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > > For additional commands, e-mail: user-help@ant.apache.org > > > > >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org >=20 >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org >=20 >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org