tycho-maven-plugin 3.0.0 Failed to collect dependencies - tycho

I'm trying to migrate to tycho 3.0.0 and get
Failed to collect dependencies at org.eclipse.tycho:tycho-maven-plugin:jar:3.0.0 -> org.eclipse.platform:org.eclipse.core.runtime:jar:3.12.0 -> org.eclipse.platform:org.eclipse.equinox.preferences:jar:3.10.0 -> org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0)
Obviously this is related to maven-build-failed-due-to-jdt-dependencies-no-versions-available-for-org-osgi
Any attempt to force org.eclipse.equinox.preferences to resolve to something above 3.10.0 failed.
The following worked for org.eclipse.core.runtime (forced version 3.26.0) but not for org.eclipse.equinox.preferences
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.26.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.preferences</artifactId>
<version>3.10.100</version>
</dependency>
</dependencies>
</plugin>

The problem turned out to be an issue of the repository manager (archiva 2.2.4), which seems to provide the wrong versions. So I was completely on the wrong track.

Related

failed to resolve junit platform launcher 1.6.3 intellij

I am trying to run tests in Intellij which used to work earlier in spring boot 2.2.x. I recently upgraded to spring boot 2.3.9. When I try to run the test from Run Configurations, it doesn't run the test and throws the error:
'failed to resolve junit platform launcher 1.6.3 intellij'.
However if I run the test in cli, it works fine.
It turns out that, junit5-platform-launcher dependency needs to be added in order for Junit5 tests to run in IntelliJ.
https://youtrack.jetbrains.com/issue/IDEA-231927?_ga=2.5997872.2063517257.1613993298-1098513328.1597974168
https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea
Add this dependency explicitly in pom.xml, and it will solve the issue.
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
I was facing same issue "failed to resolve junit platform launcher 1.8.1" intellij.
IntellJ version: 2021.3
I found answer here and it worked, no need to add any dependency to pom.
Go to settings >> HTTP Proxy >> choose auto-detect proxy settings
For IntelliJ Idea 2021.1, I fixed a similar problem with:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
Maybe an even better fix is:
<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit/junit-bom -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.7.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Found the above solution on Jetbrains issue tracker
If you have no direct internet connection but a repository manager like artifactory, idea tries to resolve junit-platform-launcher from there. Make sure u have a mirror to maven central repository (virtual repository) configured and the artifactory url to this mirror is accessible WITHOUT authentication (in the settings for the repo "Force Authentication" should be unchecked).
Check also the idea proxy settings and if needed, configure an exception for the artifactory domain.
Check your proxy settings in IntelliJ Idea settings. I turned ON the proxy and it solved the problem.
Here's the official way to do this
Maven Surefire and Maven Failsafe can run JUnit 4 based tests
alongside Jupiter tests as long as you configure test scoped
dependencies on JUnit 4 and the JUnit Vintage TestEngine
implementation similar to the following.
<!-- ... -->
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
<!-- ... -->
<dependencies>
<!-- ... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<!-- ... -->
</dependencies>
<!-- ... -->

"Cannot find database driver: Driver class was not specified and could not be determined from the url" error on using liquibase-hibernate plugin

I am trying to generate changeLog from diffs between a Database and Persistence Entities.
I am using the liquibase hibernate plugin
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.3.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
and my liquibase.properties goes like this
changeLogFile=classpath:liquibase-changeLog.xml
url=jdbc:postgres://localhost:5432/oauth_reddit
username=tutorialuser
password=tutorialmy5ql
driver=org.postgresql.Driver
referenceUrl=com.sample.App
?dialect=org.hibernate.dialect.PostgreSQLDialect
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog.xml
while executing mvn liquibase:diff, I am getting the following error
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:diff (default-cli) on project prototype-liquibase-migration: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect) -> [Help 1]
I have specified the Driver in the liquibase properties, but it seems that it is not taking.What could have I done wrong ?
The problem was with my referenceUrl in liquibase.properties The referenceUrl is using package scan, so the url has to start with hibernate:spring:.
I changed
referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect
into
referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
This solved my problem.

Maven does not resolve a local Grails plug-in

