2010-12-06 5 views
6

Wir haben eine spezielle Routine, um Dateien in einem Unterordner in Extensions zu explodieren, die in einzelne Extension-Dateien kopiert und eingebunden werden. Für diesen speziellen Ansatz wollte ich die maven-antrun-plugin verwenden, für die sequenzielle Iteration und jar packaging durch das dirset benötigen wir die Bibliothek ant-contrib.Maven antrun mit sequenziellem ant-contrib läuft nicht

Die bevorstehende Plugin-Konfiguration schlägt mit einem Fehler fehl. Was habe ich falsch konfiguriert? Vielen Dank.

Plugin Konfiguration

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
    <execution> 
     <phase>validate</phase> 
     <goals> 
     <goal>run</goal> 
     </goals> 
     <configuration> 
     <target> 
      <for param="extension"> 
      <path> 
       <dirset dir="${basedir}/src/main/webapp/WEB-INF/resources/extensions/"> 
       <include name="*" /> 
       </dirset> 
      </path> 

      <sequential> 
       <basename property="extension.name" file="${extension}" /> 
       <echo message="Creating JAR for extension '${extension.name}'." /> 
       <jar destfile="${basedir}/target/extension-${extension.name}-1.0.0.jar"> 
       <zipfileset dir="${extension}" prefix="WEB-INF/resources/extensions/${extension.name}/"> 
        <include name="**/*" /> 
       </zipfileset> 
       </jar> 
      </sequential> 
      </for> 
     </target> 
     </configuration> 
    </execution> 
    </executions> 
    <dependencies> 
    <dependency> 
     <groupId>ant-contrib</groupId> 
     <artifactId>ant-contrib</artifactId> 
     <version>1.0b3</version> 
     <exclusions> 
     <exclusion> 
      <groupId>ant</groupId> 
      <artifactId>ant</artifactId> 
     </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.ant</groupId> 
     <artifactId>ant-nodeps</artifactId> 
     <version>1.8.1</version> 
    </dependency> 
    </dependencies> 
</plugin> 

Fehler

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project extension-platform: An Ant BuildException has occured: Problem: failed to create task or type for 
[ERROR] Cause: The name is undefined. 
[ERROR] Action: Check the spelling. 
[ERROR] Action: Check that any custom tasks/types have been declared. 
[ERROR] Action: Check that any <presetdef>/<macrodef> declarations have taken place. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[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 

Antwort

9

Es sieht aus wie Sie die taskdef sind vermisst, die declare the ant-contrib tasks benötigt wird, so dass Ant über sie weiß, damit dieser Teil die Fehlermeldung:

(. Es wäre vielleicht ein wenig klarer, wenn die ausgefallene Aufgabe - 'for' - zitiert wurden)

Eine Möglichkeit, die taskdef hinzuzufügen, ist es unmittelbar vor dem for Schleife einzufügen:

<target> 
    <taskdef resource="net/sf/antcontrib/antlib.xml" 
      classpathref="maven.plugin.classpath" /> 
    <for param="extension"> 
    ... 
+0

Danke, das ist für mich sehr gearbeitet. Ich habe das auch versucht, aber die falsche Klassenpfadreferenz verwendet. – codevour

10

Deshalb verschwendet ich mindestens eine Stunde, um den Fehler ein kleiner Hinweis unten zu finden ...

ich benutze maven3 und den Rest, wie oben beschrieben, aber ich habe maven.dependency.classpath statt maven.plugin.classpath verwenden ! Andernfalls wird maven die contrib-Aufgaben nicht finden. Hoffe das hilft jedem.

0

Nach 2 Stunden zu verschwenden und zu viele Antworten zu lesen, ist es das, was ich

http://www.thinkplexx.com/learn/howto/maven2/plugins/could-not-load-definitions-from-resource-antlib-xml-understanding-the-problem-and-fix-worklow

ich alle Maven CLASSPATHs gedruckt mit diesen

<property name="compile_classpath" refid="maven.compile.classpath"/> 
<property name="runtime_classpath" refid="maven.runtime.classpath"/> 
<property name="test_classpath" refid="maven.test.classpath"/> 
<property name="plugin_classpath" refid="maven.plugin.classpath"/> 
<echo message="compile classpath: ${compile_classpath}"/> 
<echo message="runtime classpath: ${runtime_classpath}"/> 
<echo message="test classpath: ${test_classpath}"/> 
<echo message="plugin classpath: ${plugin_classpath}"/> 

und geprüft, um zu überprüfen, müssen die Classpath enthält Antrib-Jar-Datei. Also änderte ich classpathhref zu maven.runtime.classpath von maven.plugin.classpath . Also meine taskdef ist

<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.runtime.classpath" /> 

und die Abhängigkeiten

<dependency> 
    <groupId>ant-contrib</groupId> 
    <artifactId>ant-contrib</artifactId> 
    <version>1.0b3</version> 
    <exclusions> 
     <exclusion> 
      <groupId>ant</groupId> 
      <artifactId>ant</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>org.apache.ant</groupId> 
    <artifactId>ant-nodeps</artifactId> 
    <version>1.8.1</version> 
</dependency> 
Verwandte Themen