Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

include/exclude patterns for resources does not work #36

Open
mat127 opened this issue Jan 18, 2012 · 2 comments
Open

include/exclude patterns for resources does not work #36

mat127 opened this issue Jan 18, 2012 · 2 comments

Comments

@mat127
Copy link

mat127 commented Jan 18, 2012

I have pom.xml defining resources as follows:

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>code/**</include>
                <include>html/**</include>
            </includes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <excludes>
                <exclude>profile/**</exclude>
                <exclude>code/**</exclude>
                <exclude>html/**</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources/profile/${profile.id}</directory>
            <filtering>false</filtering>
        </resource>
    </resources>

Such definition I use because of various resources to be filtered or not and for special resources under src/main/resource/profile/${profile.id} that has to be included only in case that particular profile is active.

Then I use following configuration of the yuicompressor-maven-plugin for compressing just the .js files:

        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <jswarn>false</jswarn>
                <failOnWarning>false</failOnWarning>
                <encoding>UTF-8</encoding>
                <nomunge>false</nomunge>
                <nosuffix>true</nosuffix>
                <excludes>
                    <exclude>profile/**</exclude>
                    <exclude>**/*.css</exclude>
                </excludes>
            </configuration>
        </plugin>

As you see, I have to explicitly exclude the profile/** because without this exclusion the whole tree under src/main/resources/profile is included in the resulting archive. And this is something that I do not want at all.

Moreover all the .js files under src/main/resources are processed exactly 2 times by the yui compressor. I expect this is due to the fact that directory src/main/resources is specified twice in the resources configuration. Some of the are processed 3 times as they reside under the src/main/resources/profile

Currently the pom.xml is working for me, but the repetitive processing of some files is quite unpleasant. Is there some reason why the include/exclude patterns fro resources definition are ignored?

@noctarius
Copy link
Contributor

No there's no special reason, it's just not implemented to respect these :)

@Dacesilian
Copy link

Dacesilian commented Oct 17, 2017

I have the same problem - files are processed multiple times. I need to exclude *.min.js / *.min.css from minification. Solution is:

<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>process-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<delete>
									<fileset dir="${project.build.outputDirectory}/WEB-INF">
										<include name="**/*.js" />
										<exclude name="**/*.min.js" />
										<include name="**/*.css" />
										<exclude name="**/*.min.css" />
									</fileset>
								</delete>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>net.alchim31.maven</groupId>
				<artifactId>yuicompressor-maven-plugin</artifactId>
				<version>1.5.1</version>
				<executions>
					<execution>
						<phase>process-resources</phase>
						<goals>
							<goal>compress</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<nosuffix>true</nosuffix>
					<nomunge>true</nomunge>
					<!-- <sourceDirectory>${project.basedir}/src/main/resources/WEB-INF</sourceDirectory> <outputDirectory>${project.build.outputDirectory}/WEB-INF</outputDirectory> -->
					<excludes>
						<exclude>**/*.min.js</exclude>
						<exclude>**/*.min.css</exclude>
					</excludes>
					<jswarn>false</jswarn>
				</configuration>
			</plugin>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants