How to use GitHub Repo using JitPack.io in Maven - java

I wants to use https://github.com/liquibase/liquibase version 3.5.0-SNAPSHOT
I have added the following in pom.xml
<dependency>
<groupId>liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.5.0-SNAPSHOT</version>
</dependency>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
but got following error when compile:
[ERROR] Failed to execute goal on project XYZ: Could not resolve dependencies for project com.XYZ:jar:0.0.1-SNAPSHOT: Failure to find org.liquibase:liquibase-core:jar:3.5.0-SNAPSHOT in https://github.com/liquibase/liquibase was cached in the local repository, resolution will not be reattempted until the update interval of liquibase-repository has elapsed or updates are forced -> [Help 1]

There seems to be an issue with JitPack and downloading this repository. According to the maven modular example that JitPack provides, the dependency should be defined as follows:
<dependency>
<groupId>com.github.User.Repo</groupId>
<artifactId>Module</artifactId>
<version>Commit/Tag</version>
</dependency>
The following should then work:
<dependency>
<groupId>com.github.liquibase.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>f7f3b8f60b</version>
</dependency>
But it also fails resolving the dependency:
[ERROR] Failed to execute goal on project my-app: Could not resolve dependencies for project com.mycompany.app:my-app:jar:1.0-SNAPSHOT: Failure to find com.github.liquibase.liquibase:liquibase-core:jar:0885bc4 in https://jitpack.io was cached in the local repository, resolution will not be reattempted until the update interval of jitpack.io has elapsed or updates are forced -> [Help 1]
You can see that this is definitely an issue by just trying to use the liquibase parent repository (not just the liquibase-core module) as follows:
<dependency>
<groupId>com.github.liquibase</groupId>
<artifactId>liquibase</artifactId>
<version>f7f3b8f60b</version>
</dependency>
Which also errors out. According to JitPack's log for this commit, it looks like there is a compilation error with the source:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project liquibase-core: Compilation failure
[ERROR] /home/jitpack/build/liquibase-core/src/main/java/liquibase/parser/core/formattedsql/FormattedSqlChangeLogParser.
java:[213,209] ')' expected
It seems like the best route would be to file an issue with the JitPack folks and see if they can shed some light on it.

Related

PluginResolutionException: Plugin .url=jdbc:postgresql://localhost or one of its dependencies could not be resolved: Could not find artifact