My goal is to take a Grails web application and build it into a Web ARchive (WAR file) using Maven, and the key is that it must populate the "plugins" folder without live access to the internet. An "out of the box" Grails webapp will already have the plugins folder populated with JAR files, but the maven build script should take care of populating it, just like it does for any traditional WAR projects (such as WEB-INF/lib/ if it's empty)
This is an error when executing mvn grails:run-app with Grails 1.1 using Maven 2.0.10 and org.grails:grails-maven-plugin:1.0. (This "hibernate-1.1" plugin is needed to do GORM.)
[INFO] [grails:run-app]
Running pre-compiled script
Environment set to development
Plugin [hibernate-1.1] not installed, resolving..
Reading remote plugin list ...
Error reading remote plugin list [svn.codehaus.org], building locally...
Unable to list plugins, please check you have a valid internet connection: svn.codehaus.org
Reading remote plugin list ...
Error reading remote plugin list [plugins.grails.org], building locally...
Unable to list plugins, please check you have a valid internet connection: plugins.grails.org
Plugin 'hibernate' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
The build machine does not have access to the internet and must use an internal/enterprise repository, so this error is just saying that maven can't find the required artifact anywhere. That dependency is already included with the stock Grails software that's installed locally, so I just need to figure out how to get my POM file to unpackage that ZIP file into my webapp's "plugins" folder.
I've tried installing the plugin manually to my local repository and making it an explicit dependency in POM.xml, but it's still not being recognized. Maybe you can't pull down grails plugins like you would a standard maven reference?
mvn install:install-file -DgroupId=org.grails -DartifactId=grails-hibernate -Dversion=1.1 -Dpackaging=zip -Dfile=%GRAILS_HOME%/plugins/grails-hibernate-1.1.zip
I can manually setup the Grails webapp from the command-line, which creates that local ./plugins folder properly. This is a step in the right direction, so maybe the question is: how can I incorporate this goal into my POM?
mvn grails:install-plugin -DpluginUrl=%GRAILS_HOME%/plugins/grails-hibernate-1.1.zip
Here is a copy of my POM.xml file, which was generated using an archetype.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.samples</groupId>
<artifactId>sample-grails</artifactId>
<packaging>war</packaging>
<name>Sample Grails webapp</name>
<properties>
<sourceComplianceLevel>1.5</sourceComplianceLevel>
</properties>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-crud</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-gorm</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
<artifactId>oscache</artifactId>
<version>2.4</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!--
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-hibernate</artifactId>
<version>1.1</version>
<type>zip</type>
</dependency>
-->
</dependencies>
<build>
<pluginManagement />
<plugins>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>init</goal>
<goal>maven-clean</goal>
<goal>validate</goal>
<goal>config-directories</goal>
<goal>maven-compile</goal>
<goal>maven-test</goal>
<goal>maven-war</goal>
<goal>maven-functional-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${sourceComplianceLevel}</source>
<target>${sourceComplianceLevel}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is a tricky problem. I was going to suggest using Grails 1.3, which allows you to pull Grails plugins from Maven-compatible repositories, but I don't think this helps with Maven (at the moment).
So, I'm going to suggest something I haven't tried myself, but may work. I have some confidence because I wrote the relevant code in the Grails Maven plugin ;) No guarantees though.
With that out of the way, let's get started. First, you need to grab the code for the relevant Grails plugins. For example, you can get Hibernate from here:
http://svn.codehaus.org/grails/trunk/grails-plugins/grails-hibernate/tags/RELEASE_1_1/
You just need a copy of the code, so a read-only checkout will be fine.
Once you have the code, run mvn grails:create-pom -DgroupId=org.grails.plugins from the root of the plugin project. This will generate a POM. Next, you will need to edit the POM and change the packaging to "grails-plugin". You should also be able to remove the <executions> block from the Grails Plugin configuration.
The POM will now allow you to build and package the Hibernate plugin, but you still have to deploy it. So add your local repository to the POM's distribution management and run mvn deploy. Once that's done, you should be able to add the plugin as a standard dependency in your application's POM.
It's hard work, but at least you should only have to do it once per version of the plugin!
I was able to come up with a workaround just to get up and running.
This requires Grails be installed locally and that GRAILS_HOME be set. It will clear out and then populate the project's "plugins" folder during the maven "validate" phase. (Insert this into the POM above.)
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!-- clear out this project's plugins folder if it exists, otherwise you will get prompted to upgrade it after re-building -->
<delete dir="${basedir}/plugins/" includeemptydirs="true"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>create plugins folder</id>
<phase>validate</phase>
<goals>
<goal>install-plugin</goal>
</goals>
<configuration>
<pluginUrl>${env.GRAILS_HOME}/plugins/grails-hibernate-1.1.zip</pluginUrl>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

How to make maven-pmd-plugin support the latest PMD release?

