how to call m2e plugin reindex API? - eclipse-plugin

Does the m2e plugin provide the ability that other plugins can update the settings.xml file and call the eclipse maven plugin to reindex it?
in this link , I can read the configurations but it just provided the ability to read, so does the m2e plugin provide the API to update the settings.xml (such as changing the "localRepository") and reindex it? I can modify the settings.xml by code but it cannot active the m2e plugin to reindex.

There is no public API (it's likely we'll get rid of Nexus Index support in the future), but if you like living dangerously, you can try :
MavenPlugin.getIndexManager().getLocalIndex().updateIndex(force, monitor);
With MavenPlugin living in the org.eclipse.m2e.core package/plugin.

Related

Does maven expose scmUrl as a property?

I'm using maven scm plugin and buildnumber plugin to get set buildNumber property from revision. I'd like to get the full url as well but it doesn't appear to be exposed as a property. I know I can call svn info and grep for it but I figured the maven way would be to expose it.
Please let me know if there is a plugin that exposes the url as a property.
For now, I plan to add the functionality to buildNumber plugin and submit a patch.
Thanks
Peter
No need to modify buildNumber plugin. maven-scm-plugin:validate-mojo provides
${project.scm.connection}

avoid instantiating maven dependency plugin

I would like to use the "deploy"-phase of maven to deploy some files to my appliance (using a custom maven plugin), but I don't need the maven-deploy-plugin.
There are several answers on stackoverflow and the rest of the web on how to avoid a plugin being run, for example:
maven exclude plugin defined in parent pom
Disable a Maven plugin defined in a parent POM
I have tried setting <phase>none, <skip>true and <inherited>false. However, the plugin is still configured, which fails with message:
failed to configure plugin parameters for org.apache.maven.plugins maven-deploy-plugin 2.4
because there is no distributionManagement-element in my pom.
Is there a way to completely remove the dependency-plugin from the maven lifecycle?
In my opinion, this is unlikely to work even with those workarounds simply because the maven-deploy-plugin is a core plugin, like it or not.
Therefore, here's another hack:
Create a profile.
Define your plugin in it and attach it to the install phase.
Trigger the deployment, by invoking your profile.
Not as fancy as you would have hoped for, but it should do the trick. If anyone has better ideas, I would also like to hear them, as I've faced this sort of issue as well.

Maven - How to find correct groupId/artifactId to include dependency in POM

In general, what is the best strategy for finding the groupId and artifactId for a well-known dependency for use in a Maven POM? For example, how would I find the correct entry for the MySQL JDBC driver? It's not mentioned on the mysql.com site, so I would usually spend time looking for another POM that already uses the Maven repository version of the jar. This can't be the best way.
I would suggest to use http://search.maven.org
M2Eclipse, the maven integration of eclipse, supports local searchable indexes of maven repositories. So you can right-click a project or a pom.xml and do
Maven -> Add Dependency
A dialog appears where you can search for artifacts from your local indexes. Wouldn't want to miss it.
If that's not an option, use mvnrepository.com
Most of the time my IDE does this for me. But when I'm not sure I search manually; Google really helps.
You can also search on maven search engines like this mvnrepository.com.
I use http://repository.sonatype.org.
Maven site suggests to browse biblio to get maven co-ordinates; http://www.ibiblio.org/ .
Say for log4j
First, we need to know what the groupId, artifactId, and version are for log4j. We can browse ibiblio and look for it, or use Google to help by searching for "site:www.ibiblio.org maven2 log4j".
Maven metadata for log4j: http://mirrors.ibiblio.org/maven2/log4j/log4j/maven-metadata.xml
In my experience the best option is mvnrepository.com. for example in your case, just type mysql in the search text field. you will find all available artifacts that contain mysql string. in your case the one fit your needs is: mysql-connector-java
for each artifact you have a general description that helps you decide what is best for you.
once you click it you get all the available versions and once you click on a version you have all sort of information about it like the code you need to add to your pom.xml, the artifact dependencies and so on...
1. Go to http://search.maven.org
2. Search in the required jar with groupId/artifactId or Just with basic text.
Like for your case

Maven 2, Liquibase and dbDoc

I'd like to generate liquibase's dbdoc as part of my maven site build, but I cannot figure out how to do this. My thoughts were to add maven-antrun-plugin to the reporting section of the pom, but I cannot have an node under plugin in the reporting section. Any ideas?
This is not supported by the Maven LiquiBase Plugin so either create your own report plugin or use the dbDoc Ant Task and the Maven AntRun Plugin to generate the documentation under target/site/.
In the later case, bind the plugin on one of the phases of the Site Lifecycle (this will require some testing but I think that pre-site, site or post-site would be ok) and add an entry in the left menu in the site descriptor.
You can create your own reports plugin, more information here:
http://docs.codehaus.org/display/MAVENUSER/Write+your+own+report+plugin

Download Maven2 dependency from non-standard layout repository

I need to download a file from a non-standard layout repository.
The standard repository layout is groupId>/<artifactId>/<version>/<artifactId>-<version>.<packaging> however, I need to download the following file:
http://hudson.myserver.com:10000/repo/ocp-services/schemas/trunk/201/archive/schemas/dist/schemas.jar
where ocp-services is effectively the groupId, schemas is the artifactId and 201 is the version.
How would I add a dependency to this file and get it downloaded into my project and local repository?
This is a Hudson file repository if this is of any help, but it is a third parties so difficult to get them to change any location.
One option would be to register a custom ArtifactRepositoryLayout implementation and to declare a repository using this custom layout. I've never done that but it should be possible, check this blog post.
A second option would be to configure Maven to go through some kind of custom proxy (e.g. a Servlet) and to rewrite the URL on the fly for this particular dependency.
In both cases, I'm afraid Maven will complain about missing metadata ("A dependency in Maven isn't just a JAR file", see 3.5.5. Maven's Dependency Management) because the hudson file repository is just not a Maven repository. Maybe this can be handled programmatically though. But as I said, I've never done this.
A third option would be to ask the project building the JAR you need to deploy it (in the maven sense). That would be of course the best solution.
A last one option would be to just download this JAR and to install it manually in your local repository. If this is an option, go for it.
Have you tried adding this to your pom.xml :
<dependencies>
<dependency>
<groupId>ocp-services</groupId>
<artifactId>schemas</artifactId>
<version>201</version>
<type>jar</type>
</dependency>
</dependencies>
or if that don't work as Pascal says install it manually