maven 3.6.3 not able to execute `project.remotePluginRepositories` - maven

I have been using maven 3.0.4 and one of our plugin's goal is using project.remotePluginRepositories. I have to now use maven 3.6.3 and I keep getting errors of value not found of project.remotePluginRepositories. The configuration of my goal is configured as:
<pluginRepos default-value="${project.remotePluginRepositories}"/>
I have also tried changing to the following, but I am still getting errors:
<pluginRepos>${project.remotePluginRepositories}</pluginRepos>
This pom.xml is in the child folder of the main folder with its pom.xml file.
I also can't find where project.remotePluginRepositories is defined so I also don't know how exactly the value is defined in XML format. Need help. Thanks

Related

Maven execute plugin specified in pom

I am very new to Maven, and I am facing the situation that I need to execute plugin specified in pom.xml which generates java classes from xsd. This plugin is specified in build section so I need to compile all the code before it is triggered. Is there some way how to trigger the plugin with all its configuration specified in pom.xml directly?
I have searched online and the suggested way was to call
mvn org.apache.cxf:cxf-xjc-plugin:2.6.1:xsdtojava
(this is my plugin), but I am getting error Must specify xsdOptions, so from my understanding it is just calling the plugin without he config specified in pom.xml.
If someone could help me, it would be great. I can not edit the pom.xml!

can't find my maven artifacts

