ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <sflo...@nc.rr.com>
Subject Re: Ant illegalArgumentException while trying to build automatic translations ("build-lang")
Date Mon, 05 Jan 2015 20:09:49 GMT
Ya know it looks like you need to hand in literals like "-Dlang.dir=some/dir"

So your ant script probably needs this 'kind of' thing:

<param value="-Dlang.dir=some/dir"/>

Obviously replace qith variables and apppropriate values like this kind of thing:

<param value="-Dlang.dir=${dir}"/>




Sincerely,

Scot P. Floess

Sent from my Verizon Wireless 4G LTE Smartphone

<div>-------- Original message --------</div><div>From: Tanguy Thomas <tanguy.thomas@gmail.com>
</div><div>Date:01/04/2015  1:59 PM  (GMT-05:00) </div><div>To: sfloess@nc.rr.com
</div><div>Cc: Ant Users List <user@ant.apache.org> </div><div>Subject:
Re: Ant illegalArgumentException while trying to build automatic translations ("build-lang")
</div><div>
</div>Hi, thanks a lot for your feedback. I tried to use ${file.separator} as
separator, but it unfortunately did not solve the issue. What you explained
however helps me to move a bit forward, I know it's not this / vs \ isse at
least. I tried both methods, but ended up with the same
illegalArgumentException.

The code you found is the one being called indeed (it just seems to be
version 6.1.0 used here):
http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-impl/6.1.0/com/liferay/portal/tools/LangBuilder.java/

