Specifying new Maven repository - maven

Good day!
I've specified in my project's pom.xml file a new repository. So before tags I've added this configuration
<repositories>
<repository>
<id>maven-db-plugin-repo</id>
<name>maven db plugin repository</name>
<url>http://maven-db-plugin.googlecode.com/svn/maven/repo</url>
<layout>default</layout>
</repository>
</repositories>
like indicated here
But, when i'm trying to execute mvn db:update, I'm getting this error:
[ERROR] No plugin found for prefix 'db' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/andriy/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[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/NoPluginFoundForPrefixException
Any suggestions of what I'm doing wrong?
Thanks
Update
I've also added this dependence
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>maven-db-plugin</artifactId>
<version>1.3</version>
<type>jar</type>
</dependency>
And still getting those warnings:
[WARNING] The POM for com.googlecode:maven-db-plugin:jar:1.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.googlecode:maven-db-plugin:1.3: Plugin com.googlecode:maven-db-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.googlecode:maven-db-plugin:jar:1.3

Just adding a repo isn't enough to make a plugin work. You have to configure the plugin in your pom, too. There's an example of configuring the maven-db-plugin at the bottom of the project's home page.
The maven-sql-plugin has better documentation. If it fits your needs, you might just use that instead.

I think you have to have the following configuration:
<pluginRepositories>
<pluginRepository>
<id>maven-db-plugin-repo</id>
<name>maven db plugin repository</name>
<url>http://maven-db-plugin.googlecode.com/svn/maven/repo</url>
<layout>default</layout>
</pluginRepository>

Related

Adding a Github release to my maven pom.xml file

I need to add the following GitHub project as a dependency in my pom.xml:
https://github.com/loomchild/maligna
This project defines two maven modules: maligna and maligna-ui and I need both.
Unfortunately, it seems only the first module (maligna) is being deployed to a maven artifactory.
I tried using jitPack, as follows:
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
...
<depencies>
...
<dependency>
<groupId>com.github.loomchild.maligna</groupId>
<artifactId>maligna-ui</artifactId>
<version>3.0.1</version>
</dependency>
...
</depencies>
but I get the following error
[ERROR] Failed to execute goal on project iutools-core: Could not resolve dependencies for project org.iutools:iutools-core:jar:1.0.2: Failure to find com.github.loomchild.maligna:maligna-ui:jar:3.0.1 in https://repository.apache.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced -> [Help 1]
Is there something I misundertand about how to use jitPack?

No transfer protocol found while deploying an artifact using maven deploy in Azure DevOps

When I am trying to deploy a JAR artifact to artifact feed in Azure DevOPS facing the below issue.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project: No transfer protocol found. -> [Help 1]
[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/MojoExecutionException
Below is my YAML code:
- task: Maven#3
displayName: 'Maven Deploy'
inputs:
mavenPomFile: 'pom.xml'
goals: 'deploy:deploy-file'
options: '-DgroupId="com.mycompany" -DartifactId="s-demo-cicd" -Dversion="1.0.1" -
Dpackaging=jar -Dfile="demo-1.0.1-mule-application.jar" -DgeneratePom="true" -
DrepositoryId="$AZURE_FEED_ID" -Durl="$AZURE_FEED_URL"'
I have added required dependencies in POM.xml file.
<distributionManagement>
<repository>
<id>demo-mule</id>
<url>https://pkgs.dev.azure.com/demo-mule/_packaging/demo-mule/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
Please help me understand where I need to make the changes or updates.
To pass a variable into the parameters of the Maven task, make sure you use the correct notation. It can be a bit confusing at times.
In this case use $(...) instead of $.... So your task would look like this:
- task: Maven#3
displayName: 'Maven Deploy'
inputs:
mavenPomFile: 'pom.xml'
goals: 'deploy:deploy-file'
options: '-DgroupId="com.mycompany" -DartifactId="s-demo-cicd" -Dversion="1.0.1" -
Dpackaging=jar -Dfile="demo-1.0.1-mule-application.jar" -DgeneratePom="true" -
DrepositoryId="$(AZURE_FEED_ID)" -Durl="$(AZURE_FEED_URL)"'

Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?

I am working from a private network, trying to a buildpipeline for a Maven project. To work with tools on our private network I am trying to use a Private Hosted Agent. Now I know there are some restrictions on reaching Maven Central from our network, normally we use a proxy through Nexus for this.
With the new Maven Upstream feature in Azure artifacts I thought I could use this as a 'proxy'.
Unfortunately the build is failing, it seems to try and reach Maven Central directly (not using my feed) which naturally fails. Below my output and settings
And finally my build output:
2019-10-02T07:27:06.0094285Z Task : Maven
2019-10-02T07:27:06.0094336Z Description : Build, test, and deploy with Apache Maven
2019-10-02T07:27:06.0094403Z Version : 3.158.0
2019-10-02T07:27:06.0094449Z Author : Microsoft Corporation
2019-10-02T07:27:06.0094522Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/maven
2019-10-02T07:27:06.0094582Z ==============================================================================
2019-10-02T07:27:06.8762822Z [command]C:\windows\system32\reg.exe query "HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.8" /v JavaHome /reg:64
2019-10-02T07:27:06.8762932Z
2019-10-02T07:27:06.8763016Z HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8
2019-10-02T07:27:06.8763085Z JavaHome REG_SZ C:\Program Files\Java\jdk1.8.0_221
2019-10-02T07:27:06.8763156Z
2019-10-02T07:27:06.9319606Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -version"
2019-10-02T07:27:07.4696051Z Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
2019-10-02T07:27:07.4700024Z Maven home: C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\..
2019-10-02T07:27:07.4709043Z Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
2019-10-02T07:27:07.4725586Z Default locale: en_US, platform encoding: Cp1252
2019-10-02T07:27:07.4726158Z OS name: "windows server 2016", version: "10.0", arch: "amd64", family: "windows"
2019-10-02T07:27:07.5446027Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:07.7710829Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0375908Z ##[warning]The settings for the feed or repository already exists in the xml file.
2019-10-02T07:27:08.0492975Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0530287Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -f C:\DATA\Agent\_work\71\s\pom.xml -s C:\DATA\Agent\_work\_temp\settings.xml package"
2019-10-02T07:27:09.9877350Z [INFO] Scanning for projects...
2019-10-02T07:27:10.0851393Z [INFO]
2019-10-02T07:27:10.0897285Z [INFO] ---------< com.ontestautomation.javafortesters:JavaForTesters >---------
2019-10-02T07:27:10.0941394Z [INFO] Building JavaForTesters 1.0-SNAPSHOT
2019-10-02T07:27:10.0942123Z [INFO] --------------------------------[ jar ]---------------------------------
2019-10-02T07:27:10.6741134Z Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
2019-10-02T07:27:31.8954116Z The process 'C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd' failed with exit code 1
2019-10-02T07:27:31.8954401Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955258Z Could not retrieve code analysis results - Maven run failed.
2019-10-02T07:27:31.8955423Z [INFO] BUILD FAILURE
2019-10-02T07:27:31.8955503Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955591Z [INFO] Total time: 21.842 s
2019-10-02T07:27:31.8955658Z [INFO] Finished at: 2019-10-02T07:27:31Z
2019-10-02T07:27:31.8955759Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955928Z [ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.36.215] failed: Connection timed out: connect -> [Help 1]
2019-10-02T07:27:31.8956093Z [ERROR]
2019-10-02T07:27:31.8958075Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2019-10-02T07:27:31.8958201Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2019-10-02T07:27:31.8958274Z [ERROR]
2019-10-02T07:27:31.8958331Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2019-10-02T07:27:31.8958423Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
2019-10-02T07:27:33.1008909Z No test result files matching C:\DATA\Agent\_work\71\s\**\surefire-reports\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2019-10-02T07:27:33.1015611Z ##[error]Build failed.
2019-10-02T07:27:33.1185161Z ##[section]Finishing: Maven ```
Anyone any ideas?
Thanks!
Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?
The answer should be yes.
The reason why it still reach Maven Central directly is that all pom files inherit from the maven super POM:
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
which contains this entry:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
So, we could overwrite it in your pom with Azure DevOps artifacts:
<repositories>
<repository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases><enabled>false</enabled></releases>
</pluginRepository>
</pluginRepositories>
Or you can use the maven Mirrors to to replace a particular repository with your own internal repository.
Check more details about this issue, please check this ticket.
Besides, you could also set the Proxies in the your pom.
Hope this helps.

Official Maven repo for com.springsource.org.jboss.el

I have a project with a dependency org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA for which I am trying to find the official Maven repository.
It is unclear to me where this depedency should come from. Should I download this and create a Nexus repo myself. Is there a official repo for this artifact?
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project myjar:jar:5.0.0-SNAPSHOT: Failure to find org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA in https://mynexusserver/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
The artifact org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA is available from Spring repositories:
You can add them by adding this snippet inside your settings or POM:
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
Note that the error message you are getting suggest to run Maven with the -U option also, to force the updates of dependencies.

Maven: Error resolving version for plugin

I am trying to get Batik working, having not worked with Java much in the last ten years or so and I'm running into problems with Maven being able to find the org.apache.maven.wagon:wagon-ssh-external package.
When I open or try to build the project in Netbeans, it reports the following error:
The project org.freehep:freehep-graphicsio:2.1.1 (/home/glenatron/Projects/batik/freehep-graphicsio/pom.xml) has 1 error
Unresolveable build extension:
Error resolving version for plugin 'org.apache.maven.wagon:wagon-ssh-external' from the repositories [local (/home/glenatron/.m2/repository), freehep-maven (http://java.freehep.org/maven2), central (http://www.ibiblio.org/maven2), Codehaus (http://repository.codehaus.org/), Codehaus Snapshots (http://snapshots.repository.codehaus.org/)]:
Plugin not found in any plugin repository -> [Help 2]
As far as I can tell this is correct, however, I have the following in my pom.xml file for the project:
<repositories>
<repository>
<id>freehep-maven</id>
<name>Maven FreeHEP</name>
<url>http://java.freehep.org/maven2</url>
</repository>
<repository>
<id>maven-apache</id>
<name>Maven Apache</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
From what I can judge a) that plugin should be available in one of those repositories and b) if they are in the pom.xml file, Maven should be searching them but I can't see any sign of it doing that.
The project I am trying to work with is the FreeHEP EMF driver. The bigger screen solution was to use the unsignposted but much more up to date Github repository version.
It turns out that the solution was in the message after all: Error resolving version for plugin.
So obviously it's not a repository it is a pluginRepository which goes in a different part of pom.xml:
<pluginRepositories>
<pluginRepository>
<id>maven1</id>
<name>Maven.org</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
Remove the entries with repo1... cause this is maven Central and used by Maven by default so no need to define it explicit. Furthermore the given freehep.org is also available via Maven Central. So if i see it correct you don't need to define supplemental repositories at all.

Resources