2014-10-01 4 views
0

내 ant 스크립트에서 trycatch 블록을 만들려고합니다. 이 오류를 얻을 :개미 trycatch 블록에서 나는 무엇을 놓치고 있습니까?

* UPDATE *

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (test-compile) on project PROJECT: An Ant BuildException has occured: Problem: failed to create task or type trycatch 
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. 

around Ant part ...<trycatch>... @ 6:13 in /Users/NAME/Projects/PROJECT-dev/PROJECT-website/target/antrun/build-main.xml 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 
    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:108) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) 
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:483) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: Problem: failed to create task or type trycatch 
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. 

around Ant part ...<trycatch>... @ 6:13 in /Users/NAME/Projects/PROJECT-dev/PROJECT-website/target/antrun/build-main.xml 
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:355) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
    ... 19 more 
Caused by: /Users/NAME/Projects/PROJECT-dev/PROJECT-website/target/antrun/build-main.xml:6: Problem: failed to create task or type trycatch 
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.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:327) 
    ... 21 more 
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

내가 시도 캐치의 예를 따르도록 시도했지만 그들 중 누구도 일했다. http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html

이 오류는 같은 이름이 모든 경우에 정의되지는 않습니다. 특정 빌드 단계에 넣으려고하기 때문에이 블록을 올바른 위치에 중첩하는지 여부는 알 수 없습니다.

이 trycatch를 작동 시키려면 어떻게해야합니까?

* UPDATE *

나는 아직도 얻을 같은 오류

<dependencies> 
... 
    <dependency> 
     <groupId>ant-contrib</groupId> 
     <artifactId>ant-contrib</artifactId> 
     <version>1.0b3</version> 
    </dependency> 
... 
</dependencies> 

... 

      <execution> 
       <id>test-compile</id> 
       <phase>test-compile</phase> 
       <configuration> 
       <tasks> 
         <!-- declare ant-contrib tasks --> 
         <taskdef resource="net/sf/antcontrib/antlib.xml" /> 
         <echo message="***** Hello from test-compile phase! *****" /> 
         <trycatch> 
          <try> 
           <replaceregexp match="\s+" replace=" " flags="g" byline="true"> 
            <fileset dir="${basedir}/target/ROOT/WEB-INF/views/" includes="**/*.jsp"></fileset> 
           </replaceregexp> 
           <replaceregexp match="&lt;!--.*build.*--&gt;" replace=" " flags="g" byline="true"> 
            <fileset dir="${basedir}/target/ROOT/WEB-INF/views/" includes="**/*.jsp"></fileset> 
           </replaceregexp> 
          </try> 
         </trycatch> 
        </tasks> 
       </configuration> 
       <goals> 
        <goal>run</goal> 
       </goals> 
      </execution> 

답변

0

trycatchant-contrib의 일부입니다. 따라서이 라이브러리에서 플러그인에 대한 종속성을 선언하고 구성에있는 작업을 실행하기 전에 포함 된 작업을 선언해야합니다.

관련 문제