I could implement a "suppress system property"
(ant.suppress.toolsjar.warning).
But I am not convinced of that idea ...

What do the other committers think of that?


Jan

> -----Ursprüngliche Nachricht-----
> Von: David J. B. Hollis [mailto:dhol...@aandoconsultancy.ltd.uk]
> Gesendet: Dienstag, 28. April 2015 09:32
> An: Ant Users List
> Betreff: Re: tools.jar not found
> 
> Hi Jan,
> 
> The DITA Open Toolkit uses ANT to build docs. This is a question that
> comes up occasionally on the DITA Users forum.
> 
> A number of document CMS products use the DITA Open Toolkit, so a large
> number of Technical Authors can potentially see this message.
> 
> If it could be suppressed, I'm sure a lot of folks would be highly
> delighted.
> 
> Many thanks,
> David
> 
> 
> > I thought using a custom Logger could solve your problem.
> > That logger would simply supress special messages.
> >
> > But after failing tests I searched for that message:
> > Locator.getToolsJar() prints directly to SYSO:
> >
> >   public static File getToolsJar() {
> >       ... try to find tools.jar
> >        if (!toolsJar.exists()) {
> >            System.out.println("Unable to locate tools.jar. "
> >                 + "Expected to find it in " + toolsJar.getPath());
> >            return null;
> >        }
> >
> > This method is called by the Launcher very early in the startup
> process, where all logging goes directly to STDOUT because the logging
> framework is not initialized yet.
> >
> >
> > With that finding these possibilities come to my mind:
> > - pimp your Ant: overwrite the Locator class (copy and delete all
> syso-logs) and place that before the Ant jars.
> > - filter STDOUT: instead using an AntLogger doing the filtering, you
> have to do it somewhere else between Ant and your tool.
> > - enhance Ant: we introduce an additional if statement which
> evaluates System properties (e.g. "ant -Dsuppress-tools-warning=true")
> >        if (!toolsJar.exists()) {
> >            if (!aVerySpecialSystemPropertyIsSet()) {
> >                System.out.println("Unable to locate tools.jar. "
> >                     + "Expected to find it in " +
> toolsJar.getPath());
> >            }
> >            return null;
> >        }
> >
> >
> >
> > Jan
> >
> >
> >
> >
> >
> >
> >
> > import org.apache.tools.ant.*;
> >
> > public class NoToolsWarningLogger extends DefaultLogger {
> >
> >    public static final String IGNORE_MSG_PATTERN = "Unable to locate
> > tools.jar.";
> >
> >    public void messageLogged(BuildEvent event) {
> >        String msg = event.getMessage();
> >        if (!msg.contains(IGNORE_MSG_PATTERN)) {
> >            super.messageLogged(event);
> >        } else {
> >            System.out.println("tools-message suppressed");
> >        }
> >    }
> >
> > }
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Earl Hood [mailto:earlh...@gmail.com]
> >> Gesendet: Dienstag, 28. April 2015 07:38
> >> An: Ant Users List
> >> Betreff: Re: tools.jar not found
> >>
> >> On Tue, Apr 28, 2015 at 12:12 AM, Jan Matèrne (jhm) wrote:
> >>
> >>> Ant is a build tool. For some tasks (for example javac, javadoc)
> the
> >>> tools from the Java _Development_ Kit are required.
> >>> If you run with just a Java _Runtime_ Environment most of its tasks
> >>> could be used, but not all - hence the warning.
> >>
> >> It would be really nice if that warning can be suppressed.
> >>
> >> I work on a project where Ant is used (under-the-hood), but only the
> >> JRE is required.  Ant tasks used do not require the JDK.  We have to
> >> include in the user documentation that the "tools.jar" message can
> be
> >> ignored, but we still on occassion get a user asking about it.
> >>
> >> --ewh
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional
> commands, e-mail: user-h...@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to