http://maven.apache.org/plugins/maven-pmd-plugin/ is currently in version 2.4 which supports PMD version 4.2.2
Is it possible to use PMD version 4.2.5 with this plugin, if so how do we do this?
There is a Jira Issue for this, see MPMD-97 (I suggest to vote for it).
For now, you can try to upgrade locally the pmd version used in the plugin with:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
<dependencies>
<dependency>
<groupId>pmd</groupId>
<artifactId>pmd-jdk14</artifactId>
<version>4.2.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
I didn't test this, I don't know if it'll work seamlessly.
This is an old question and things have moved on, but I faced a challenge upgrading maven-pmd-plugin:3.8 from pmd 5.6.1 to 5.8.1.
The documentation for doing this was missing from the maven-pmd-plugin page at the time of writing.
Add pmd-core, pmd-java and any other mavenized PMD artifacts as plugin dependencies.
If your rules are contained within in a separate .jar module, add that module to the dependencies also.
Ensure that the check goal is run after the compile phase - validate is too soon. (I picked process-test-classes to invoke it just before any tests are run rather than the more usual verify which is also OK but will run it later).
pom.xml configuration:
<properties>
<rev.javac>1.8</rev.javac>
<rev.pmd-plugin>3.8</rev.pmd-plugin>
<rev.pmd>5.8.1</rev.pmd>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${rev.pmd-plugin}</version>
<dependencies>
<dependency>
<groupId>my.project.group</groupId>
<artifactId>project-standards</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>${rev.pmd}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>${rev.pmd}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>pmd-validation</id>
<phase>process-test-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<rulesets>
<ruleset>/pmd/project-pmd-rules.xml</ruleset>
</rulesets>
<targetDirectory>${project.build.directory}</targetDirectory>
<targetJdk>${rev.javac}</targetJdk>
<failOnViolation>true</failOnViolation>
<failurePriority>5</failurePriority>
<verbose>false</verbose>
<linkXRef>false</linkXRef>
</configuration>
</plugin>

maven dependencies groovy

I'm running a project that has a dependency on groovy 1.7-beta-1. The gmaven plugin uses groovy version 1.6 as a dependency. In my pom, I specify in the dependency management section the grooyv-all version as :
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7-beta-1</version>
</dependency>
</dependencies>
</dependencyManagement>
Yet when I run maven in debug mode I see that groovy 1.6 is being used for a dependency to the gmaven plugin. I thought my dependency management section would override this so they all use 1.7-beta-1, but I'm getting errors due to the different groovy versions. any help here would be appreciated.
thanks,
Jeff
Here's a refined version of Pascal's answer. I upgraded the main plugin version to 1.2, the dependency to Groovy 1.7, and wrapped it all in a pluginManagement tag so that it will nicely leverage the inheritance model.
Keep in mind that the 1.3-SNAPSHOT of the GMaven plugin has already begun using the 1.7-rc2 Groovy provider.
<!-- I wrapped everything in a plugin management section so that this can be neatly inherited across all your poms -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<!-- Notice I upgraded it to 1.2 -->
<!-- Details here http://repo1.maven.org/maven2/org/codehaus/gmaven/gmaven-plugin/1.2/gmaven-plugin-1.2.pom -->
<version>1.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
Overriding a dependency used by a plugin is a nice ability that was actually introduced by Maven 2.0.9.
To do so, at least with a plugin that you are using as a normal build plugin - as opposed to a report which is not the case with the the gmaven-plugin so I won't cover this case here - simply add a dependency block inside the plugin block, like this (this is a sample so versions may be inaccurate):
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7-beta-1</version>
</dependency>
</dependencies>
</plugin>
As long as the new version of the dependency is "API compatible" with the version the plugin was linked against, you should be ok. If not, then you'll obviously have to upgrade to a newer version of the plugin compatible with the new API (i.e. likely using it as dependency), which is what you did.
To make gmaven accurately picks the right runtime is by configuring the "providerSelection" value, e.g.
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<configuration>
<providerSelection>1.7</providerSelection>
</configuration>
FYI, for the groovy:providers mojo, these are the configurations it expects (I extracted them by debugging to org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(List, Stack, MavenSession, MavenProject) (look for XmlPlexusConfiguration):
<configuration>
<remoteRepositories implementation="java.util.List">${project.pluginArtifactRepositories}</remoteRepositories>
<project implementation="org.apache.maven.project.MavenProject">${project}</project>
<artifactRepository implementation="org.apache.maven.artifact.repository.ArtifactRepository">${localRepository}</artifactRepository>
<pluginArtifactMap implementation="java.util.Map">${plugin.artifactMap}</pluginArtifactMap>
<providerSelection implementation="java.lang.String">${gmaven.runtime}</providerSelection>
</configuration>
You need to add a similar 1.7 dependency to the dependencies of the plugin in a similarly structured <plugin> or <pluginManagement> section. Your dependency management section you are adding is proper, but does not affect the plugin dependencies. I'll try to review this reply and post an example later when I'm back at my desk.