WRO4J in ANT

158 views
Skip to first unread message

yudi...@gmail.com

unread,
Jul 14, 2014, 2:31:11 PM7/14/14
to wr...@googlegroups.com
I am trying to use wro4j in ANT build to precompile handlebars templates to js. I searched online and find this. It announces that it will allow you to use wro4j in ant.

<?xml version="1.0" encoding="UTF-8"?>
<project name="handlebars.compile"  default="trasition" basedir=".">
<description> handlebars build in</description>
<property name="charset" value="utf-8"/>
<target name="trasition" >
<echo> is now ready to execute</echo>
</target>
<target name="crunching" >
<echo> is now ready to execute</echo>
</target>
<!-- properties file --> 
        <property file="build.properties"/>

       <!-- macro for interacting with wro4j --> 
       <macrodef name="wro4j">
               <attribute name="processor"/>
               <attribute name="wro-file" default="wro.xml"/>
               <attribute name="target-groups"/>
               <attribute name="context-dir" default="${basedir}"/>
               <attribute name="output-dir" default="${basedir}/bin"/>
               <sequential>
                       <exec executable="java" failonerror="true">
                               <arg value="-jar"/>
                               <arg value="${basedir}/lib/wro4j-runner-1.6.2-jar-with-dependencies.jar"/>
                               <arg value="--wroFile"/>
                               <arg value="@{wro-file}"/>
                               <arg value="--contextFolder"/>
                               <arg value="@{context-dir}"/>
                               <arg value="--targetGroups"/>
                               <arg value="@{target-groups}"/>
                               <arg value="--destinationFolder"/>
                               <arg value="@{output-dir}"/>
                               <arg value="-c"/>
                               <arg value="@{processor}"/>
                       </exec>
               </sequential>
       </macrodef>

       <!-- minify target --> 
       <target name="minify">
               <wro4j processor="yuiCssMin" target-groups="global-css"/>
               <wro4j processor="yuiJsMin" target-groups="global-js"/>
               <echo>Minification Completed Successfully</echo>
       </target>


</project>




 However when I try to run this build.xml, it says:






Buildfile: C:\Users\di_yu\workspace\AffirmedNetworks\build.xml
trasition:
     [echo]  is now ready to execute
crunching:
     [echo]  is now ready to execute
