I have been using intellij for 2 years now and love it. however after updating to 2016.3.4 it stopped highlighting path locations in the run window.
I used to be able to just click on the highlighted path and it would jump to the file and line.
example of output from maven-checkstyle-plugin which should be "clickable" :
[ERROR] C:\Users\userName\Documents\project.main\src\main\java\MyClass.java:36: Only one statement per line allowed. [OneStatementPerLine]
This is extremely frustrating and any idea of how to get intellij to do this again would be fantastic.
Minimal, Complete, and Verifiable example
To Replicate this Create a project in IntelliJ IDEA called "bug"
IntelliJ IDEA 2016.3.4
Build #IU-163.12024.16, built on January 31, 2017
Create a folder
bug->CodeStyle
and a file in this folder
"checkstyle.xml"
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java,"/>
<module name="FileTabCharacter"/>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="System\.(out|err).*?$"/>
<property name="ignoreComments" value="true"/>
</module>
</module>
</module>
the pom
<?xml version="1.0" encoding="UTF-8"?>
<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>bugExample</groupId>
<artifactId>bug</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>CodeStyle/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>6.18</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
and a Class Example.java
public class Example {
public Example() {
System.out.println("This is not allowed");
}
}
And now in the maven project Tool Click life-cycle, and then Validate.
The outputs in the "run terminal" :
[INFO] Starting audit...
[ERROR] C:\Users\Username\bug\src\main\java\Example.java:7: Line matches the illegal pattern 'System\.(out|err).*?$'. [RegexpSinglelineJava]
Audit done.
So the problem is that Example.java is Not "Clickable", it has been in the past.
Thanks for the example, I've reported a bug for IntelliJ IDEA Maven integration, feel free to vote:
IDEA-169034 File paths are not clickable in the Maven tool output
Related
I'm using maven-antrun-plugin in my pom.xml with external ant file.
It's said in plugin's document:
All of the properties available to Maven are also available in the
target configuration. However, you may want to call an external Ant
build script using the ant task. To avoid name conflicts, only a
subset of the properties are passed to the external Ant build. These
include all properties defined in the properties section of the POM.
It also includes prefixed versions of some of the commonly used Maven
properties.
So here's my pom, where I define "test.prop" property:
<?xml version="1.0" encoding="UTF-8"?>
<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>testant</groupId>
<artifactId>testant</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<test.prop>TestPropValue</test.prop>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>optional</artifactId>
<version>1.5.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-index-properties</id>
<phase>install</phase>
<configuration>
<tasks>
<!--<property name="test.prop" value="${test.prop}"/>-->
<ant antfile="build.xml">
<target name="echo-prop"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And just trying to echo this property in build.xml:
<project default="test">
<target name="echo-prop">
<echo>${test.prop}</echo>
</target>
</project>
This is what I get:
echo-prop:
[echo] ${test.prop}
So property is not resolved as it should, according to the doc.
And it works fine only in case if I uncomment line with explicit property declaration under "tasks" tag.
Could you please help me in understanding, what am I doing wrong?
Thank you!
You should specify a version for the antrun-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version><!--$NO-MVN-MAN-VER$-->
(...)
</plugin>
ant by default passes all properties of the parent to an underlying "ant"-call. Unless you define inheritAll=false, all properties are passed.
In this case, you should have a look at the effective pom. There a very ancient version of the antrun-plugin is defined.
As soon as you switch to a recent one, the example code works.
I'm using the Maven EAR plugin to generate the application.xml of my EAR, which contains a WAR.
I want the contextRoot of that WAR to be determined at runtime (this works thanks to JBoss AS 7), so the application.xml should contain something like this:
<module>
<web>
<web-uri>my.war</web-uri>
<context-root>${my.context.root}</context-root>
</web>
</module>
This works by setting the System Property my.context.root within JBoss AS 7 and configuring JBoss to replace variables within XML descriptor files:
<system-properties>
<property name="my.context.root" value="/foo"/>
</system-properties>
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>
If I do this by editing the generated application.xml in the EAR, it works.
However, I can't get Maven to write ${my.context.root} into the context root within application.xml.
I tried this first (since nothing is filtered, it should work):
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
Apparently, even though filtering defaults to false, Maven still thinks it should use this as Maven property. The result is that the EAR plugin just puts in the WAR's name:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>/my-war</context-root>
</web>
</module>
So I tried escaping:
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>\${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
This is then taken literally:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>\${my.context.root}</context-root>
</web>
</module>
How can I get Maven to do what I want? (Of course, I could try to hack application.xml by using the Maven replacer plugin, but that's ugly...)
Thanks for any hints!
Well, since nobody knows a better answer, here's how I hacked application.xml into shape:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<executions>
<execution>
<id>replace-escaped-context-root</id>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>${project.build.directory}/${project.build.finalName}/META-INF/application.xml</file>
<regex>false</regex>
<token>\${</token>
<value>${</value>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>\${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
i want to use the Maven Checkstyle plugin with a custom configuration that tells Checkstyle to not warn or error on missing Javadoc. Is there a way to do this?
Just found it myself. To fully ignore all javadoc checking for everthing, add this to your checkstyle configuration:
<!-- No need for Javadoc -->
<module name="JavadocType">
<property name="severity" value="ignore"/>
</module>
<module name="JavadocMethod">
<property name="severity" value="ignore"/>
</module>
<module name="JavadocVariable">
<property name="severity" value="ignore"/>
</module>
One good option would be configuring a suppressions filter.
Plugin configuration:
<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">
<!-- ... -->
<build>
<plugins>
<!-- ... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>verify</id>
<phase>verify</phase>
<configuration>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
<suppressionsLocation>
checkstyle-suppressions.xml
</suppressionsLocation>
<suppressionsFileExpression>
checkstyle.suppressions.file
</suppressionsFileExpression>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- ... -->
</project>
checkstyle-suppressions.xml file:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.0//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
<suppressions>
<suppress checks="Javadoc" files="."/>
</suppressions>
Then running
$ mvn verify
Does not output any Javadoc-related Checkstyle errors.
Many other examples on suppressions filters may be found in checkstyle repository.
Below is the example with the Gradle 7.3.2 setup.
build.gradle
plugins {
id 'checkstyle'
}
Folder structure (root level).
├── config
└── checkstyle
├── checkstyle.xml
└── suppressions.xml
Below is the entry in checkstyle.xml to include suppressions.xml
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml" />
</module>
And now you can have the suppressions in the suppressions.xml file to ignore a particular type of check.
for e.g. Below code base will ignore the mentioned checks for all files (regex can be applied to ignore particular matching set of files.)
<suppressions>
<suppress files="." checks="JavadocMethod"/>
<suppress files="." checks="JavadocPackage"/>
<suppress files="." checks="JavadocVariable"/>
<suppress files="." checks="MissingJavadocMethod"/>
<suppress files="." checks="JavadocPackage"/>
</suppressions>
Now execute the Checkstyle task on consolidated project files by
gradle check
If specific execution is needed then use checkstyleMain or checkStyleTest to execute checkstyle report on Source files or test files respectively.
I am trying to pass maven properties (defined through profiles) to a antrun execution:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<!-- ... these are ok -->
</dependencies>
<executions>
<execution>
<configuration>
<target>
<property name="ant_destDir" value="${destDir}" />
<property name="ant_serverDeploy" value="${serverDeploy}" />
<property name="ant_deployDir" value="${deployDir}" />
<property name="ant_userDeploy" value="${userDeploy}" />
<property name="ant_passwordDeploy" value="${passwordDeploy}" />
<!-- correct task definitions for sshexec and scp -->
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
<scp remoteTodir="${userDeploy}#${serverDeploy}:${destDir}"
password="${passwordDeploy}" trust="yes" sftp="true">
<fileset dir="${deployDir}" includes="*.jar" />
</scp>
<sshexec host="${serverDeploy}" username="${userDeploy}"
password="${passwordDeploy}" trust="yes"
command="some command" />
</target>
</configuration>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The properties are defined in profiles to allow for deployment in different servers (I know it's not the best possible approach, but this is the way things are done here), like this:
<profile>
<id>aprofile</id>
<properties>
<property name="serverDeploy" value="somevalue" />
<property name="userDeploy" value="someuser" />
<property name="passwordDeploy" value="somepassword" />
<!-- and so on -->
</properties>
</profile>
My problem is that I can't get maven properties to work in ant plugin; I tried to add a <echoproperties> task in ant to see which properties I have and there is no trace of maven properties.
Is it possible to use maven defined properties or should I use another approach? Any suggestion is welcome.
Edit: I modified the script as per first answer, it still doesn't work
You can pass the properties by defining new Ant properties (using the property tag in your target within the configuration). So for example:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test-module</artifactId>
<name>test-module</name>
<version>SNAPSHOT</version>
<properties>
<my.custom.property>false</my.custom.property>
</properties>
<profiles>
<profile>
<id>customProfile</id>
<properties>
<my.custom.property>true</my.custom.property>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="antProperty" value="${my.custom.property}"/>
<echo message="Custom Ant Property is: ${antProperty}"/>
<echoproperties />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I execute mvn compile on this pom the output is:
main:
[echo] Custom Ant Property is: false
[echoproperties] #Ant properties
[echoproperties] #Thu Aug 08 17:17:30 CEST 2013
[echoproperties] ant.project.name=maven-antrun-
[echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
[echoproperties] antProperty=false
and when the command is mvn -PcustomProfile compile then the output is:
main:
[echo] Custom Ant Property is: true
[echoproperties] #Ant properties
[echoproperties] #Thu Aug 08 17:18:30 CEST 2013
[echoproperties] ant.project.name=maven-antrun-
[echoproperties] ant.version=Apache Ant(TM) version 1.8.2 compiled on December 20 2010
[echoproperties] antProperty=true
This works using maven 3.0.5.
Most properties are automatically passed along to ant, at least if you're running an inlined ant script. Some of the properties get renamed. I suggest running "mvn -X" and the antrun plugin prints a list of all the variable mappings into ant (things like basedir becomes project.basedir, etc.)
On the newer versions of maven you can just use:
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
example:
<build>
....
<plugins>
....
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<echo message="Project name from Maven: ${project.name}" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
....
</plugins>
....
</build>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
Currently running into a weird problem with a Maven build that is making a call to ant, within the parent pom the following property is defined: -
<jboss.home>${env.JBOSS_HOME}</jboss.home>
I am trying to override this by passing in -Djboss.home when I run Maven.
This build contains a profile that when activate calls an Ant build: -
<ant antfile="build.xml" inheritRefs="true">
<target name="all"/>
</ant>
The Ant script uses the property: -
<property name="jboss.dir" value="${jboss.home}"/>
An subsequently outputs it: -
<echo message="jboss dir is: ${jboss.dir}"/>
The problem is that the value it output is ${env.JBOSS_HOME}
Other properties in the parent pom I can override from the command line.
Even the jboss.home property does appear to be overridden if use elsewhere within the Maven build.
After trying various combinations of command it almost appears that the set of properties passed to Ant are resolved from the poms BEFORE any overrides from the command line. If I set the JBOSS_HOME environment variable then all places this variable is used have the correct values.
Is there something I am missing to be able to override this variable on the command line and have the overridden value used in the Ant script?
Stumbled into this problem today, and did discover an answer. This link provides some background: http://technotes.khitrenovich.com/properties-resolution-maven-implications-antrun-plugin/
Maven properties will work just fine if the property is referenced inline within the <target>. e.g:
<execution>
..
<configuration>
<target>
<echo message="Command-line override of external.property will work OK like this: ${external.property}"/>
</target>
</configuration>
</execution>
However, if you use an external ant file written like this, many/most properties will work, BUT command-line overrides will not be passed into the ant file. You will get the non-overridden value instead.
<execution>
..
<configuration>
<target>
<property name="external.property" value="${external.property}" />
<ant antfile="build.xml" target="all" />
</target>
</configuration>
</execution>
Instead, for external ant files, use this syntax. The command line value will be passed through correctly to the external antfile:
<execution>
..
<configuration>
<target>
<ant antfile="build.xml" target="all" >
<property name="external.property" value="${external.property}" />
<ant/>
</target>
</configuration>
</execution>
The problem is that ${env.JBOSS_HOME} is a system environment variable and you are instead passing to the JVM a system property -Djboss.home=.... These are two different things. Apart from that, any variables, args and so on in the Java world are case sensitive.
You seem do be doing all the right things, it works for me, I have made a working example with 2 pom.xml files. The parent 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.stackoverflow.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<name>Test</name>
<packaging>pom</packaging>
<modules>
<module>test-ant-properties</module>
</modules>
<properties>
<jboss.home>${env.JBOSS_HOME}</jboss.home>
</properties>
</project>
Then I created a module pom.xml in the sub-folder test-ant-properties that 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>
<parent>
<groupId>com.stackoverflow.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
</parent>
<artifactId>test-ant-properties</artifactId>
<name>Test maven ant properties</name>
<profiles>
<profile>
<id>jboss</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>jboss-ant</id>
<phase>install</phase>
<configuration>
<target>
<property name="jboss.dir" value="${jboss.home}"/>
<echo message="jboss dir is: ${jboss.dir}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I don't have JBOSS installed so for testing purpose I set the environement variable to test1234 like this:
set JBOSS_HOME=test1234
When I execute the parent pom with the jboss profile
mvn install -Pjboss
I get the following result: [echo] jboss dir is: test1234
When I execute the same command with the jboss.home setting
mvn install -Pjboss -Djboss.home=my_custom_variable
I get the following result: [echo] jboss dir is: my_custom_variable