This is coming with LiferayPortal CE 6.1 (I checked however if they updated
/ corrected anything there, but it seems newer versions (6.2 etc) have
exactly the same code:

public static void main(String[] args) {
   Map<String, String> arguments = ArgumentsUtil.parseArguments(args);
   System.setProperty("line.separator", StringPool.NEW_LINE);
   InitUtil.initWithSpring();
   String langDir = arguments.get("lang.dir");
   String langFile = arguments.get("lang.file");
   boolean langPlugin = GetterUtil.getBoolean(
    arguments.get("lang.plugin"));
   boolean langTranslate = GetterUtil.getBoolean(
    arguments.get("lang.translate"), true);
   try {
    new LangBuilder(langDir, langFile, langPlugin, langTranslate);
   }
   catch (Exception e) {
    e.printStackTrace();
   }
  }

The very first line seems to be throwing the exception :
ArgumentsUtil.parseArguments(args);
http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-impl/6.1.0/com/liferay/portal/tools/ArgumentsUtil.java

public static Map<String, String> parseArguments(String[] args) {
  Map<String, String> arguments = new ArgumentsMap();
  for (String arg : args) {
   int pos = arg.indexOf('=');
   if (pos <= 0) {
    throw new IllegalArgumentException("Bad argument " + arg);
   }
   String key = arg.substring(0, pos).trim();
   String value = arg.substring(pos + 1).trim();
   if (key.startsWith("-D")) {
    key = key.substring(2);
    System.setProperty(key, value);
   }
   else {
    arguments.put(key, value);
   }
  }
  return arguments;
}

I indeed get this exact error message "Bad Argument " and then the folder I
passed, no matter if I use /, \ or the  ${file.separator}.

So it seems it's searching for a "=" sign but according to the
documentation, I am just supposed to put a directory name there.

I tried to start the argument with -D=(then my path) but it crashed, so I
tried to add some stuff after like -DIR=(then my path) (I could have put
-Dinosaur etc.) it seems and then it passed but crashed at the next
argument for same reason. It seems actually that Liferay changed the
translation system from Babelfish to Bing and that parameters changed. My
book (Liferay in Action) is still based on these parameters from before
this change, and I guess they added this "=" stuff afterwards.

So it's a Liferay issue, I could go till the end of this thanks to your
help, I was supposing the issue was coming from these / and \ problem.

Thanks a lot for your help



On Sat, Jan 3, 2015 at 3:56 PM, <sfloess@nc.rr.com> wrote:

> Tanguy,
>
> I am completely unfamiliar with this package you are calling.
>
> But it looks like you are on a Windows machine and my guess is, the param
> you are handing in for the directory is being presented literally to the
> application - which is likely attempting to escape the characters vs
> utilizing them as directory separators.
>
> You may want to try this to see if it gets you passed your
> IllegalArgumentException:  simply use ${file.separator} vs the forward
> slash.  Something like this:
>
> <project name="product-registration-TT-portlet" basedir="."
> default="deploy">
>     <import file="../build-common-portlet.xml" />
>     <target name="build-lang">
>         <antcall target="build-lang-cmd">
>             <param name="lang.dir"
> value="docroot${file.separator}WEB-INF${file.separator}src${file.separator}content"
> />
>             <param name="lang.file" value="Language" />
>             <param name="lang.translate" value="true" />
>         </antcall>
>     target>
> </project>
>
> Or if you don't like that you can store as a property:
>
> <project name="product-registration-TT-portlet" basedir="."
> default="deploy">
>     <import file="../build-common-portlet.xml" />
>     <target name="build-lang">
>         <property name="DIR"
> value="docroot${file.separator}WEB-INF${file.separator}src${file.separator}content"/>
>
>         <antcall target="build-lang-cmd">
>             <param name="lang.dir" value=${DIR}" />
>             <param name="lang.file" value="Language" />
>             <param name="lang.translate" value="true" />
>         </antcall>
>     target>
> </project>
>
> I'm not sure it will fix your problem - but its a start.
>
> I did a preliminary google and found the code here:
> http://grepcode.com/file/repo1.maven.org/maven2/com.liferay.portal/portal-impl/6.0.5/com/liferay/portal/tools/LangBuilder.java
>
> Again - I don't know this code base whatsoever, but what's the download
> site for this?  Be easier to help if I can test against the library.
>
> ---- Tanguy Thomas <tanguy.thomas@gmail.com> wrote:
> > Dear all,
> >
> > I am relatively new to Ant using, so may I may miss something obvious
> but I
> > tried to follow guidelines and search documentation without success.
> >
> > When I add the <target name="build-lang">...</target-lang> I get an
> > IllegalArgumentException related to the lang.dir. Ant however does
> > something, it creates an English version (but not any other translation)
> > Language_en.properties, and says "build successful" after this exception.
> > In case this matters, I am using the JDK 1.8.0 (C:\Program
> > Files\Java\jdk1.8.0_25)
> >
> > The build.xml is
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > *<project name="product-registration-TT-portlet" basedir="."
> > default="deploy"> <import file="../build-common-portlet.xml" /> <target
> > name="build-lang">  <antcall target="build-lang-cmd">   <param
> > name="lang.dir" value="docroot/WEB-INF/src/content" />   <param
> > name="lang.file" value="Language" />   <param name="lang.translate"
> > value="true" />  </antcall> </target></project>*
> >
> > And the output is :
> >
> >
> >
> *F:\COEProjects\plugins\plugins-lia\portlets\product-registration-TT-portlet>antbuild-langBuildfile:
> >
> F:\COEProjects\plugins\plugins-lia\portlets\product-registration-TT-portlet\build.xml*
> > *build-lang:*
> >
> >
> >
> >
> >
> > *build-lang-cmd:     [java] Exception in thread "main"
> > java.lang.IllegalArgumentException: Bad argument
> > docroot/WEB-INF/src/content     [java]    at
> >
> com.liferay.portal.tools.ArgumentsUtil.parseArguments(ArgumentsUtil.java:32)
> > [java]     at
> > com.liferay.portal.tools.LangBuilder.main(LangBuilder.java:57)     [java]
> > Java Result: 1*
> >
> > *BUILD SUCCESSFULTotal time: 0 seconds*
> >
> > Of course, the folder name is correct (and it somehow finds my files as
> it
> > creates the Language_en.properties file. I also tried to put backslashes
> > instead of foreward slashes, I tried to add in front or after the folder
> > name, to escape them etc. but nothing helps.
> >
> > Please note that I searched on internet for example build.xml files, and
> as
> > I saw a parameter called "build-lang-cmd" I tried to add it. Though I
> have
> > no idea what it exactly tells, In that case strangely, I don't get the
> > exception, but I get lot of errors telling the client-id argument is
> > missing. As a result, all translation files are created, but they all
> > contain the original English content.
> >
> > The build file in this example would be :
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > *<project name="product-registration-TT-portlet" basedir="."
> > default="deploy"> <import file="../build-common-portlet.xml" /> <target
> > name="build-lang">  <antcall target="build-lang-cmd">   <param
> > name="lang.dir" value="docroot/WEB-INF/src/content" />   <param
> > name="lang.file" value="Language" />   <param name="lang.translate"
> > value="true" />  </antcall> </target> <target name="build-lang-cmd">
> <java
> > classname="com.liferay.portal.tools.LangBuilder"
> > classpathref="portal.classpath" fork="true" newenvironment="true">
> <jvmarg
> >
> value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties"
> > />  <jvmarg value="-Dfile.encoding=UTF-8" />  <jvmarg
> > value="-Duser.country=US" />  <jvmarg value="-Duser.language=en" />  <arg
> > value="lang.dir=${lang.dir}" />  <arg value="lang.file=${lang.file}"
> > />  <arg value="lang.plugin=true" />  <arg
> > value="lang.translate=${lang.translate}" /> </java> <copy
> > file="${lang.dir}/${lang.file}.properties"
> > tofile="${lang.dir}/${lang.file}_en.properties" /> </target></project>*
> > I would get as output a lot of text such as :
> >
> >
> >
> >
> >
> >
> >
> > *     [java] Correlation ID: 3c2e5a07-204a-47a3-a413-316ab512277c
> > [java] Timestamp: 2015-01-03 17:33:50Z     [java] Translating en_es
> > where-purchased-required Please tell us where youpurchased the product
> > [java]
> >
> com.liferay.portal.kernel.microsofttranslator.MicrosoftTranslatorException:
> > ACS90011: The required field 'client_id' is missing.     [java] Trace ID:
> > 2ce232f9-4ada-4901-b61e-a8a65ae7d4d6*
> >
> > I mainly would like to understand what goes wrong, I can use with or
> > without this extra "build-lang-cmd" but I would like to understand also
> > what I am doing by adding or omitting this.
> >
> > Thank you very much for your help, and happy new year to whoever reads
> this
> > :)
> >
> > --
> > Tanguy Thomas
>



-- 
Tanguy Thomas
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message