I just installed m2e (the Maven Eclipse plugin) and created a new Maven Project with a Quickstart archetype. I then went to the official Maven repo to pull down GWT 2.5.1's dependencies, and see that it wants you to add the following <dependency> element to your project's pom.xml file:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
So, altogether, my pom.xml looks like:
<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.me.myorg</groupId>
<artifactId>maven-resolver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-resolver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</project>
I am getting the following error:
Missing artifact com.google.gwt:gwt:jar:2.5.1
And furthermore, in Eclipse's Package Explorer, under my project's Maven Dependencies library, nothing is resolving.
What's going on here? Thanks in advance!
Update: the contents of ~/.m2/repository/com/google/gwt/gwt/2.5.1 are as follows:
gwt-2.5.1.jar.lastUpdated gwt-2.5.1.pom.sha1
gwt-2.5.1.pom _maven.repositories
This gwt dependencie it's a parent pom for the gwt project. This means that the repo will only contain the hash and the pom, but not the jar.
You need to use two libraries: gwt-servlet and gwt-user:
I've found this configuration for GWT development (maybe you don't need to put the <scope> as described):
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependencies>
Remove your dependencies and update your pom with these two shown above.
You can also use the gwt-maven-plugin to manage your gwt project and deploy via maven. I've found this information there.
I hope that works!
Related
I am using the Eclipse IDE and in the past, I have been developing a maven project depending on local sources (from github (sap-olingo)) as well as maven dependencies loaded as jar. I have now updated the github source and also all the dependencies which seems to break standard eclipse export functionalities (right click porject -> export -> war)
The webproject is working fine when using the maven install functionality and is loading all sources into the META-INF/lib classes, but when using the export as war from eclipse (which I did previously) it is missing to compile a proper dependency. Missing in the sense of that the jar is still present in the META-INF/lib directory of the war, but the content is empty and the size is only 1kb
When comparing the mvn clean install to the exported, there are rarely any differences. Except for the projects that are to be compiled during the runtime. Sizes of the libs in the mvn created war and the exported war roughly matches except for that one jar.
Is there a way to root cause that issue? I am using solely the maven integrated into the IDE which is why I doubt differences in the maven versions and or jdk.
Unfortunately I have no idea in where to start and what info you require
Thanks for your input
EDIT:
My projects pom:
<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>odata</artifactId>
<packaging>war</packaging>
<version>4.0.0</version>
<name>odataMaven Webapp</name>
<url></url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-processor</artifactId>
<version>0.3.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies>
<build>
<finalName>odata</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${project.build.source}</source>
<target>${project.build.source}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.source>1.8</project.build.source>
</properties>
</project>
The odata-jpa-processor source/project is pulled from here. The problem exists solely with the olingo-jpa-metadata jar which is empty. All other maven dependencies are exported correctly.
I want to use dom4j to parse xml string. But when I add dom4j dependency in pom file, my dev tool(Eeclipse) prompt errors below:
I tried to refresh project and maven's update project, the errors still occured. If remove the dependency, all of errors disappear, also dom4j cannot use.
Eclipse version:
Eclipse Java EE IDE for Web Developers.
Version: Photon Release (4.8.0)
Build id: 20180619-1200
POM file:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.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-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Maven Version:
I figured out it through a whole day working, the fix steps are:
1. the first line of errors prompt in eclipse is : fail to read artifact descriptor for xml-apis:xml-apis:jar:1.4.01.(the first capture image of the question)
2. I assumed that something are wrong with xml-apis in maven repository, so I find the directory of xml-apis in maven repository and remove them all
3. After that, I use Maven->Update project in eclipse, the errors run away.
I think the reason is: some files of xml-apis were damaged.
I have a custom library - Dao.jar which contains the database persistence logic.
I push this jar to artifactory with new version each time there is a change in code as shown below :
mvn install:install-file -Dfile=C:\*****\target\Dao.jar -DgroupId=non-public.com.karthik -DartifactId=dao -Dversion=2.0 -Dpackaging=jar
I have another maven web project which has a dependency on this jar. This jar is also packaged/bundled in the maven webapp project/war.
<dependency>
<groupId>non-public.com.karthik</groupId>
<artifactId>dao</artifactId>
<version>2.0</version>
</dependency>
Currently, I am changing the version of dao dependency in the pom.xml & re-building the maven webapp project each time a new version of Dao.jar is available in the artifactory.
Is there any option to build the maven project with the latest version of Dao.jar without manually changing the dependency version in the pom.xml?
When Maven searches for a dependency, it first checks the local repository (~/.m2/repository). If it's not found, it tries other resources, such as remote repositories defined in the POM file or in the settings file (~/.m2/settings.xml).
By that logic, if you try to use a version of a local project that's not yet installed to the local repository, Maven will never be able to find it to use in another project.
To avoid changing version numbers all the time and manually building both projects. You could create a parent POM for both projects. The parent would then be able to recognize that one of the child projects depends on the other and build them in the correct order.
Based on Luciano's inputs, I have created a multi-module maven project/parent POM with 2 modules(dao & web)
Parent
<groupId>com.karthik</groupId>
<artifactId>test</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
..........
</dependencies>
</dependencyManagement>
<modules>
<module>web</module>
<module>dao</module>
</modules>
Child module # 1 - dao
<parent>
<groupId>com.karthik</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>dao</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
.........
</dependencies>
Child module # 2 - web(declared dao dependency in POM)
<parent>
<groupId>com.karthik</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>com.karthik</groupId>
<artifactId>dao</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
.........
</dependencies>
When I run mvn package command at root path of parent pom, both modules - web.war and dao.jar are built. This method ensures always the latest version of dao.jar is packaged in web.war.
Is there a way to add a pom type dependency to my POM and get all its modules?
JavaMail is a good example. Maven Central Repo has a parent POM called: com.sun.mail:all:1.5.0 with modules: mail, mailapi, mailapijar, smtp, imap, gimap, pop3, and dsn.
However, the "all" artefact only has a single file: pom.xml Is there a way to add this "all" artefact as a dependency to my POM and get all its modules? I am 90% sure this is not the right way to use dependencies in Maven, but I want to hear it from an expert on The Stack.
Ideas:
<dependencies><dependency>...<type>pom</type></dependency></dependencies>
<dependencyManagement><dependencies><dependency>...<type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
Related: Netbeans: maven dependencies of type pom
You have to go with
<dependencies>
<dependency>
<groupId>com.my</groupId>
<artifactId>commons-deps</artifactId>
<type>pom</type>
</dependency>
</dependencies>
This will transitively add all dependencies declared in com.my:commons-deps to your current POM.
Using
<dependencyManagement>
<dependencies>
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
works as a simple 'include' of artifacts versions in your dependency management. Thus, it won't add any dependency in your project.
I believe you can create your own POM which aggregates the dependencies you want, and then in your original project add a dependency on that aggregate pom. You will still have to add dependencies on each individual module in your dependency POM, but it will be abstracted from the actual project POMs and allows those dependencies to be managed in one place, which could become useful if you end up having multiple projects that depend on that set of dependencies.
In your example you could create a new pom 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mail-deps</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>mailapi</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>mailapijar</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>imap</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>gimap</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>pop3</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>dsn</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
</project>
Then in your original project just add:
<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">
...
<modules>
<module>src/main/java/com/mycompany</module>
</modules>
...
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>mail-deps</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
The short answer: You cannot do this in Maven.
The other answers make only the "all" POM a dependency. Does not solve the issue. Another answer tries to import the dependencies of the "all" POM. I don't need the dependencies; I need the (child) modules of the "all" POM. Again, does not solve the issue.
Side note: I was using the JavaMail library incorrectly. I only needed to add one dependency: com.sun.mail:javax.mail:1.5.0
If the pom you're trying to import, contains dependencies defined in a <dependencies/> section, and you would like to import them all, you can try the code below.
(Disclaimer: I haven't done this in a while): in your <dependencyManagement/> section, add the pom dependency like this:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>kung.fu<groupId>
<artifactId>ninja</artifactId>
<version>1.2.3</version>
<scope>import</scope>
<type>pom</type> <!-- Not too sure if you needed this
when it's scoped as import,
but just in case -->
</dependency>
</dependencies>
</dependencyManagement>
It may as well be the case that you define the dependency directly in the <dependencies/> section not needing the <dependencyManagement/> bit, but as far as I recall, it should be scoped import as shown above.
As someone already wrote above : You can't do it . But this is what i did and it worked .
Lets assume you have some pom file (JavaMail in your example) with following :
<type>pom</type>
<dependencyManagement><dependencies><dependency></dependencyManagement>
And You want copy all jars mentioned in this pom to some place .
This is what i did and it is fast working solution
Open original pom and just copy-paste all dependencies section from original pom file to your new pom as is .
Of course use maven dependency plugin to copy all .
i am using Eclipse IDE. i have a maven projects as lmexadapter-core-api, lmexadapter-core-impl, lmex-moodle-api, lmexserver-mobile-api, lmexadapter-moodle-api, lmexadapter-moodle-impl. i have dependency in pom as below :
<parent>
<artifactId>lmexadapter-moodle</artifactId>
<groupId>com.platysgroup.lmex.adapter</groupId>
<version>1.0</version>
</parent>
<groupId>com.platysgroup.lmex.adapter</groupId>
<artifactId>lmexadapter-moodle-web</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>Maven Webapp Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.platysgroup.lmex.adapter.core</groupId>
<artifactId>lmexadapter-core-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.platysgroup.lmex.adapter.core</groupId>
<artifactId>lmexadapter-core-impl</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.platysgroup.lmex.server.mobile</groupId>
<artifactId>lmexserver-mobile-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.platysgroup.lmex.adapter.moodle</groupId>
<artifactId>lmexadapter-moodle-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.platysgroup.lmex.adapter.moodle</groupId>
<artifactId>lmexadapter-moodle-impl</artifactId>
<version>${project.version}</version>
</dependency>
i am using tomcat as my application server. i get all the jar except lmexadapter-moodle-api, lmexadapter-moodle-impl in my D:\EclipseWorskpace\ew-pg\lmexadapter.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\lmexadapter-moodle-web\WEB-INF\lib. because of this application is unable to locate class of lmexadapter-moodle-impl. what should i have to define so it will take both jar in a specified path as above.
please help me.
Thank you
Assuming current version of Eclipse and Maven plugin, is this something that can be solved by adding Maven dependencies to "project deployment assembly"?
If you have your project configured as Dynamic Web Project and Tomcat as server in Eclipse, this is under Project->Deployment Assembly->Add->java build path entries -> Maven dependencies.