为什么Maven会将Subversion目录复制到目标文件夹?

7

虽然不是所有的时间都会发生,但有时候我会发现这样的东西:

>dir /SF  target\.svn
…\target\Zeiterfassung-web\WEB-INF\.svn\.
…\target\Zeiterfassung-web\WEB-INF\.svn\..
…\target\Zeiterfassung-web\WEB-INF\.svn\lock

为什么Maven默认应该忽略 .svn 目录,但还是发生了这种情况?

我能否明确地排除它们(请注意 WEB-INF - 它既不是源代码也不是资源文件)?

或者可以将该可恶的 .svn 数据放在与工作文件分开的其他位置(如 ClearCase 所做的那样)吗?


所请求的 POM(减去 scm 和 issue management):

<project
  xmlns='http://maven.apache.org/POM/4.0.0'
  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd'
>
<!-- Projekt - - - - - - - - - - - - - - - - - - - - - - - - {{{1  - - - -->
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>Zeiterfassung</artifactId>
    <groupId>com.noser</groupId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../Zeiterfassung</relativePath>
  </parent>
  <groupId>com.noser</groupId>
  <artifactId>Zeiterfassung-web</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Zeiterfassung Webapp</name>
  <description>Mobile Applikation Zeiterfassung — Web Archive/Application</description>
  <url>http://maven.apache.org</url>
  <repositories>
    <repository>
      <id>java.net2</id>
      <name>Repository hosting the jee6 artifacts</name>
      <url>http://download.java.net/maven/2</url>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>Zeiterfassung-lib</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-web-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.8.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
  </dependencies>
  <organization>
    <name>Noser Engineering AG</name>
    <url>http://www.noser.com</url>
  </organization>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - }}}1  - - - -->
<!-- Build - - - - - - - - - - - - - - - - - - - - - - - - - {{{1  - - - -->
  <build>
    <defaultGoal>package</defaultGoal>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>**/.backups/*</exclude>
          <exclude>**/.backups</exclude>
          <exclude>**/.svn/*</exclude>
          <exclude>**/.svn</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.scala-tools</groupId>
        <artifactId>maven-scala-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <jvmArgs>
            <jvmArg>-Xms64m</jvmArg>
            <jvmArg>-Xmx1024m</jvmArg>
          </jvmArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
          <encoding>${project.build.sourceEncoding}</encoding>
          <showDeprecation>true</showDeprecation>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <encoding>${project.build.sourceEncoding}</encoding>
        </configuration>
      </plugin>
    </plugins>
    <finalName>Zeiterfassung-web</finalName>
  </build>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - }}}1  - - - -->
<!-- Profiles  - - - - - - - - - - - - - - - - - - - - - - - {{{1  - - - -->
  <profiles>
    <profile>
      <id>endorsed</id>
      <activation>
        <property>
          <name>sun.boot.class.path</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.6</source>
              <target>1.6</target>
              <encoding>${project.build.sourceEncoding}</encoding>
              <showDeprecation>true</showDeprecation>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
              </compilerArguments>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-endorsed-api</artifactId>
                <version>6.0</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - }}}1  - - - -->
<!-- Reporting - - - - - - - - - - - - - - - - - - - - - - - {{{1  - - - -->
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <show>private</show>
          <nohelp>true</nohelp>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - }}}1  - - - -->
<!-- Properties  - - - - - - - - - - - - - - - - - - - - - - {{{1  - - - -->
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compile.encoding>UTF-8</maven.compile.encoding>
    <netbeans.hint.deploy.server>gfv3ee6wc</netbeans.hint.deploy.server>
  </properties>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - }}}1  - - - -->
</project>
<!-- vim: set nowrap tabstop=8 shiftwidth=2 softtabstop=2 expandtab :-->
<!-- vim: set textwidth=0 filetype=xml foldmethod=marker spell spelllang=en_gb :-->

我得到了相同的东西,只是在target\classes和target\test-classes中,但对于多模块项目的几个部分,有些是war包,有些是jar包。在Windows上使用Eclipse。 - Stephen Denne
我也偶尔使用Eclipse。但是现在主要使用Netbeans。想起来:问题出现的次数也少了。我想知道是否有相关性。可能是Eclipse的问题。 - Martin
2个回答

1

我非常惊讶你的war包中有.svn目录(据我所知,scm目录默认是被排除在外的,这些排除规则已经硬编码在源代码中)。我真的不知道为什么会出现这种情况。

话虽如此,以下方法可能有助于解决问题:

...
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <warSourceExcludes>
        **/.svn/**
      </warSourceExcludes>
    </configuration>
  </plugin>
  ...
</plugins>

但正如我所说,我认为上述更多的是一种解决方法而不是一种解决方案。


就像我说的那样,这是偶发性的,所以我猜这是某种bug。但是感谢你排除错误的提示。 - Martin

0

如果你使用了 maven-release-plugin,那么很可能会出现这种情况。如果这让你感到困扰,只需运行 mvn clean 就可以解决问题了。


“mvn clean”确实是我当前的解决方案。我正在寻找更好的解决方案。或者找出发生这种情况的原因,以便我可以避免这种情况或者知道当我执行X操作后,需要重新清理一下。 - Martin
你使用 maven-release-plugin 吗? - Robert Munteanu
实际上不行:-> ffind /SVT"maven-release-plugin" *.pom -> 0 行在 0 个文件中。 - Martin
你能发布你的pom.xml文件吗? - Robert Munteanu
我确实使用NetBeans。并且使用它的集成功能。 - Martin
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接