Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.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-从生成中排除文件夹_Maven_Maven Compiler Plugin - Fatal编程技术网

Maven-从生成中排除文件夹

Maven-从生成中排除文件夹,maven,maven-compiler-plugin,Maven,Maven Compiler Plugin,试图从我的生成中删除文件夹src/main/resources/scripts/,但以下操作无效: <build> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude>src/main/reso

试图从我的生成中删除文件夹
src/main/resources/scripts/
,但以下操作无效:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>src/main/resources/scripts/</exclude>
            </excludes>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <excludes>
                    <exclude>src/main/resources/scripts/</exclude>
                </excludes>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

src/main/resources
src/main/resources/scripts/
org.apache.maven.plugins
maven编译器插件
3.1
src/main/resources/scripts/
1.7
1.7
有什么想法吗?

试试:

<exclude>scripts/**</exclude>

我遇到了类似的问题,并发现以下问题:

  • 您可能有一个父pom,它已经定义了
    maven编译器插件的配置。为此,将
    combine.self=“override”
    添加到
    配置标签中。看
  • 如果插件需要被排除的类进行编译,它似乎会忽略排除:请确保您没有引用将被编译的其他类中被排除的类。例如,如果您排除
    Foo.java
    ,但在
    Bar.java
    中,您将
    导入Foo
    它将(尝试)编译
    Foo.java
    以编译
    Bar.java
例如:

<profiles>
    <profile>
        <id>myId</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration combine.self="override">
                        <excludes>
                            <exclude>**/some/full/directory/*</exclude>
                            <exclude>**/some/single/File.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
</profile>

粘虫
org.apache.maven.plugins
maven编译器插件
**/some/full/directory/*
**/some/single/File.java

重新构建
org.apache.maven.plugins
maven编译器插件
**/com/pyramid/controllers/authoritmentWriteControl.java
**/com/pyramid/controllers/productWriteControl.java
**/com/pyramid/controllers/authenticementWriteControllerTest.java
**/com/pyramid/controllers/ProductWriteControllerTest.java
你的目录

它非常简单,您无需添加其他插件:


src/main/resources
应用程序属性

谢谢您的建议,但这似乎对我不起作用。您是否先进行了
mvn清理
?顺便说一句,它对manven编译器插件没有影响,它只编译.java文件。maven资源插件负责将这些文件复制到类路径。给你适当的例子<代码>***
只匹配目录,如果是文件,我希望它是
脚本/***
,没有乐趣。我正在做一个
mvn清理
,然后是一个
mvn编译
。你会认为我是个白痴……我看的项目完全错了……你的建议行得通。ThanksSingle file excluding在版本3.6.0中对我不起作用这在当前版本的maven和插件上给出了一个构建错误在阅读了40多票的问题后,我终于找到了一个有效的(Kumar)!非常感谢。
<profiles>
    <profile>
        <id>myId</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration combine.self="override">
                        <excludes>
                            <exclude>**/some/full/directory/*</exclude>
                            <exclude>**/some/single/File.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
</profile>
<profiles>
    <profile>
        <id>readBuild</id>
        <build>
             <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration >
                    <excludes>
                        <exclude>**/com/pyramid/controllers/EntitlementWriteController.java</exclude>
                        <exclude>**/com/pyramid/controllers/ProductWriteController.java</exclude>
                    </excludes>
                     <testExcludes>
                      <testExclude>**/com/pyramid/controllers/EntitlementWriteControllerTest.java</testExclude>
                       <testExclude>**/com/pyramid/controllers/ProductWriteControllerTest.java</testExclude>
                    </testExcludes>
                </configuration>
            </plugin>
        </plugins>
            <directory>yourDirectory</directory>
        </build>
    </profile>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <excludes>
                        <exclude>application.properties</exclude>
                    </excludes>
                </resource>
            </resources>
        </build>