I'm working in eclipse and I have a problem that I can't import my personal java libraries.
I created the libraries and 'installed' them into my local maven repo (using mvn install). This created a subdirectory related to the 'version' name that was in the POM file from when I ran the command. Which seemed fine.
So in this directory there where the usual jar files and other stuff.
When I released this file I manually changed the name of the version in the POM. going from 0.0.1-SNAPSHOT to 0.0.1-RELEASE
This seems to have worked as I would have expected.
However I can't seem to find import the new release jar.
Using the maven repositories browser in eclipse I can see that the new artifact is in the 'local' repository.
I try to add the dependency in the following methods:
Select the main project -> Maven -> add dependency.
This adds the dependency details into the pom but with a type value detail of <type>pom.lastUpdated</type>
Select the project pom.xml file -> Maven -> add dependency.
This time the artifact for the 0.0.1-RELEASE is greyed out I can select it, but I guess nothing is actually happening.
The original 0.0.1-SNAPSHOT it selectable, and if I use this I do not have a <type> detail in the pom.
I don't understand why there is a difference in the RELEASE and SNAPSHOT artifacts, as they have both been generated in the same way, and clearly they are both visible in the browser, the contents of the directory on disk are the same. The file names and contents are identical with the exception of the word RELEASE or SNAPSHOT.
I know that I can simply add in the RELEASE jar to my build path, but this seems to be a ridiculous thing to have to do if I intend to use maven (or do I need to do this).
I don't want to use an external repo for storing my artifacts, and I'm not too keen to go to the trouble of installing nexus (or similar) on my local machine (just because I've had trouble with it in the past).
What am I missing so as I can get my maven project to see my local repository and all its artifacts.
Thanks in advance.
David
ps I've already tried things such as mvn dependency:purge-local-repository which definitely pulled in / updated all the local jar dependencies.
So I've managed to work around my problem.
As such this solution is ridiculous, and breaks all the purpose of maven.
So I found (from running maven from the cli) that there was an error in the parent of the project I was attempting to use.
The parent was missing a direct link to the scm plugin (version error).
Once I solved this problem, I then returned to the sub project, and got a lot of errors from missing stuff from the parent.
Essentially it was not 'seeing' all the log4j dependencies.
The solution (well non-solution really).
Add all the log4j dependencies to the sub project.
Edit in SCM and surefire test plugins (as it also started to fail the test code due to missing junit).
So this is great.
I have to define all my dependencies on log4j and in my sub / child project's pom.xml file.
I also need to define them all in my parent's pom.
As it then still refused to run tests in my new project (that used the above as a dependency), and refused to find log4j also. I then decided to add all of these as dependencies for my current project.
Great.
I thought the whole point of maven was I could define my dependency on log4j in my my logging library that I use (which is the dependency), and then it would 'automagically' pull in all the required from this dependency.
Clearly not.
As stated at the start. This is NOT AN ANSWER it is a crazy work around.
My logging library that I use should be able to define its own requirement on a specific log4j version (such as moving from log4j to log4j2), and then when I include this as a maven dependency any change to the required dependency should be seen automatically.
But No : I have to import the dependency on log4j in my other projects also. So now if I had updated my logging library from log4j to log4j2 I would need to go to all my project that use this library and update their pom's to ensure that I have the correct version of log4j.
Seems the whole point of maven has just been lost!
Can someone please tell me where I am going wrong!
David.

Add Archtypes to Eclipse

I am new to MAVEN and restful services. I have MAVEN installed it correctly and set the variables. I was creating a webservice using the jersey-quickstart-webapp but found it did not appeared in the list of Archetypes.
I tried to add it using using ADD Archetypes option. After the entering the details
GroupId: org.glassfish.jersey.archetypes
ArtifactId: jersey-quickstart-webapp
Version : 2.16 // version is correct??
I get following error please help.
<b>
org.eclipse.core.runtime.CoreException: Could not resolve artifact
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.16</b>
I don't have a ready explanation as to why the Eclipse archetype plugin was giving you this error, since 2.16 is a valid version of jersey-quickstart-webapp. However, I would recommend that you try manually executing the following command from a command prompt:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false
-DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example
-DarchetypeVersion=2.19
Make sure that you first delete the jersey-quickstart-webapp folder, if it exists, from your Maven .m2 directory. This may be necessary to avoid from something getting corrupted during the archetype install.
Here is a link to the official documentation for creating a Jersey EE application from a Maven archetype.

Maven not installing dependcies

i am new to maven so this could be something basic but i cant seem to get to the bottom of it.
I am running m2eclipse. I have a simple project that is trying to use the classes in the maven package for servlet-api (group id : javax.servlet artifact : servlet-api version 2.5 scope : compile ).
My repository where i assumed it would be pulled from, in my settings.xml (http://repo1.maven.org/maven2 ). I followed this url to verify that there was a jar and such at that address and there was (http://search.maven.org/#browse|-182598336)
however when i run mvn compiler:compile i get the (cannot find symbol
symbol : class HttpServletRequest )
also i looked in my repository and the jar's and poms that should be installed there are not. Other classes are but those are not.
i have looked in the debug info i got from the -X and it didnt seem to indicate anything was wrong.
I can post effective pom or whatever anyone would find helpful.
thanks in advance.
So I was able to solve the issue. It was a bit strange, but it seems to act differently if you select the pom and click to maven -> add Dependance. That will download and install the dependency.
If you add then directly to the pom (as i was doing before) there is an additional step that seems a bit strange and that is to select the project (again i am using m2eclipse) not the pom, and then click maven -> update dependencies ...
Seems odd because I am not running in offline mode, I would think that when i run mvn compiler:compile from the command line that it should notice that it needs to resolve the dependency and then go get it from the repository...
maybe there is a setting that i have to have to force this to happen?
In any event i hope this saves someone some time :)

How to add files to a maven project executing generate goal (mvn archetype:generate)?

I'm building a maven archetype project. As parameter (serviceDescriptor), I'm passing path to an xml file. When the generate goal is successfully executed, I would like to have the serviceDescriptor file in src/main/resources. Based on maven archetype documentation, it seems that is not possible but, there should be a way to do it.
I have spent couple of days on this and I think that I have found a reasonable solution.
As I mention in the question, I'm passing the file path as required property to the archetype:generate.
I had to implement a simple plug-in that is executed after archetype generate is finishing. This plug-in is coping the file into src/main/resources, read some data from the file and update the pom.xml setting some properties. In order to be able to modify the pom.xml file I'm using maven-model-2.0 archetype as dependency in maven plug-in. It offers Maven MvenXpp3Reader and MavenXpp3Writer classes that allows to safe modify pom.xml.
In order to tell to archetype project to execute plug-in at the end of generate phase of archetype:
mvn archetype:generate -goals=plugin_groupId:plugin_artifactId:goal
The downside is that the plug-in should be available in a accessible repository or local repo.

Resources