<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
What is the point of using maven in intellij if it dose not work without setting the correct JDK under various intellij options?
What I mean is that now with intellij I have to set the JDK in 3 different places.
File->Setting->Build->Compiler
File->Project Structure->Project
File->Project Structure->Modules
While I aspect expect that when i compiler on the right side where are the maven options it works just by watching the pom file.
i think that depends on what type of project you want to make but personally i find maven nice to use because you can set up several actions in the pom file (for example when compiling Less files, excluding them from the build and just using the resulting css files).
another feature would be the easy way to add dependency's from the maven rep http://mvnrepository.com/
Im facing the following problem. I have set up my checkstyle with the following configuration:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<inherited/>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
This runs fine when I run mvn site. However, when I run checkstyle through mvn checkstyle:checkstyle in order to get the XML report much more efficiently, the checkstyle plugin fails back to use the default configuration. When I move the plugin to <build> the XML is generated properly, but now the checkstyle report is not included in the generated site anymore.
What is the (current) way of setting up report plugins as Checkstyle, while perserving the ability to run the plugin separately under the same configuration?
Is it really the preferred way to defined your plugins and configuration twice?
Okay, apparently you should add the plugin with configuration to both <build> and <reporting>.
I'm trying to add a JSP ruleset to an existing Maven build using PMD. Unfortunately, it seems like no matter what I do I get an error. If I add the reference to our existing ruleset:
<rule ref="rulesets/jsp/basic.xml/NoUnsanitizedJSPExpression" />
I get this message (linebreaks added for readability:
Execution DRY of goal org.apache.maven.plugins:maven-pmd-plugin:2.7.1:pmd failed:
Couldn't find that class Can't find resource rulesets/jsp/basic.xml.
Make sure the resource is a valid file or URL or is on the CLASSPATH -> [Help 1]
I've consulted this question and tried various permutations of leading slashes:
<rule ref="/rulesets/jsp/basic.xml/NoUnsanitizedJSPExpression" />
but I still get the error message referenced above.
I've tried adding the ruleset to the Maven plugin (second ruleset):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<rulesets>
<ruleset>${project.basedir}/src/main/resources/properties/pmd_workspace.xml</ruleset>
<ruleset>rulesets/jsp/basic.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>DRY</id>
<phase>test</phase>
<goals>
<goal>cpd</goal>
<goal>pmd</goal>
</goals>
</execution>
</executions>
</plugin>
but that simply gives me this error:
An error has occurred in PMD Report report generation. Could not find resource 'rulesets/jsp/basic.xml'. -> [Help 1]
I've looked at the documentation for PMD and for the Maven PMD plugin but had no luck. Can anyone help or point me to a tutorial?
This turned out be because I was using an old version of the Maven PMD plugin. The Maven plugin pulls in PMD by itself, which is convenient, but doesn't give you any control over what version it pulls in.
The version I was using, 2.7.1, pulled in PMD version 4.3, which did not have the rule I was trying to include. Therefore, it (correctly) stated that it couldn't find that rule.
The current version of the Maven PMD plugin, 3.3, pulls in PMD version 5.2.1, which does include the NoUnsanitizedJSPExpression JSP-checking rule.
Once I updated the maven PMD plugin to version 3.3, everything worked:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.3</version>
<configuration>
<rulesets>
<ruleset>${project.basedir}/src/main/resources/properties/pmd_workspace.xml</ruleset>
</rulesets>
</configuration>
</plugin>
I am trying to implement a new XPath PMD rule based on the example from the book "Jenkins Continuous Integration Cookbook".
My pom file's relevant section:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<targetJdk>1.6</targetJdk>
<format>xml</format>
<rulesets>
<ruleset>password_ruleset.xml</ruleset>
</rulesets>
</configuration>
</plugin>
</plugins>
</reporting>
I have the file 'password_ruleset.xml' sitting in the root of my maven project and it looks as follows:
<?xml version="1.0"?>
<ruleset name="STUPID PASSWORDS ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Lets find stupid password examples
</description>
<rule name="NO_PASSWORD"
message="If we see a PASSWORD we should flag"
class="net.sourceforge.pmd.rules.XPathRule">
<description>
If we see a PASSWORD we should flag
</description>
<properties>
<property name="xpath">
<value>
<![CDATA[
//VariableDeclaratorId[#Image='PASSWORD']
]]>
While executing i got the following error:
Failure executing PMD: Couldn't find the class net.sourceforge.pmd.rules.XPathRule
Checking which libraries contains this class i realized it's 'pmd' itself. I tried to add the dependency to the dependencies section without luck.
Where and what should i change to overcome this?
Please see the whole setup in github:
https://github.com/dave00/pmdcustomrule
A friend of mine resolved my problem via github:
https://github.com/mnyeste/pmdcustomrule/commit/ad2f04e33d2a5a04ef95d059d64a258ebca5b7be
Summary:
PMD API change 4.3 -> 5.0 Class net.sourceforge.pmd.rules.XPathRule
has been renamed to net.sourceforge.pmd.lang.rule.XPathRule
Maven PMD plugin version 3.2 is using PMD 5.1.2
Anyone interested can now pull my example project from github to see this working.
I can't run the Maven Netbeans JavaFX example :
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) onproject mavenproject3:
Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e
switch. Re-run Maven using the -X switch to enable full debug logging.
My POM looks like this :
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.huw.almexoffice.client</groupId>
<artifactId>almex-office-client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Almex Office Client</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.huw.almexoffice.client.MainApp</mainClass>
</properties>
<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>Your Organisation</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-nocss2bin</argument>
<argument>-appclass</argument>
<argument>${mainClass}</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}</argument>
<argument>-outfile</argument>
<argument>${project.build.finalName}.jar</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Does anyone know why this is happening?
And if not, does anyone know how to get Maven running with the -e or the -X switch via Netbeans? I assume it is via a right click on the POM and then run goal then entering something in the textfield there.
This error would spring up arbitrarily and caused quite a bit of trouble though the code on my end was solid.
I did the following :
I closed it on netbeans.
Then open the project by clicking "Open Project", selecting my project and
Simply hit the run button in netbeans.
I would not build or clean build it. Hope that helps you out.
I noticed another reason why this happens. If you moved your main class to another package, the same error springs up. In that case you :
Right Click Project > Properties > Run
Set the "Main Class" correctly by clicking "Browse" and selecting.
I faced the same issue. When I tried to run the project from IDE, it was giving me same error. But when I tried running from the command prompt, the project was running fine. So it came to me that there should be some issue with the settings that makes the program to Run from IDE.
I solved the problem by changing some Project settings. I traced the error and came to the following part in my pom.xml file.
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>${runfx.args}</commandlineArgs>
</configuration>
</execution>
I went to my Project Properties > Actions Categories > Action: Run Project:
then I Set Properties for Run Project Action as follows:
runfx.args=-jar "${project.build.directory}/${project.build.finalName}.jar"
Then, I rebuild the project and I was able to Run the Project. As you can see, the IDE(Netbeans in my case), was not able to find 'runfx.args' which is set in Project Properties.
what's happening? you haven' shown much of the output to be able to decide. if you are using netbeans 7.4, try disabling Compile on Save.
to enable debug output, either run Custom > Goals... action from project popup or after running a regular build, click the Rerun with options action from the output's toolbar
I am a beginner in Maven - don't know much about it.
Carefully check on your input i.e. file path in my case.
After I have carefully check, my file path is wrong so it leads to this error.
After I fixed it, it works magically lol.
A solution which worked in my case is:
1. Go to the module having Main class.
2. Right click on pom.xml under this module.
3. Select "Run Maven" -> "UpdateSnapshots"
Had the same problem, I worked around it by changing
${java.home}/../bin/javafxpackager
to
${java.home}/bin/javafxpackager
Had the same problem after installing oracle jdk on Ubuntu 13.10 x64.
I've done the following steps, not sure which one helped. I think that at least 2 and 3 are necessary.
Deleted Netbeans 7.4 and reinstalled it from oracle's site.
Installed plugins for maven, ant and java that may be related to the project.
Deleted .nbproject folder - after that the project was considered a maven project.
Also, after that, I've found that the project runs, but exits with exit code 1 because I didn't supply the command line parameters for it. And the builder considers it is an error. So, look carefully for the output and see if the program actually starts.
Maven needs to be able to access various Maven repositories in order to download artifacts to the local repository. If your local system is accessing the Internet through a proxy host, you might need to explicitly specify the proxy settings for Maven by editing the Maven settings.xml file. Maven builds ignore the IDE proxy settings that are set in the Options window.
For many common cases, just passing -Djava.net.useSystemProxies=true to Maven should suffice to download artifacts through the system's configured proxy. NetBeans 7.1 will offer to configure this flag for you if it detects a possible proxy problem. https://netbeans.org/bugzilla/show_bug.cgi?id=194916 has discussion.
I solved this issue with right click on project -> Set as Main Project.
Netbeans needs to be able to index the maven repository. Allow it to do that and try again. It was giving me the same error and after it indexed the repository it ran like a charm
Try to run Maven from the command line or type "-X" in the text field - you can't break anything this way, at the worst, you'll get an error (I don't have Netbeans; in Eclipse, there is a checkbox "Debug" for this).
When running with debug output enabled, you should see the paths which the exec-maven-plugin plugin uses.
The next step would then be to copy the command into a command prompt or terminal and execute it manually to see if you get a useful error message there.
Restart Netbeans & it solved my problem.
Im new to java hibernate but i could solve this problem, this is how i did it :
I was working with hibernate and maven project.
First you have to put persistence.xml under project directory, then add jdbc manually.
Maven couldn't download my dependency so i added it manually.
In the persistence.xml in design jdbc connection add it manually ps: i work with netbeans good luck
For me, the clue was the "org.codehaus.mojo:exec-maven-plugin:1.2.1:exec".
The only place this was referenced was in the "Run project" action under Project Properties=>Actions.
When I changed this action to match the HelloFXMLWithMaven sample project (available in Netbeans 11.1):
"clean javafx:run"
then executing the Run goal was able to proceed.
Note, I also had to update the pom file's javafx-maven-plugin to also match the sample project but with the mainClass changed for my project.
Rohith H.Y Solved this problem
I noticed another reason why this happens. If you moved your main class to another package, the same error springs up.
In that case you :
Right Click Project > Properties > Run
Set the "Main Class" correctly by clicking "Browse" and selecting.