QueryDSL maven set up project - java

I'm followed instructions described in this document http://www.querydsl.com/static/querydsl/2.1.0/reference/html/ch02s02.html
After this, in my Eclipse I have a following error:
Plugin execution not covered by lifecycle configuration: com.mysema.maven:maven-apt-plugin:1.0:process (execution: default, phase: generate-sources) pom.xml /projectname line 266 Maven Project Build Lifecycle Mapping Problem
Also, as suggested in QueryDSL documentation I have performed
mvn eclipse:eclipse
in order to include target/generated-sources/java as a source folder and now I have a lot of warnings:
So my questions are:
Is it a correct way to fix Plugin execution error by adding a following to my pom.xml:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.mysema.maven
</groupId>
<artifactId>
maven-apt-plugin
</artifactId>
<versionRange>
[1.0,)
</versionRange>
<goals>
<goal>process</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Is there a better way in order to include target/generated-sources/java as a source folder without performing mvn eclipse:eclipse ?

The correct goal to generate sources is: mvn generate-sources
This will create the QueryDSL querys before the compile.
Also, the documentation you are looking is for QueryDSL 2.x versions.
Check the newest version! http://www.querydsl.com/static/querydsl/4.0.7/reference/html_single/

I have fixed these issues by adding the following plugins:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

Related

Eclipse and maven-war-plugin explode

I'm running against a brick with Eclipse.
I will try to explain. I'm working on a project that "abused" of maven overlays and have many modules that have Javascript and LESS files inside the webapp.
We managed to config maven to explode the dependencies on a directory where maven-frontend-plugin would process (using nodejs) to generate the final compiled JS and CSS files.
This is working perfectly when I'm using pure maven. However, on Eclipse, this not ends to work correctly. The main reason is that Eclipse simple ignores the execution config of maven-war-plugin that explodes the dependencies. Instead, it simple executes the default maven-war-plugin:explode.
I need to fix it, as is the biggest roadblock to get a modern frontend develop environment (using nodejs, npm and gulp to transpile JS and LESS).
Extracted from our main pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>make-webapp-compress</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/webapp-exploded" />
<mkdir dir="${project.build.directory}/webapp-compress" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>parent-resources-less</id>
<phase>generate-sources</phase>
<goals>
<goal>exploded</goal>
</goals>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceExcludes>**/*.ftl,**/*.vm,**/*.xml,WEB-INF/,META-INF/</warSourceExcludes>
<warSourceIncludes>**/*.css,**/*.less,**/*.js</warSourceIncludes>
<webappDirectory>${project.build.directory}/webapp-exploded</webappDirectory>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.8,]</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<versionRange>[3.0.0,]</versionRange>
<goals>
<goal>exploded</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
You can try using the plugin "maven-dependency-plugin". I used this in my project to copy the dependencies to the desired specific output destination. I am attaching the sample config, update this as per your requirement.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/pipeline/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>

Plugin execution not covered by lifecycle configuration: org.jetbrains.kotlin:kotlin-maven-plugin:1.1.51:test-compile

I cloned the spring-boot Git repository into Eclipse and I get the following error. I have not made any code changes.
Plugin execution not covered by lifecycle configuration:
org.jetbrains.kotlin:kotlin-maven-plugin:1.1.51:test-compile (execution:
test-compile, phase: test-compile)
When I attempt to "auto-fix" the error I see this:
No marketplace entries found to handle kotlin-maven-plugin:1.1.51:test-
compile in Eclipse. Please see Help for more information.
Here's my POM:
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
Error In Eclipse
Try
Quick Fix -> Mark goal compile as ignore in pom.xml
Choose both phases: compile & test-compile if coming from Markers list. In popup window quick fix shows only two rows with title pom.xml with line numbers respectively, check both.
It will create you block starting:
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only.
It has no influence on the Maven build itself.-->
...
And just to stress read the comment in block: it does not affect the maven build
In case quick fix fails below is the whole plugin management section I managed to generate.
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<versionRange>[1.1.60,)</versionRange>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain

I am using m2e to build a java project. I need to use JAVA VERSION 1.6 . So i am trying to configure toolchains plugin to achieve it. by referring the below link.
https://maven.apache.org/guides/mini/guide-using-toolchains.html
But in eclipse it is throwing the below error.
Plugin execution not covered by lifecycle configuration:
org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
(execution: default, phase: validate) pom.xml /Replenishment line
98 Maven Project Build Lifecycle Mapping Problem
I referred the link but i did not get a proper clarity. Below is the code snippet used for configuring tool chains plugin.
IN pom.XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
and my toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>D:\POC\jdk1.6.0_31</jdkHome>
</configuration>
</toolchain>
</toolchains>
For eclipse users, Go to Window >> Preferences >> Maven .
Select Lifecycle Mapping option from menu. The default mapping file location could be in somewhere in eclipse temp directory, instead copy the file lifecycle-mapping-metadata.xml file to some location in eclipse directory or maven directory so that it could be easy to refer.
In lifecycle-mapping-metadata.xml file add below configuration.
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0.5,)</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<goals>
<goal>toolchain</goal>
</goals>
<versionRange>[0.0,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
Just do Maven >> Update Project from project view.
This is the easy way to solve the issue.
The error got resolved after changing my pom.xml file like below. We need to add the maven life cycle plugin and then include the metadata information in the .
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Instead of adding the life cycle plugin separately, it can be solved directly by adding <pluginmanagement> tag before the <plugins> tag as given below.
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
......................
......................
</pluginManagement>
</build>

Cannot import antlr4 lexer grammar in combined grammar using Eclipse Kepler

Given:
Simple.g4
grammar Simple;
import SimpleLexer;
prog : entry+ EOF;
entry : a semi tail;
semi : ':';
tail : TAIL;
a : 'a';
W:;
SimpleLexer.g4
lexer grammar SimpleLexer;
TAIL : [a-z]+;
They are both in a same package under 'src/main/antlr4'.
Maven plugins:
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/antlr4</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.2</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<versionRange>[4.2,)</versionRange>
<goals>
<goal>antlr4</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Version of the antlr eclipse plugin:
ANTLR 4 SDK Feature 0.1.1.201401151138 antlr4ide.sdk.feature.group
Eclipse version:
Version: Kepler Service Release 2
Build id: 20140224-0627
The error on import statement in Simple.g4 that eclipse gives is:
can't find or load grammar 'SimpleLexer' from 'Simple.g4'
Environment works for single file grammars.

aspectj not recognized in Maven plugin

I'm looking at the "spring-mvc-showcase" project-- an example on Spring dashboard.
it is one on Github-- now downloaded on my disk.
i'm getting the following error:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.2:compile (execution: default, phase: process-sources)
to this tag in the pom.xml file.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<!-- Have to use version 1.2 since version 1.3 does not appear to work with ITDs -->
<version>1.2</version>
....
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
....
No other error anywhere else in the package-- except for some warnings to unused APIs imported.
is this a version problem, something wrong w/my Maven installation...? im running the latest version of Maven.
This is a request for a quick fix. not good with Maven, new to the whole MVC framework and a warn out already.
M2E doesn't provide life cycle mapping for aspectj plugin. Here is how I had configured aspjectj
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!-- Aspectj compiler -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
</executions>
</plugin>
I had the same problem, but it was due to a missing aspectjweaver maven dependency.
You can get its details here.
I used the latest version, v1.8.4 for Eclipse Luna 4.4.1 and the errors went away.

Categories