I generated jars from Talend,and I suppose to use them in a maven project.After some research I know that I have to install this jars in the local maven repository using:
mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -DartifactId=non-maven-proj -Dversion=1 -Dpackaging=jar
and then add a dependency:
<dependency>
<groupId>....</groupId>
<artifactId>...</artifactId>
<version>...</version>
</dependency>
But I don't know what to put exactly in the groupId,artifactId and version tag. Help plz
Go to the maven repository https://mvnrepository.com and search for your dependency. Click on the version number and it will show you the complete dependency tag for your talend. e.g
<!-- https://mvnrepository.com/artifact/org.talend.esb.job/org.talend.esb.job.api -->
<dependency>
<groupId>org.talend.esb.job</groupId>
<artifactId>org.talend.esb.job.api</artifactId>
<version>6.3.1</version>
You should specify what is this "Talend"?
Here is simple introduction to maven pom structure:maven pom doc
groupId: This is generally unique amongst an organization or a project.
artifactId: The artifactId is generally the name that the project is known by.
version: is last piece of specification which package to use.
You can find specification to mvn dependencies on maven repository page. Here is an example for Talend ESB jar (newest version):
<!-- https://mvnrepository.com/artifact/org.talend.esb.job/org.talend.esb.job.api -->
<dependency>
<groupId>org.talend.esb.job</groupId>
<artifactId>org.talend.esb.job.api</artifactId>
<version>6.3.1</version>
</dependency>
BTW if you are just using it locally , then you can install jar with any group Id,artifact Id and version you feel like. Just make sure you use the same in your dependencies in project POM.
However this is not the recommended approach, but if you are not sure about the maven coordinates( group Id, artifact Id and version) you can use above given hack.
Related
My POM looks like this -->
<dependency>
<groupId>com.abc.xyz</groupId>
<artifactId>xyz</artifactId>
<version>1.0</version>
</dependency>
I have installed abc.xyz jar locally inside .m2 and is not available on mvn artifactory.
When I try to scan my code using sonar scanner installed on remote server, it tries to download abc-xyz.jar from maven artifactory & fails.
How do I make my remote sonar happy?
I tried giving scope as system but I see that it is deprecated.
Tried following
<scope>system</scope>
<systemPath>${project.basedir}/path/to/abc-xyz.jar</systemPath>
You can use sonar.exclusions in your pom.xml to exclude your jar-directory :
<properties>
<sonar.exclusions>${project.basedir}/path/to/abc-xyz.jar</sonar.exclusions>
<properties>
You might also try to define the property <sonar.skip>true</sonar.skip> in the pom.xml of the module you want to exclude.
Or try advanced reactor options like so: mvn sonar:sonar -pl !${project.basedir}/path/to/abc-xyz.jar.
Following import in an existing class is throwing a compilation error "import cannot be resolved" on eclipse -
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
The corresponding jar inclusion in pom.xml is -
<properties>
<fasterxml.version>0.7.0</fasterxml.version>
</properties>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-module-hibernate</artifactId>
<version>${fasterxml.version} </version>
</dependency>
I checked that the corresponding jar file is not present in .m2.
There is no such directory as jackson-module-hibernate inside .m2/fasterxml/
However, jar corresponding to another declaration is present in .m2 -
com.fasterxml.jackson.core
jackson-annotations
2.6.1
Is present in .m2/fasterxml/jackson/core/jackson-annotations/2.6.1
as jackson-annotations-2.6.1.jar
Setup details
Maven version - 3.3
Java version - 1.8.
Eclipse latest version - 2019-06.
I could not verify the absence of the first jar in the working sandbox setup, but that's how it should be, as we had taken a backup of the .m2 directory. How is it possible that the application runs in another setup without the presence of the jar.
Note - I am still a struggler when it comes to maven dependencies and the setup of this legacy project has made me pull hairs. I am trying to do the setup on eclipse. It got setup sometime back, after a lot of struggle, but before I could document all the steps/workarounds we made, I deleted the working setup by mistake.
Update
The pom declaration for jackson-annotations is in the pom of another project. That project has been included in the pom of the dependent project as -
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.dependencies</groupId>
<artifactId>dependency-project</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
You also need:
Execute mvn clean compile from Command Line, on another project
Execute mvn clean compile on your project
Right-click on Project > Maven > Update project...
I need to use AuthenticationRequest in my Maven Java Project. I did a search on the internet and found AuthenticationRequest on this page (OpenID Connect authentication), indicating this library contains AuthenticationRequest. I follow the links on that website to this page (com.nimbusds:oauth2-oidc-sdk-6.13 API Doc) and find a list of packages. I found this library at Maven Repository.
I added the information in my pom.xml in my Maven Project in Eclipse. Updated Project. Yet I am not able to import any packages starting with "com.nimbusds.oauth2".
Here is the dependency info for that library that I put in my pom.xml file:
<!-- https://mvnrepository.com/artifact/com.nimbusds/oauth2-oidc-sdk -->
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>6.13</version>
<scope>runtime</scope>
</dependency>
I am following an example code that uses the AuthenticationRequest class. I am having trouble finding the Maven info to put in my pom.xml file that allows me to use that class in my project. How do I find the right info for it?
Since you are developing a class that depends on that AuthenticationRequest class to compile, your maven goal is going to be before runtime. Maven scope of runtime is not appropriate.
You need to modify your pom.xml to specify compile scope:
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>oauth2-oidc-sdk</artifactId>
<version>6.13</version>
<scope>compile</scope>
</dependency>
Since Maven's default scope is compile, you could also just omit the scope tag.
Maven will import dependencies from the Maven Central repository by default. If Maven Central doesn't contain your dependency (I haven't checked) you must specify a repository that does contain it with something of this form in your pom.xml (note the repo is just an example - substitute a real one that contains your dependency)
<repositories>
<repository>
<id>some-example-repo</id>
<url>http://some.example.repo/some_example_path/</url>
</repository>
</repositories>
I have 4 modules in my project.
Module1 (i.e. com.assign.print:printlog.value:3.0.0-SNAPSHOT) has one class i.e. Foo.java, inside this class, on more class is there which is using com.print.assess: mns.pro:2.0
Module2 , Module2 and Module4 are using com.print.assess: mns.pro:6.2.
In my project main pom.xml, the dependency is added as :
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>6.2</version>
</dependency>
In Foo.java, I have one class as DataVal.java which is using older version.
If I don't add
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
to Module1 pom.xml, Redline error is coming for DataVal.java saying "cannot resolve the symbol". So when I added the dependency with version 2.0, the error was resolved but while installing project:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.print.assess:mns.pro:6.2 paths to
dependency are:
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.app.print:print.sal:1.1.3
+-com.print.assess:mns.pro:6.2
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess:mns.pro:2.0
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess.over:multi-task.rev:3.1
+-com.print.assess:mns.pro:6.2
How to resolve this issue?
Thanks in advance
If you have the dependencyConvergence enforcer rule active (which you obviously have), you need to determine your versions in the <dependencyManagement> (which is different from the standard <dependencies>).
Then you can declare the dependencies without version in <dependencies>. dependencyManagement entries can be in the main pom and in modules as well. #Bahmut gave you the link to understand dependencyManagement.
You may want to move your 6.2 dependency in your main pom to <dependencyManagement> so it does not get imported by default. Then you can simply import the 6.2 version in your module poms like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
</dependency>
and in the module where you need version 2, you can import it like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
More information about dependency management can be found here:
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
I have 4 projects in my eclipse workspace. They are all 4 maven projects. The names are API, Games, Faction, Board.
API is used in all the other maven projects (Games, Faction, Board) and itself depends of a jar into my PC and also HikariCP.
I declare this dependencies in my API pom.xml
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
<scope>compile</scope>
</dependency>
Then I declare on my 3 other projects that they depend of API
<dependency>
<groupId>net.onima</groupId>
<artifactId>onimaapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
But I have a big warning on the API and the error log says this:
I don't understand why is there this error as I can code with the API in my classes. Can someone explain me? Thanks
EDIT: As requested the text of the screenshot:
Description Resource Path Location Type
Project 'OnimaAPI' is missing required Java project: 'paperspigot' OnimaAPI Build path Build Path Problem
Description Resource Path Location Type
Project 'OnimaGames' is missing required Java project: 'onimaapi' OnimaGames Build path Build Path Problem
I don't know why I can't set the pom.xml here so here's a link: https://ghostbin.com/paste/r4u62
You're declaring paperspigot with system scope.
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM.
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies
You should declare it with compile scope:
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.