Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
maven mojo用于解压文件夹?_Maven_Unzip_Mojo - Fatal编程技术网

maven mojo用于解压文件夹?

maven mojo用于解压文件夹?,maven,unzip,mojo,Maven,Unzip,Mojo,如何编写java程序(mojo)来解压缩特定位置的文件夹? 如果有人帮我的话,我是马文的新手 /** * The Zip archiver. * @parameter \ expression="${component.org.codehaus.plexus.archiver.Archiver#zip}" */ private ZipArchiver zipArchiver; /** * Directory containing the

如何编写java程序(mojo)来解压缩特定位置的文件夹? 如果有人帮我的话,我是马文的新手

/**
    * The Zip archiver.
    * @parameter \
    expression="${component.org.codehaus.plexus.archiver.Archiver#zip}"
    */

    private ZipArchiver zipArchiver;

    /**
    * Directory containing the build files.
    * @parameter expression="${project.build.directory}/Test"
    */

    private File buildDirectory;

    /**
    * Base directory of the project.
    * @parameter expression="${basedir}"
    */

    private File baseDirectory;
我会把这个和一个字母连在一起

例如,如果您希望在测试准备期间发生这种情况:

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <!-- a lifecycle phase to run the unzip-->
            <phase> process-test-resources</phase> 
            <configuration>
              <target>

                 <unzip src="${your.source.zip}" dest="${your.dest}"/>

              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

maven antrun插件
1.7
过程测试资源
跑
您可以这样使用:

<project>
   [...]
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.6</version>
         <executions>
           <execution>
             <id>unpack</id>
             <phase>package</phase>
             <goals>
               <goal>unpack</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId>junit</groupId>
                   <artifactId>junit</artifactId>
                   <version>3.8.1</version>
                   <type>jar</type>
                   <overWrite>false</overWrite>
                   <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>

                 </artifactItem>
               </artifactItems>
                ...
               <overWriteReleases>false</overWriteReleases>
               <overWriteSnapshots>true</overWriteSnapshots>
             </configuration>
           </execution>
         </executions>
       </plugin>
     </plugins>
   </build>
   [...]
 </project>

[...]
org.apache.maven.plugins
例如:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>truezip-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
      <execution>
        <id>unpack</id>
        <goals>
          <goal>cp</goal>
        </goals>
        <phase>ThePhaseYouLike</phase>
        <configuration>
          <from>${project.build.directory}/WhatEveryArchive.zip</from>
          <to>${project.build.directory}</to>
        </configuration>
      </execution>
    </executions>
  </plugin>

org.codehaus.mojo
truezip maven插件
1.1
打开
内容提供商
相如
${project.build.directory}/WhatEveryArchive.zip
${project.build.directory}

你走对了路,正好相反:

 /**
 * The UnZip archiver.
 * 
 * @parameter expression="${component.org.codehaus.plexus.archiver.UnArchiver#zip}"
 */

private ZipUnArchiver unzipArchiver; 
:)