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>
Instead try:
<exclude>node_modules/**</exclude>
then try
mvn clean process-resources -X
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>
I suggest you a different approach that works fine for me.
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
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.
use gulp or grunt to move only the javascript resources you need in the classpath from myproject/node_modules to myproject/target/...
Related
I'm using IntelliJ Idea, and trying to create an executable or jar of my app but I'm having issue with JFornix
This is how I run the application from the IDE
but running this from an executable or jar file returns the
module java.base does not "opens java.lang.reflect" to module com.jfoenix
I tried adding the args this way
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.ahs.pos/com.ahs.pos.Launcher</mainClass>
<arg>--add-opens=java.base/java.lang.reflect=com.jfoenix</arg>
</configuration>
</execution>
</executions>
</plugin>
it's a similar issue to this post but with gradle, and I'm trying to do this on maven pom.xml
any ideas how I should go about doing this?
Referring to the documentation, the argument should be using <option> instead
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.ahs.pos/com.ahs.pos.Launcher</mainClass>
<options>
<option>--add-opens</option>
<option>java.base/java.lang.reflect=com.jfoenix</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
I try to implement sonar+failsafe+jacoco plugins. I added theese to my pom.xml file
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<version>7.5</version>
<scope>provided</scope>
</dependency>
and I added this plugins to the same file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<argLine>--add-modules java.base</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<propertyName>jacoco.agent.argLine</propertyName> <!-- default: argLine -->
<includes>
<include>**/*IT.java</include>
</includes>
<destFile>${project.build.directory}/jacoco-it.exec</destFile> <!-- agent -->
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile> <!-- report -->
</configuration>
<executions>
<execution>
<id>agent</id>
<goals><goal>prepare-agent</goal></goals>
</execution>
</executions>
</plugin>
and It is already exists in my pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>${it.skip}</skip>
<argLine>--add-modules java.base</argLine>
<forkCount>4</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>*IT</include>
</includes>
<systemPropertyVariables>
<doc.skip>${doc.skip}</doc.skip>
</systemPropertyVariables>
</configuration>
</plugin>
and I run mvn clean verify -P integration-test and then mvn sonar:sonar
but I still get a coverage is 0.0% Why did not get IT's reports results? Please help me.. What is my issue?
I saw a mistake, which I think is the cause of your problem:
In the configuration for jacoco-maven-plugin you overrid the parameter that would receive the jvm arguments set by jacoco to communicate with maven surefire, with <propertyName>jacoco.agent.argLine</propertyName>. That means that it will fill in this property instead of the default property argLine (which is fine but not necessary I guess).
In the configuration for maven-surefire-plugin, you overrid the <argLine>--add-modules java.base</argLine> (which by default would have taken the value ${argLine}) without refering to the property jacoco.agent.argLine.
You need something like <argLine>${jacoco.agent.argLine} --add-modules java.base</argLine> or <argLine>#{jacoco.agent.argLine} --add-modules java.base</argLine> (with an #) depending on your jacoco version.
If using $and not #, you may need to define an empty <jacoco.agent.argLine/> property on top of the pom file.
I have a java project done with Eclipse and Maven with this estructure folder:
enter image description here
Ok, when i make a Maven install to create the .jar take this structure folder:
enter image description here
So that the hierarchy is not the same and links to the images and css do not work.
I show you the code of pom.xml
enter code here
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.wepall
palle
0.4.0
com.thoughtworks.xstream
xstream
com.thoughtworks.xstream
xstream
1.4.9
palle
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>com.wepall.palle.MainApp</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any ideas?
thanks a lot!!
Best regards
You should add a build section to your pom.xml:
<build>
<directory>${basedir}/target</directory>
<resources>
<resource>
<targetPath>${basedir}/target/resources</targetPath>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
Further Reference:
POM Reference (Build Section)
I think that you should create a war instead of a jar, because you are talking about css and images and jars should not contains that kind of files (see jar vs war).
In maven you only need to change the <packaging> of the project inside the POM.
Welcome,
I have problem with packaging aspectj program. Using this piece of code in pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.mkyong.core.utils.App</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<configuration>
<ajdtBuildDefFile>build-1-5.ajproperties</ajdtBuildDefFile>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- OTHER PLUGINS -->
</plugins>
</build>
Using this commands on console:
mvn aspectj:compile
mvn exec:java
Running program well with all aspects. But execute this route:
mvn package
java -jar target\<my-package>.jar
Hasn't worked. In exception is information about:
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
What is the problem?
The problem is that the AspectJ Runtime aspectjrt.jar is not on your classpath when running the program manually. You should run the program like this:
java -cp path\to\aspectjrt.jar -jar target\<my-package>.jar
The only way to avoid that is to use a plugin like One-Jar (dependencies are packed into the application JAR and loaded witgh a special classloader) or Maven Shade (dependencies are unpacked into your JAR).
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<onejarVersion>0.96</onejarVersion>
<mainClass>de.scrum_master.app.FooBar</mainClass>
<attachToBuild>true</attachToBuild>
</configuration>
</plugin>
<!-- (...) -->
<pluginRepositories>
<pluginRepository>
<id>OneJAR googlecode.com</id>
<url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
</pluginRepository>
</pluginRepositories>
Then you can just forget about putting all dependencies on the classpath and use:
java -jar target\<my-package>.one-jar.jar
I have a Java project entirely consisting of junit/integration tests which is managed by maven. One of the dependencies is a zip archive, the contents of which I would like to be available on the classpath when the tests are run. Since maven does not put the content of a zip dependency on the classpath I have had to come up with what I consider to be a hacky workaround. I unpack the zip archive to a temp directory then copy one of the resulting directories into the /test-classes folder. I also had to make the clean step delete the temp directory. Here are the relevant parts of the pom:
<groupId>com.my.package</groupId>
<artifactId>test-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>My Test Project</name>
<properties>
<config.artifactId>environment-dev</config.artifactId>
<config.version>2.0.8-SNAPSHOT</config.version>
<tempDir>${project.basedir}/temp</tempDir>
</properties>
<build>
<plugins>
...
<!-- clean out our custom temp directory as well as the default dir during clean phase-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.3</version>
<configuration>
<filesets>
<fileset>
<directory>${tempDir}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<!-- since the config dependency is a zip it does not get added to the classpath. So we extract
it to a temp dir, then copy the content we need into a directory on the classpath -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-config</id>
<phase>compile</phase>
<goals><goal>unpack-dependencies</goal></goals>
<configuration>
<includeGroupIds>com.my.package.config</includeGroupIds>
<includeArtifactIds>${config.artifactId}</includeArtifactIds>
<includeClassifiers>config</includeClassifiers>
<outputDirectory>${tempDir}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- copy the content of the zip file that we extracted into a directory on the classpath -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>compile</phase>
<goals><goal>copy-resources</goal></goals>
<configuration>
<outputDirectory>${project.build.directory}/test-classes/TargetDir</outputDirectory>
<resources>
<resource>
<directory>${tempDir}/${config.artifactId}-${config.version}/TargetDir</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
...
<dependency>
<groupId>com.my.package.config</groupId>
<artifactId>${config.artifactId}</artifactId>
<version>${config.version}</version>
<classifier>config</classifier>
<type>zip</type>
</dependency>
</dependencies>
There must be a better way of doing this.
Can I force maven to treat the zip file as if it were a jar? The link I provided has a tantalising hint that this might once have been possible, but I can't find anything relevant in the documentation. This seems like such a simple thing to be able to do, I really hope I've just missed a config parameter somewhere. Can anyone suggest a better way of getting the content of a zip dependency onto the classpath?
I would unzip the dependency into a subdirectory of the target directory and add that directory to the additionalClasspathElements configuration of the surefire plugin.
<properties>
<config.artifactId>environment-dev</config.artifactId>
<config.version>2.0.8-SNAPSHOT</config.version>
<unzipDir>${project.build.directory}/addTestClasspath</unzipDir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack-config</id>
<phase>compile</phase>
<goals><goal>unpack-dependencies</goal></goals>
<configuration>
<includeGroupIds>com.my.package.config</includeGroupIds>
<includeArtifactIds>${config.artifactId}</includeArtifactIds>
<includeClassifiers>config</includeClassifiers>
<outputDirectory>${unzipDir}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${unzipDir}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
In this case you can omit the clean plugin config because everything is under the target folder which will be deleted by the clean plugin by default.
Sadly this configuration does only work on the command line and not within eclipse, because the m2e plugin does not honor the additionalClasspathElement. See the jira issue MNGECLIPSE-1213