1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    1
    Vote Rating
    0
    ACE91 is on a distinguished road

      0  

    Default Calling Sencha CMD in Maven compile: Cannot find com/sencha/ant/antlib.xml

    Calling Sencha CMD in Maven compile: Cannot find com/sencha/ant/antlib.xml


    I am trying to integrate Sencha CMD into a Maven compilation process. The src/main/webapp directory of the project is a valid Sencha CMD application (with .sencha folders, etc.). I added the following XML to my pom.xml:

    Code:
        <profiles>
            <profile>
                <id>minify</id>
    
    
                <build>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-antrun-plugin</artifactId>
                            
                            <executions>
                                <execution>
                                    <id>compile with sencha cmd</id>
                                    <phase>compile</phase>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                    <configuration>
                                        <target>
                                            <taskdef resource="com/sencha/ant/antlib.xml" classpath="${cmd.dir}/sencha.jar" />
                                            <x-sencha-command dir="src/main/webapp">
                                                app
                                                  build
                                            </x-sencha-command>
                                        </target>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </build>
            </profile>
        </profiles>
    The 'cmd.dir' property is not set in any 'properties' block (although I have tried that). Every time I try to compile it with this command:

    Code:
    mvn clean install -Pminify -Dcmd.dir=/home/myname/bin/Sencha/Cmd/3.1.2.342
    ...I get this error (company name replaced with "***"):

    Code:
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
    Including theme package ext-theme-*** for app.theme=ext-theme-*** build
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
    
    
    init-plugin:
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
    
    
    cmd-root-plugin.init-properties:
    
    
    init-properties:
    
    
    init-sencha-command:
      [taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml. It could not be found.
    
    
    init:
    InvocationTargetException: null
    
    
    BUILD FAILED
    com.sencha.exceptions.BasicException: Problem: failed to create task or type x-script-def
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any <presetdef>/<macrodef> declarations have taken place.
    
    
        at com.sencha.exceptions.BasicException.wrap(BasicException.java:44)
        at com.sencha.cli.Command.dispatch(Command.java:64)
        at com.sencha.cli.Commands.dispatch(Commands.java:62)
        at com.sencha.cli.Commands.dispatch(Commands.java:62)
        at com.sencha.command.Sencha.dispatch(Sencha.java:78)
        at com.sencha.cli.AbstractCommand.dispatch(AbstractCommand.java:131)
        at com.sencha.ant.SenchaCommandTask.doExecute(SenchaCommandTask.java:65)
        at com.sencha.ant.BaseAntTask.execute(BaseAntTask.java:29)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:327)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: /home/myname/bin/Sencha/Cmd/3.1.2.342/plugin.xml:15: Problem: failed to create task or type x-script-def
    Cause: The name is undefined.
    Action: Check the spelling.
    Action: Check that any custom tasks/types have been declared.
    Action: Check that any <presetdef>/<macrodef> declarations have taken place.
    
    
        at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:487)
        at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:419)
        at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
        at org.apache.tools.ant.Task.perform(Task.java:347)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at com.sencha.ant.AntScript.execute(AntScript.java:127)
        at com.sencha.command.plugin.PluginManager.execute(PluginManager.java:93)
        at com.sencha.command.plugin.PluginManager.executeReverseFirst(PluginManager.java:134)
        at com.sencha.command.environment.BuildEnvironment.execute(BuildEnvironment.java:66)
        at com.sencha.command.BasePluginCommands$BasePluginCommand.doExecute(BasePluginCommands.java:23)
        at com.sencha.command.app.AppCommands$BuildCommand.execute(AppCommands.java:120)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.sencha.util.MethodInvoker$Arguments.invoke(MethodInvoker.java:174)
        at com.sencha.cli.Command.dispatch(Command.java:42)
        ... 39 more
    
    
    Total time: 2 seconds
    Googling for this error came up with nothing. I've tried to compile this in dozens of different ways, including moving the Sencha CMD directory, using relative paths, adding or removing trailing and leading slashes, and extracting the antlib.xml from the JAR and using it directly, but I always end up with the same problem. It looks like the problem has something to do with the fact that all of Sencha CMD's generated XML files also reference sencha.jar, and, for some reason, they can't find it.

    I have a feeling I'm missing some obvious step, given that this seems like a pretty basic error, and, as far as I can tell, no one else has encountered it.

  2. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    6
    Vote Rating
    0
    mikel1982 is on a distinguished road

      0  

    Default


    I have the same problem. I don't know if this info is not misleading. Because when you remove build from your x-sencha-command and only app remain, it works. So maybe its somehow connected with multi arguments ?

  3. #3
    Sencha Premium Member
    Join Date
    Dec 2013
    Posts
    11
    Vote Rating
    0
    ahmedmohammed is on a distinguished road

      0  

    Default Were you able to resolve the issue

    Were you able to resolve the issue


    I am currently looking into integrating the ext-js compile with Maven. Wanetd to check if you were able to do that. And any help in that regard will be very helpful.
    Thanks

  4. #4
    Sencha User nbabinski's Avatar
    Join Date
    Apr 2011
    Location
    Ukraine, Kyiv
    Posts
    21
    Vote Rating
    2
    nbabinski is on a distinguished road

      0  

    Default Sencha Cmd 4.0.2.67

    Sencha Cmd 4.0.2.67


    I've tried installed Sencha Cmd 4.0.2.67 with maven and it works.

    Simple example:

    Code:
    <build>
        <plugins>
    ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>                                 
                                <!-- could be defined in properties section -->
                                <!-- ${user.home}\bin\Sencha\Cmd\4.0.2.67 The default path the Sencha Cmd is installed -->
                                <property name="cmd.dir" value="${user.home}\bin\Sencha\Cmd\4.0.2.67" />
    
                                <taskdef resource="com/sencha/ant/antlib.xml" classpath="${cmd.dir}/sencha.jar" />
    
    
                                <echo>Start Sencha Cmd build</echo>
    
    
                                <x-sencha-init />
                                <x-sencha-command dir="path/to/extjs/application">
                                      app
                                             build
                                </x-sencha-command>
    
    
                                <echo>End build process</echo>
                           </target>
                       </configuration>
                       <goals>
                           <goal>run</goal>
                       </goals>
                    </execution>
                </executions>
            </plugin>
    ...
        </plugins>
    </build>
    Or the same :

    Code:
    ...
    <configuration>
        <target>                                 
            <ant antfile="path/to/extjs/application/build.xml" target="build" dir="path/to/extjs/application">
                <!-- "production" is be default, just set it explicitly -->
                <property name="build.environment" value="production" />
            </ant>
        </target>
    </configuration>
    ...
    The shown example is bad cause you are tied to Sencha Cmd and have to install it on a machine where application will be used prior to run maven (For instance at machine with CI, you have to install Sencha Cmd).

    More clear way is to create a maven dependency that contains sencha.jar and all it dependencies. Then add this dependency to the project and on compilation time run all needed commands. Thus there will be no need to install the Sencha Cmd on a machine the application is run.
    That makes application independable, anyone in your team can run it.

    But the reality is not so perfect. I have not found a Sencha Cmd maven project yet, maybe you will find. Otherwise this should be done and shared in the team/organization maven repository (for instance using nexus) or be published in any of maven open repos.

    There is one small intricacy, guys from Sencha placed in sencha.jar not all required dependencies making it autonomous, so you could not just include sencha.jar and use it with antrun plugin inside your maven.
    sencha.jar depends on others pieces, e.g. cmd_installed_folder/lib - sencha cmd dependencies.
    So it will be nice to have one complete jar file that could be used in ant/maven environment out from the box (along with sencha.jar having fat senchacmd.jar).

  5. #5
    Sencha Premium Member
    Join Date
    Dec 2013
    Posts
    11
    Vote Rating
    0
    ahmedmohammed is on a distinguished road

      0  

    Default Sencha build using maven

    Sencha build using maven


    Thanks it worked some minor modifications based on my project setup.
    Thanks