3

I use Gulp and for this reason Node.js in my project. I have a node_modules folder inside src/main/resources and every time I run mvn install it copies 9000+ Files to the target folder.

I don't want this! How can I exclude the node_modules folder?

I tried this:

<excludes>
    <exclude>**/src/main/resources/node_modules/*</exclude>
</excludes>

and this

<excludes>
    <exclude>node_modules/**</exclude>
</excludes>

inside configuration tag of the maven-compiler-plugin. But this doesn't work.

Does anyone have solution?

And here is the build part of my pom

<build>
    <plugins>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-jira-plugin</artifactId>
            <version>${amps.version}</version>
            <extensions>true</extensions>
            <configuration>
                <productVersion>${jira.version}</productVersion>
                <productDataVersion>${jira.version}</productDataVersion>
                <applications>
                    <application>
                        <applicationKey>jira-software</applicationKey>
                        <version>${jira.software.application.version}</version>
                    </application>
                </applications>
                <!-- Uncomment to install TestKit backdoor in JIRA. -->
                <!--
                <pluginArtifacts>
                    <pluginArtifact>
                        <groupId>com.atlassian.jira.tests</groupId>
                        <artifactId>jira-testkit-plugin</artifactId>
                        <version>${testkit.version}</version>
                    </pluginArtifact>
                </pluginArtifacts>
                -->
                <pluginArtifacts>
                    <pluginArtifact>
                        <groupId>com.atlassian.labs.plugins</groupId>
                        <artifactId>quickreload</artifactId>
                        <version>1.30.5</version>
                    </pluginArtifact>
                </pluginArtifacts>
                <compressResources>false</compressResources>
                <enableQuickReload>true</enableQuickReload>
                <enableFastdev>false</enableFastdev>
                <allowGoogleTracking>false</allowGoogleTracking>
                <productDataPath>./generated-test-resources.zip
                </productDataPath>
                <!-- See here for an explanation of default instructions: -->
                <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                <instructions>
                    <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                    <!-- Add package to export here -->
                    <Export-Package>
                        de.cschulc.jira.plugin.api,
                    </Export-Package>

                    <!-- Add package import here -->
                    <Import-Package>
                        org.springframework.osgi.*;resolution:="optional",
                        org.eclipse.gemini.blueprint.*;resolution:="optional",
                        *;version="0";resolution:=optional,
                        *
                    </Import-Package>

                    <!-- Ensure plugin is spring powered -->
                    <Spring-Context>*</Spring-Context>
                </instructions>

            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <excludes>
                    <exclude>**/src/main/resources/node_modules/*</exclude>
                </excludes>
            </configuration>

        </plugin>

        <plugin>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>atlassian-spring-scanner</goal>
                    </goals>
                    <phase>process-classes</phase>
                </execution>
            </executions>
            <configuration>
                <scannedDependencies>
                    <dependency>
                        <groupId>com.atlassian.plugin</groupId>
                        <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                    </dependency>
                </scannedDependencies>
                <verbose>false</verbose>
            </configuration>
        </plugin>
    </plugins>
</build>
Christian
  • 1,022
  • 13
  • 28

3 Answers3

2

Instead try:

<exclude>node_modules/**</exclude>

then try

 mvn clean process-resources -X
rakesh
  • 63
  • 1
  • 2
  • 12
2

i have this problem,fixed by

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-war-plugin</artifactId>
     <version>3.2.3</version>
     <configuration>
         <warSourceExcludes>node_modules/**,build/**,config/**,src/**</warSourceExcludes>
     </configuration>
</plugin>
thonju
  • 21
  • 1
1

I suggest you a different approach that works fine for me.

  1. move node_modules from myproject/src/main/resources to myproject: when I want to install modules locally it's more natural for me to run npm from the root folder of the project because it's my working dir, see global vs local
  2. use in your pom this plug-in: frontend maven plugin, it works great with node and npm to let you use many javascript automation tools. It has a good documentation to make it works.
  3. use gulp or grunt to move only the javascript resources you need in the classpath from myproject/node_modules to myproject/target/...
Aris2World
  • 1,214
  • 12
  • 22
  • 1
    Yes I did this solution, because I'm not in mood to search a solution to exclude the node_modules folder. – Christian Jul 05 '18 at 11:35