maven-release-plugin - Not found - spring-boot

I am trying to add maven release plugin to pom.xml file but it returns
Plugin 'org.apache.maven.plugins:maven-release-plugin:' not found

What you're seeing is your IDE complaining that it doesn't know (yet) about this new plugin you've added. It looks like Intellij IDEA from Jetbrains, so my first advice would be to:
run a maven goal that includes this plugin; for example mvn release:help. This will make sure the plugin gets resolved and downloaded (it is in central so should give no problems)
you should also see the release plugin be listed in the maven tab in IDEA now under plugins
tell IDEA to update it's own state from maven. IDEA has a hard time detecting new plugins, as they're not part of the normal project build dependencies. See Force Intellij IDEA to reread all maven dependencies
If the maven goal runs fine, the plugin is working. Try refreshing in IDEA or closing + reopening the project a few times until IDEA gets it.
Regarding the "missing" version tag. If you're not specifing an exact version of the plugin to use, you're currently getting this plugin (version) from the maven super pom:
https://maven.apache.org/ref/3.8.5/maven-model-builder/super-pom.html
you can run the following maven command to view your combined effective pom; super pom, your own pom + default bindings: mvn help:effective-pom
your current configuration should be sufficient, but if you want more control you can specify a version explicitly. See the following link for available version: https://search.maven.org/artifact/org.apache.maven.plugins/maven-release-plugin
if you really want this "error" from IDEA to go away, you must specify the version. It seems IDEA doesn't understand that the version is inherited from the super pom. You can tell because the error message org.apache.maven.plugins:maven-release-plugin: is in the format of groupid:artifactid:version, and version is missing. Adding a version would look like something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
</plugin>
(this is the default for maven 3.8.5, you can pick a newer version if you want)

Related

How do I verify that my eclipse project is effectively using tycho

I am transitioning to Maven-Tycho and was dealing with many errors. I seem to have gotten rid of all the errors but when I look into the pom.xml file I see maven-install-plugin, maven-compiler, maven-release plugin, etc and no mentions of tycho like I see in my tutorial. Did I do something wrong how do I make sure that my project is using maven-tycho not maven only.
http://www.vogella.com/tutorials/EclipseTycho/article.html
Any changes can be made in the pom.xml tab. The Effective POM tab is read-only, it just shows what Maven constructs when it parses your project. It's composed of your POM and its (grand)parent POMs. The Effective POM does not exist on your filesystem per se, it's generated on-the-fly whenever your run a Maven build - hence why the view is "read-only". You can change to tycho-compiler by modifying the pom.xml file replace maven-compiler-plugin with tycho-compiler-plugin. Make sure you add tycho to your eclipse environment

Sonar Maven plugin is failing because of a newer maven assembler plugin, how can I get the new plugin to pass properties correctly?

Had to update our maven assembler version to 1.1.8 from 1.1.6. It's the only change that happened and now Sonar Maven Plugin is throwing this exception:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar
(default) on project ReconCoverage: java.util.ArrayList cannot be cast to java.lang.String ->
Plugins:
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.7</version>
<groupId>com.CORPNAME.raptor.build</groupId>
<artifactId>assembler-maven-plugin</artifactId>
<version>1.1.8</version>
I have been looking into this for about a week, upgrading to this assembler version is required. No other teams are experiencing this issue from the upgrade because they are using Sonar through jenkins. I'm using the maven plugin because our project has many modules, and it structures the coverage results to match it.
I have looked through sonar's code and it seems to be happening in sonar.batch.bootstrap.userproperties. I'm guessing this is happening when the sonar properties are being passed in, items like: sonar.language, sonar.java.coveragePlugin, sonar.host.url, etc. etc.
Example of Coverage Properties:
<sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.host.url>http://corp.sonar.url/</sonar.host.url>
<sonar.jdbc.url>jdbc:oracle:thin:#sonardb.corp.com:0000:sonardb</sonar.jdbc.url>
<sonar.jdbc.username>username</sonar.jdbc.username>
<sonar.jdbc.password>password</sonar.jdbc.password>
<sonar.jdbc.driver>oracle.jdbc.driver.OracelDriver</sonar.jdbc.driver>
According to sonar's code, it normally takes properties through a Map. And it throws this exception when one of those strings is an array list. Is there anyway to configure my properties so that the new maven assembler will pass these values correctly?
We have implemented a workaround in version 3.1.1 to circumvent buggy plugins injecting non string properties:
https://jira.sonarsource.com/browse/MSONAR-145
To use it just update you pom.xml to use:
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
I finally found a workaround for this problem. I decided to not go the route of running Java 7 and then 8 to build the coverage report(check previous answers and comments). I'm sure that would work, but since none of our dev or CI machines had Java 8 environments set up, I tried a different route.
I was initially building the sonar report at the end of a mvn clean install through a module CoverageModule(which as the last module to build). The 1.1.8 java assembler version was throwing a fit when it built the project, and then ran the analysis.
I kept the module so that during a normal build, it would still run my ant task plugin to merge all of our module's Jacoco reports. I removed the sonar-maven-plugin from that module's pom and put it in the Project's aggregator module(parent of all modules). After running a full mvn clean install, I can run a mvn sonar:sonar and there appears to be no conflict with the new assembler version, and the old sonar version I was using.