I am trying to run mvnw clean compile on a rather old project.
The whole line is
../mvnw clean compile -Dflyway.url=jdbc:postgresql://localhost:5431/my_database -Dflyway.user=some_user -Dlyway.password=xxx -Dflyway.outOfOrder=true flyway:migrate -f pom.xml -U -X
This gives me the following error
BUILD FAILURE
[ERROR] Plugin .url=jdbc:postgresql://localhost or one of its dependencies could not be resolved: Could not find artifact .url=jdbc:postgresql:jar://localhost in central (https://repo.maven.apache.org/maven2) -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin .url=jdbc:postgresql://localhost or one of its dependencies could not be resolved: Could not find artifact .url=jdbc:postgresql:jar://localhost in central (https://repo.maven.apache.org/maven2)
And then further down
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact .url=jdbc:postgresql:jar://localhost in central (https://repo.maven.apache.org/maven2)
This is the part of the pom.xml where I add the dependency (which is what I can find on Maven https://mvnrepository.com/artifact/org.postgresql/postgresql/42.2.19)
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.19</version>
</dependency>
And for what its worth, this is defined in the Wildfly properties for the database (database.properties)
database.test.url=jdbc:postgresql://localhost:5431/my_database_test
database.test.username=some_user
database.test.password=xxx
database.url=jdbc:postgresql://localhost:5431/my_database
database.username=some_user
database.password=xxx

Maven - can't find Jackson artifact in central repository although it exists?

I have a pom.xml with the following dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
<type>bundle</type>
</dependency>
The dependency exists in Maven's central repo:
https://search.maven.org/artifact/com.fasterxml.jackson.core/jackson-databind/2.9.6/bundle
But when (using Eclipse) i right click on my pom.xml file and choose Run As -> Maven install, it downloads a bunch of dependencies related to that artifact, but finishes with the following error:
[ERROR] Failed to execute goal on project jackson-json-demo: Could not resolve dependencies for project com.elad:jackson-json-demo:jar:1.0.0: Could not find artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.6 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
I tried a couple of other versions and also deleting the dependency from my local repo and trying again, but it didn't help. What could be the issue?
I have never heard of an artifact type bundle. Here's a list of some of the valid artifact type strings.
Just remove the <type /> tag from your dependency block and it will default to jar.

Resolving broken source in Maven central repository

I need two dependencies from the same organization, but it seems the link to their source is broken.
First: https://mvnrepository.com/artifact/org.moxieapps.gwt/uploader
Second: https://mvnrepository.com/artifact/org.moxieapps.gwt/highcharts
<dependency>
<groupId>org.moxieapps.gwt</groupId>
<artifactId>uploader</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.moxieapps.gwt</groupId>
<artifactId>highcharts</artifactId>
<version>1.7.0</version>
</dependency>
[ERROR] Failed to execute goal on project ctap-web: Could not resolve dependencies
for project com.test:test-web:war:1.0.0-SNAPSHOT: The following artifacts could
not be resolved: org.moxieapps.gwt:uploader:jar:1.1.0,
org.moxieapps.gwt:highcharts:jar:1.7.0: Could not find artifact
org.moxieapps.gwt:uploader:jar:1.1.0 in central
(https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read
the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I've downloaded the source from Sourceforge and placed it in .m2/repository/org/moxieapps/gwt/ but Maven still tries to download it from the central repo.
The jar org.moxieapps.gwt:uploader:jar:1.1.0 is not in MavenCentral, which you can see here:
https://search.maven.org/search?q=g:org.moxieapps.gwt%20AND%20a:uploader
Note that mvnrepository (the links you provided) have nothing to do with MavenCentral.

Can't provide version ranges in the maven dependency management import scope

I have a large java project managed using maven.
We are using Maven 3 for management (specifically 3.6.0).
In the project, there is a sub=project with a runtime-v5.pom.xml.
In said pom, there is a version property
<properties>
<platform-v5.version>73.2.05</platform-v5.version>
</properties>
Which is used later in the file
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.company.thing.platform</groupId>
<artifactId>platform-parent</artifactId>
<version>${platform-v5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.company.release</groupId>
<artifactId>platform-v5</artifactId>
<version>${platform-v5.version}</version>
<type>resolved-pom</type>
</dependency>
</dependencies>
</dependencyManagement>
My goal is to get maven to pull in the most recent version of platform and I don't want to update the version in this file every time. I thought that changing the specific version to a range would allow the project to always pull in the most recent version in accordance with the given range.
When the platform-v5.version is set to a specific existing version, it builds just fine, but when setting the version to a range such as [73.2.05,), I get errors such as
[INFO] Scanning for projects...
[INFO] Downloading from all_global_universal: https://nexus.company/platform-parent/%5B73.2.05,).pom
[ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact com.company.thing.platform:platform-parent:pom:[73.2.05,) in all_global_universal (https://nexus.company/content/groups/all_global_universal) # com.company:runtime-v5:[unknown-version], path/to/runtime-v5.pom.xml, line XX, column YY
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.company:runtime-v5:1.0.2 (path/to/runtime-v5.pom.xml) has 1 error
[ERROR] Non-resolvable import POM: Could not find artifact com.company.thing.platform:platform-parent:pom:[73.2.05,) in all_global_universal (https://nexus.company/content/groups/all_global_universal) # com.company:runtime-v5:[unknown-version], path/to/runtime-v5.pom.xml, line XX, column YY -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Essentially, I want to know: Why can't you provide version ranges in the maven dependency management import scope?
While version ranges are not exactly deprecated, they are no longer considered a best practise. The modern way would be to run an appropriate update goal before the build so that the version numbers in the pom are the newest ones available.
This is a duplicate of Using maven dependency management import scope with version ranges
This Maven issue was resolved and will be released in Maven 4.0.0: https://issues.apache.org/jira/browse/MNG-4463

Cannot add local jar files in maven project

I'm trying to repackage log4j so I can use it with Android. In order to do so, I have to use openbeans library and replace each java.beans with com.googlecode.openbeans.
Obviously this is not sufficient, since before repacking the through maven log4j I've to include openbeans-1.0.jar in the project.
So I've found this method.
I've installed openbeans through the following command:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
I've checked that the correct execution of the command checking if the .jar exists in the following path (and it does):
~/.m2/repository/com/googlecode/openbeans/1.0/openbeans-1.0.jar
Then I edited the pom.xml file adding:
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
But if I try mvn package then this error is returned:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run (rmdir_tests_output) on project log4j: Execution rmdir_tests_output of goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its dependencies could not be resolved: Failure to find com.googlecode:openbeans:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Like the install-file didn't worked.
I've tried also with this method, using the following code (obviously I copied the .jar in the project root dir):
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/openbeans-1.0.jar</systemPath>
</dependency>
And here the error returned is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project log4j: Compilation failure
[ERROR] /home/luca/apache-log4j-1.2.17/src/main/java/org/apache/log4j/config/PropertyGetter.java:[31,21] error: package com.googlecode does not exist
What is wrong in what I'm doing?
Even if I still don't understand why, I found out that executing:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode.openbeans -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
And using in pom:
<dependency>
<groupId>com.googlecode.openbeans</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
The code is compiled without error. But as I said, still wondering why.

Categories

Resources