"target" subdirectories in package explorer in recent eclipse (at least 4.13 + maven 3.6.x) - eclipse

So in Eclipse 4.13 (and maybe a few versions before) with embedded maven 3.6.x, when I open a simple, almost empty, maven project, it shows me these non existant subdirectories in project explorer :
target/generated-sources/annotations
target/generated-sources/test-annotations
If I remove them from source directories (in project > properties > java build path), eclipse creates these directories and add them as sources again, so I guess it comes from some maven plugin conf somewhere.
How do I get rid of these 2 directories display when I don't have use of them ?
And since this problem probably comes from a combination of maven 3.6 + Eclipse 4.13 + some maven dependency, here is my pom.xml :
<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>my.comp</groupId>
<artifactId>file-mgt-backend</artifactId>
<version>${revision}</version>
<name>My project</name>
<properties>
<java.version>1.8</java.version>
<springfox.version>2.9.2</springfox.version>
<!-- Downgrade to 3.1.1 needed for Eclipse bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=547340 -->
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<!-- Sane default when no revision property is passed in from the commandline -->
<revision>0-SNAPSHOT</revision>
</properties>
<scm>
<developerConnection>(...)</developerConnection>
</scm>
<!-- Paramètres de publication de l'artifact -->
<distributionManagement>
<repository>
(...)
</repository>
</distributionManagement>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.11.2</version>
</plugin>
</plugins>
</build>
</project>

Related

Module-info.java won't compile in maven project (Syntax error on token "module", interface expected)

I am starting a new maven project that should run with Spring Boot (in case that's relevant), and it compiled fine. But then, I decided to start using Java9-modules. So, I had eclipse generate the module-info.java file that looks like this:
module BirdTreeModel {
exports mjl.familytree.birdtree;
requires junit;
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.boot.test;
requires spring.test;
}
This causes a compile error, however. Eclipse says: "Syntax error on token "module", interface expected".
(And when I do a Maven clean install, it says "Compilation failure: ...module not found: junit" and same for modules spring.boot.test and spring.test).
echo %JAVA_HOME% gives C:\Program Files\Java\jdk-12
mvn -version gives:
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:1
4+02:00)
Maven home: `D:\Programming practice\maven\apache-maven-3.5.4\bin\..`
Java version: 12, vendor: Oracle Corporation, runtime: `C:\Program Files\Java\jdk-12`
Default locale: `en_US`, platform encoding: `Cp1252`.
OS name: "Windows 7", version: "6.1", arch: "AMD64", family: "Windows"
The run configurations of the Maven build of the project are also on JDK-12
My pom looks like this:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>mjl.familytree</groupId>
<artifactId>birdtree-model-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>birdtree-model-dao</name>
<description>My family tree program</description>
<repositories>
<repository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>http://repo.spring.io/release</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.12</maven.compiler.source>
<maven.compiler.target>1.12</maven.compiler.target>
<maven.compiler.release>12</maven.compiler.release>
<java.version>12</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

Cucumber-Maven Set up with Eclipse, Source option 5 is no longer supported. Use 7 or later

I am totally new in Java , and trying to install Cucumber.
I have downloaded JDK and JRE and their versions are: jdk-12.0.1 && jre1.8.0_211 and set the environment variables.
I have also downloaded Eclipse
I am following the tutorial https://www.toolsqa.com/cucumber-video-tutorials/
I have downloaded all jar files here, C:\JavaJars\Cucumber
then I have referenced them in my pom.xml file (C:\JavaProjects\CucumberMaven)
Here is a snippet of dependencies:
<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>ToolsQA</groupId>
<artifactId>CucumberMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CucumberMaven</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
in command prompt -->
mvn clean install
I get the error -->
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
I am not sure how to fix it
maven-compiler-plugin by default will compile your project using Java 1.5 which is where m2e gets its information.
Your effective pom.xml will implicitly use the default settings in the maven-compiler-plugin pom.xml.
That's why you have to explicitly declare the maven-compiler-plugin in your project with something other than 1.5.
Add this to your pom.xml
<build>
<pluginManagement>
<plugins>
<!-- Default java version was 1.5, to change the default version added this plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

install OJDBC7 using maven POM file

I have a project A that where i created a folder called lib to add libraries in it. Currently i have Ojdb7.jar in this folder. Now, When I add the dependency for ojdbc7 in the POM file I get error "Missing artifacts".
I know there is an option to install it using :
$ mvn install:install-file -Dfile={Path/to/your/ojdbc7.jar}
-DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar
and it works fine when I run the command but What I want to do is to run mvn package command from cmd (mvn packge will run install before packaging the project to jar file). I tried the pom file below but i get error could not find artifact for the path I specified in repository tag
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.example</groupId>
<artifactId>DarAppDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DarAppDemo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<repositories>
<repository>
<id>demo-local-repo</id>
<name>demo-lib</name>
<url>file:\\${project.basedir}\lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
<!--dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I found one solution by adding a plugin to build tag
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-ojdbc-jar</id>
<phase>validate</phase>
<configuration>
<file>${project.basedir}/ojdbc7.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
but my issue is that i don't want to hard code this path ${project.basedir}/ojdbc7.jar
Because I run this in Jenkins and it failed. Any help is much appreciated.
Thanks
**Adding screen shot
Here another shot from eclipse Problems:

Compilation error when using #RequestMapping - Cannot resolve type

IDE : Spring Tool Suite
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I have added the MVC dependency as org.springframework but I guess it has to be org.springframework.boot.
I get this Compilation error when using #RequestMapping - Cannot resolve type.
I have run Maven -> clean and Maven -> Install. Restarted STS, re-installed STS, rebooted my laptop, and yet the compilation error persists.
How do I remove this error?
Update:
I deleted the .m2 folder, Maven -> Clean and Maven -> Install. Exited STS, ran it again. And voila, everything works like a charm. Not a single error. Magic? I don't know.

gwt-servlet.jar missing in the WEB-INF/lib on compiling GWT with maven

In my pom file, I have included the dependency of gwt-servlet but if i run mvn clean install and mvn eclipse:eclipse and open the project in eclipse, I get the following error
GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory
EDIT :
Here is my dependency (we use a custom maven repository):
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
EDIT 2 (main pom):
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
....
There are two things I noticed.
1) The smartgw dependency you specified cannot be resolved from the maven central repository
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
It only has the 2.4 version of smartgw (see here http://search.maven.org/#search%7Cga%7C1%7Csmartgwt) Instead I had to use this
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
notice that the artifact ID is different too. (If you have a custom repository containing this then please update your question)
2) You dont need to do eclipse:eclipse instead you can issue the
File > Import > Existing Maven projects
this will auto generate the eclipse project from your pom.xml
UPDATE
I tested with the following :
Parent pom in gwttest2 folder
<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.test</groupId>
<artifactId>gwttest2-main</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>gwttest2-module1</module>
</modules>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
child pom in gwttest2/gwttest2-module1 folder
<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.test</groupId>
<artifactId>gwttest2-module1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<artifactId>gwttest2-main</artifactId>
<groupId>com.test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
Tell Eclipse to use Maven dependencies by right-clicking on your Project folder and selecting
Configure > Convert to Maven Project.
It seems that even after running mvn eclipse:eclipse, you must do this manually to get Eclipse to actually let Maven take care of your dependencies.
If you don't see this option you may not have the M2Eclipse plugin installed in your Eclipse...