Specifying version of Sonar plugin

I have a Maven multi-module project and as part of my build I execute
mvn sonar:sonar
I get some unexpected behaviour with a particular maven plugin that there is no need to go into here and after a lot of debugging and trial-and-error, I decided to tweak the particular plugin in question to add some debugging. The plugin in question is the sonar javascript plugin (https://github.com/SonarSource/sonar-javascript).
I cloned the git repo, incremented the version to 2.16 (latest available is 2.15), modified a logging statement, executed mvn install. Then I went back to my project hoping that when I executed mvn sonar:sonar it would simply pick up the latest version of this plugin available on my local repo. It didn't. I tried adding this to my pom:
<plugin>
<groupId>org.sonarsource.javascript</groupId>
<artifactId>javascript</artifactId>
<version>2.16</version>
</plugin>
Still nothing. The logging statement is unchanged.
So how can I get the sonar execution to pick up my locally installed version of the plugin?
Just install the plugin on your SonarQube server.
Changing the plugin source means that you'll be on your own from their on though. If you've got legitimate issues/feedback with the JavaScript Plugin, then reach out to their maintainers on the SonarQube Google group. Constructive feedback will be heard, you'll get a chance to contribute directly to the sonar-javascript project, and the community we'll be able to benefit from your improvement(s) (rather than you flying solo with custom changes).

add external plugin to intellij maven project

I'd like to add a plugin to my maven project in Intellij, but I'm not sure where I should download from and where I should put the jar files. For example, I want to use
<plugin>
<groupId>funambol</groupId>
<artifactId>rhinounit-maven-plugin</artifactId>
...
or
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
...
in my pom.xml, but the text between the tags is red.
The rhineunit-maven-plugin does not seem to be found in any central repository. You will have to download the plugin sources yourself from here and then build them by running mvn install where the pom file is located. This will install the plugin in your local repository and the version will be 1.0.
Regarding the jasmin-maven-plugin it can be found here and as you can see the latest stable version is 1.1.0. That means that you will only have to add the version 1.1.0 to your plugin statement and the plugin will be downloaded when you run mvn install (actually in an earlier maven phase but don't bother about that).
Here seems to be a good article on how to use rhinounit-maven-plugin so you should go ahead and study it.
Regarding the tags being red that is caused by IntelliJ not being able to find the jar files in the local repo, especially if you don't set the version for the plugins. Normally IntelliJ shows a little green growl-like thing in the upper right corner that states "Maven projects need to be imported" when you change your pom files from within IntelliJ. If you select "Import Changes" it will try to download your dependencies. Another way to solve it is to run mvn install on your own project from the command line.

Maven can't discover workspace projects, junit, other libraries

so I have started using maven (with eclipse, and a local implementation of Sonatype) not that long ago, after getting through the initial pain I though everything was working.... apparently not !
I have my main project POM and all my child POM (I am using a 'flat' hierarchy, so all the sub projects are in the same folder as the parent POM). This seems to be working OK.
The sub project where all started and 'released' and tested before I started using Maven. I went to maven to solve my 'dependencies' problems... or rather make them more complicated in this instance.
Most of the 'Maven' stuff seems to work fine, but I can't resolve the dependencies of my 'sub projects' that have been released into my local ms/repository
Each day I start up eclipse and have the same problems, I have 'unable to resolve imports' on all my personal libraries, and all those that I use for them (such as Log4j, DDlUtils etc).
I thought the whole point of maven was that I would be able to put in an import declaration for a library, add the 'groupID' and other stuff to the child POM (or parent POM). And then have all the jars downloaded automagically when I run
mvn install
against the parent.
However each day I find I have to re-insert the build path to the libraries (internal and external) via the eclipse workspace and point them to the location of the libraries that I have downloaded as maven can't seem to find them anywhere.
Specifically with running Junit test, I can run them from the workspace (using run as junit) and they all pass fine. But if I try to run them with
mvn test
I get an message saying
java.lang;NoClassDefFoundError: org/junit/Assert
(and this is the same from within eclipse running the mvn test or from CLI)
with an error message in the output of
failed to execute goal org.apache.maven.plugins:maven.surfire-plugin:2.10:test
the POM and jar are in my M2_REPO, and I can find it when I search in sonatype, why can't maven find something that is part of its own system, exists in its repo.
but this obviously works just fine when I run via eclipse and point it to an independently downloaded junit library.
I don't know what extra info you may require, and I'm obviously missing something in either the m2e plugin, my maven install or in sonatype.
please help I'm begining to loose my hair!
and may soon be forced to return to an ant/ivy solution (but don't want to have to learn 'yet another tool' (in this case ivy).
Thanks in advance
David.
ps. i'm on a windows XP platform
edit...
can I get maven to build and release the jar and pom even though it thinks it is failing the tests (which is itn't as I'm doing them manually, and they pass just fine).
If I look in the 'effective POM' tab of my parent POM, the plugin stated above is not in there. I guess this means it is a maven config setting, but where do I add it, and why isn't it automatic when I run my first set of maven tests?
edit 2....
I just found this on the apache plugin comments page (http://maven.apache.org/plugins/maven-surefire-plugin/plugin-info.html), so I ran the code on the CLI, mvn surefire:help -Ddetail=true -Dgoal=test lots of stuff was downloaded, and now the tests run, but they fail within maven ? (remember they pass when run from eclipse using 'run as junit test)... so this is nearly a solution...
It sounds like you need make eclipse aware that the projects in question are Maven projects. You may have POMs set up for your projects, but for the m2e plugin to work you need to have either created the project as a Maven project ('New' -> 'Project...' -> 'Maven' -> 'Maven Project...'), or converted it into a Maven project by right clicking it then selecting 'Configure' -> 'Convert to Maven Project'. You will know that a project has been recognised as a Maven project because there will be a little blue 'M' in the top left of its icon, as shown in the screenshot below:
The main thing to note in the above picture is the 'Maven Dependencies' library. This is set up automatically by the m2e plugin. Whenever you add a dependency to a POM then the project's build path will be configured automatically, although sometimes you may need to force it to do so by right clicking the project and selecting 'Maven' -> 'Update Maven Configuration'. The important thing is that if everything is working then you should never have to update the build path yourself. Moveover, if you do update it yourself then any changes you make will likely get overwritten the next time you run the 'Update Maven Configuration' command.
Also worth noting from the picture is that the two dependencies 'mavenProjectTest' and 'primes' have folder icons next to them. This means that they have been picked up as workspace projects. For this to work the project must have 'workspace resolution' enabled, and the projects to be picked up need to be configured as m2e Maven projects as well.
You mention downloading external libraries. You shouldn't need to download any libraries yourself - by adding the right dependency declaration for an external library then Maven will download it from your configured remote repository (the first time anyway - afterwards it will then be able to get it from your local repository). By default, this is the Maven Central repository. To add an external library to your project just follow that link, enter the library in the search box, click on the version link for the version you require, then you will be taken to a page where there will be the dependency XML declaration that you can just copy and paste into your POM.
One more thing that may help is that you should make sure that your source folders follow the Maven default directory structure. That is, your test packages should be contained in a source folder called 'src/test/java', and the main project packages should go in 'src/main/java'. Otherwise Maven will not know where to find your source code. It is possible to configure a POM to tell Maven to expect your source code to be in different source folders, but it is highly recommended that you follow the standard Maven directory structure.
Since you have child modules, my suggestion would be to simplify things by creating a new Maven project from scratch that you can have a play around with. Once you are comfortable with that then try getting m2e to work for your multi-module project.
I remember your pain when first getting to grips with Maven, but it's great once you understand what it's doing and everything is working. I highly recommend reading through the free online book Maven: The Complete Reference - it helped me out a lot when I was getting started with Maven.
I have experienced the same messages and have found a working solution, thanks to one of my organization's Maven experts.
Here was my pom.xml that reproduces your error:
<dependencies>
<dependency>
<groupId>org.junit4</groupId>
<artifactId>org.junit4</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
With it, I would get package org.junit does not exist messages and NoClassDefFoundError: org/junit/Assert. Similar to your experience, it worked great from Eclipse, green bars and all.
Here is the pom.xml that works:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
I copied this from the example at the top of this Using JUnit page.

Resources