minify:
     [exec] processing group: global-css.css
     [exec] No valid model was found!
     [exec] =======================================
     [exec] USAGE
     [exec] =======================================
     [exec]  --contextFolder PATH                          : Folder used as a root of the context relative
     [exec]                                                  resources. By default this is the user current
     [exec]                                                  folder.
     [exec]  --destinationFolder PATH                      : Where to store the processed result. By default
     [exec]                                                  uses the folder named [wro].
     [exec]  --parallel                                    : Turns on the parallel preProcessing of resources.
     [exec]                                                  This value is false by default.
     [exec]  --postProcessors POST_PROCESSOR               : Comma separated list of post-processors
     [exec]  --targetGroups GROUPS                         : Comma separated value of the group names from
     [exec]                                                  wro.xml to process. If none is provided, all
     [exec]                                                  groups will be processed.
     [exec]  --wroFile PATH_TO_WRO_XML                     : The path to the wro model file. By default the
     [exec]                                                  model is searched inse the user current folder.
     [exec]  -c (--compressor, --preProcessors) COMPRESSOR : Comma separated list of pre-processors
     [exec]  -i (--ignoreMissingResources)                 : Ignores missing resources
     [exec]  -m (--minimize)                               : Turns on the minimization by applying compressor
     [exec] Error while creating the model
     [exec] ro.isdc.wro.WroRuntimeException: The wroFile doesn't exist. Skip trying with other wro model factories
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.createAutoDetectedStream(SmartWroModelFactory.java:158)
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.access$100(SmartWroModelFactory.java:36)
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory$2.getModelResourceAsStream(SmartWroModelFactory.java:118)
     [exec] at ro.isdc.wro.extensions.model.factory.GroovyModelFactory.create(GroovyModelFactory.java:60)
     [exec] at ro.isdc.wro.extensions.model.factory.GroovyModelFactory.create(GroovyModelFactory.java:42)
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.create(SmartWroModelFactory.java:180)
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.create(SmartWroModelFactory.java:36)
     [exec] at ro.isdc.wro.model.factory.WroModelFactoryDecorator.create(WroModelFactoryDecorator.java:27)
     [exec] at ro.isdc.wro.model.factory.FallbackAwareWroModelFactory.create(FallbackAwareWroModelFactory.java:48)
     [exec] at ro.isdc.wro.model.factory.FallbackAwareWroModelFactory.create(FallbackAwareWroModelFactory.java:22)
     [exec] at ro.isdc.wro.model.factory.WroModelFactoryDecorator.create(WroModelFactoryDecorator.java:27)
     [exec] at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:55)
     [exec] at ro.isdc.wro.model.factory.ModelTransformerFactory.create(ModelTransformerFactory.java:27)
     [exec] at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator$1.initialize(DefaultWroModelFactoryDecorator.java:60)
     [exec] at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator$1.initialize(DefaultWroModelFactoryDecorator.java:50)
     [exec] at ro.isdc.wro.util.LazyInitializer.get(LazyInitializer.java:32)
     [exec] at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:117)
     [exec] at ro.isdc.wro.model.factory.DefaultWroModelFactoryDecorator.create(DefaultWroModelFactoryDecorator.java:35)
     [exec] at ro.isdc.wro.model.group.processor.GroupsProcessor.process(GroupsProcessor.java:72)
     [exec] at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:90)
     [exec] at ro.isdc.wro.cache.support.DefaultSynchronizedCacheStrategyDecorator.loadValue(DefaultSynchronizedCacheStrategyDecorator.java:36)
     [exec] at ro.isdc.wro.cache.support.AbstractSynchronizedCacheStrategyDecorator.get(AbstractSynchronizedCacheStrategyDecorator.java:57)
     [exec] at ro.isdc.wro.manager.ResourceBundleProcessor.serveProcessedBundle(ResourceBundleProcessor.java:66)
     [exec] at ro.isdc.wro.manager.WroManager.process(WroManager.java:127)
     [exec] at ro.isdc.wro.runner.Wro4jCommandLineRunner.doProcess(Wro4jCommandLineRunner.java:254)
     [exec] at ro.isdc.wro.runner.Wro4jCommandLineRunner.processGroup(Wro4jCommandLineRunner.java:197)
     [exec] at ro.isdc.wro.runner.Wro4jCommandLineRunner.process(Wro4jCommandLineRunner.java:165)
     [exec] at ro.isdc.wro.runner.Wro4jCommandLineRunner.doMain(Wro4jCommandLineRunner.java:131)
     [exec] at ro.isdc.wro.runner.Wro4jCommandLineRunner.main(Wro4jCommandLineRunner.java:99)
     [exec] Caused by: java.io.FileNotFoundException: wro.xml (The system cannot find the file specified)
     [exec] at java.io.FileInputStream.open(Native Method)
     [exec] at java.io.FileInputStream.<init>(Unknown Source)
     [exec] at ro.isdc.wro.extensions.model.factory.SmartWroModelFactory.createAutoDetectedStream(SmartWroModelFactory.java:151)
     [exec] ... 28 more
     [exec] Couldn't load new model, reusing last Valid Model!
     [exec] No valid model was found!

BUILD FAILED
C:\Users\di_yu\workspace\AffirmedNetworks\build.xml:47: The following error occurred while executing this line:
C:\Users\di_yu\workspace\AffirmedNetworks\build.xml:28: exec returned: 1

Total time: 2 seconds


Can anyone help me with this ? Alex? I am really confused. There is an wro.xml file in my WEB-INF directory.

Alex Objelean

unread,
Jul 14, 2014, 3:32:28 PM7/14/14
to wr...@googlegroups.com

You are using wro4j-runner which by default expects to find the model in the current working directory, unless a different location is configured explicitely.

Let me know if you manage to solve this.

Cheers,
Alex

--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wro4j+un...@googlegroups.com.
To post to this group, send email to wr...@googlegroups.com.
Visit this group at http://groups.google.com/group/wro4j.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages