Does maven expose scmUrl as a property? - maven-scm

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}

Related

Jenkinsfile DSL sourcecode

I am developing new pipeline within Jenkinsfile using intelliJ.
When I was using jenkins 1 with pipeline-dsl plugin I could go into the source code and see how DSL was actually implemented in org.jenkins-ci.plugins:job-dsl-core. I would like to have the same ability with Jenkinsfile.
Can I somehow connect Jenkinsfile DSL and intellij to have there proper code completion and sourcecode insight?
In order to have access to the sourcecode for the Pipeline Plugin suite of plugins when working on ANY Jenkins pipeline script, whether global or otherwise, you will have to include the necessary libraries as dependencies.
I'm working on my current global pipeline library.
Here adding the CPS library via "Project Structure" menu item:
Go to Libraries
Click the add button and select "From Maven..."
Type in the correct GAV (in this case com.cloudbees:groovy-cps:1.9)
Click the magnifying glass button - IntelliJ will search Maven Central (and whatever other repos you've configured in the Maven IntelliJ configuration or via your settings.xml) and download them to an your local cache.
Rinse and repeat until you've got all the dependencies you need.
When you're done, it should look something like this:
I found that the minimum useful were:
com.cloudbees:groovy-cps:1.9
org.jenkins-ci.plugins.workflow:workflow-api:2.+
Have you tried this approach yet?

how to call m2e plugin reindex API?

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.

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.

How do I get documentation lookup for non-core libraries in Intellij?

I have my JDK documentation path set so that I can hit Cntrl J (osx) to get 'quick documentation lookup' for core java libraries. If I try with non-core libraries like Spring or Hibernate, I only get the method signature. How do I go about getting the documentation for these libraries too?
Attach documentation directory or specify external documentation URL, or attach sources.
If you're using Maven, you can use the Maven goal :
mvn dependency:resolve -Dclassifier=javadoc .
This goal resolves the project dependencies from the repository. The classifier specify to look for javadocs. All documentation will be downloaded inside your maven local repository, generally ~/.m2 .
After that, IntelliJ is able to find all javadoc for Spring, Hibernate, if not, check your settings inside Project Structure.

Why doesn't my Maven plugin pick up parent properties?

When I make one plugin extend another it normally inherits the properties from the parent. Sometimes it doesn't work though.
When the plugin is loaded up, the properties from the parent are all null
What might I be doing wrong? I package my project as a maven-plugin and it builds ok.
I've seen this myself and it drove me mad until I debugged the Plexus internals. I'm guessing the properties are not inherited when the parent is in another plugin?
If that is the case, the explanation below will help. If it is not, it might be a typo in the Javadoc annotations. Maven will skip any tags it doesn't recognise without warning.
If it's neither of these, can you post a little more detail? perhaps an example of the failing Mojo?
If the parent is in another project, here's the reason why you're having problems.
Maven plugins use Javadoc annotations to define the dependencies, goal declarations, and other configurations (Maven 2.1 introduced proper Java annotations but hardly any plugins use them yet). Once the plugin has been installed/deployed the Javadoc is lost, so any plugin that extends a plugin in another jar won't have access to the plexus-defined properties in the parent.
There is a workaround though. The plugin metadata is output to META-INF/maven/plugin.xml. There is a third-party plugin that reads the information from the parent Mojo's plugin.xml and merges the local plugin metadata with it. Your plugin should then work as normal.