How to release and reference Grails plugins using local Maven repository - maven

Summary
I create two plugins A and B with Grails 2.3.4 where B is a plugin used by A plugin. I get error when I use A plugin in my application.
Details
When I run the following command, for plugin B, it successfully release the plugin to local maven repository. I can see it in the ~/.m2/... folder.
~plugin-b: grails maven-install
Then I add a reference to plugin B with plugin A, so I add the reference to BuildConfig in plugin A:
plugins {
compile "com.test.plugins:b:1.0.0-SNAPSHOT"
}
Now, I think, I should be able to run the next command and the plugin should be released to the local maven repository but I get the error instead:
~plugin-a: grails maven-install
| Plugin packaged grails-a-1.0.0-SNAPSHOT.zip
| Generating POM file.....
| Error Could not find artifact com.test.plugins:b:jar:1.0.0-SNAPSHOT (scope: compile) (Use --stacktrace to see the full trace)
| POM generated: //dependencies/dependencies_A_plugin/target/pom.xml...
Maven install complete.
Here is the generated POM file:
// pom header
<artifactId>a</artifactId>
<packaging>zip</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>A</name>
<description>Brief summary/description of the plugin.
</description>
<url>http://grails.org/plugin/a</url>
<developers>
<developer>
<name>Your name</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>com.test.plugins</groupId>
<artifactId>b</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
... just ending tags
Actually, also plugin A has been released to the local Maven repository, but it is probably corrupted, because when I create a Grails application and add a reference to A plugin into BuildConfig, then I am not even able to start up that application.
~ grails
| Error Resolve error obtaining dependencies: Could not find artifact com.test.plugins:b:jar:1.0.0-SNAPSHOT (Use --stacktrace to see the full trace)
| Error Could not find artifact com.test.plugins:b:jar:1.0.0-SNAPSHOT
So, the application has found A plugin, but not the B plugin, which is referenced by A plugin. To me, it seems there is an issue with generated POM file in the local Maven repository for the A plugin. There is probably missing:
<type>zip</type>
But I have not found a way how to add the type to that dependency.
Anyone able to help?

Related

Maven release plugin

Hi Meier I have used the following goal
mvn org.codehaus.mojo:versions-maven-plugin:2.7:update-property -
Dproperty=emom.web.dependency.shr.version -DallowSnapshots=true
My Job B pom.xml is
<dependency>
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>${emom.web.dependency.shr.version}</version>
</dependency>
Under the properties it has version harcoded
<emom.web.dependency.shr.version>19.6.5-
SNAPSHOT</emom.web.dependency.shr.version>
My Job A pom.xml
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>20.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
When I run the above goal maven is picking the latest version i,e(20.1.0)
from artifactory but when I check the pom.xml of Job B under properties it still says 19.6.5 I need a way to change the 19.6.5 or current version to latest version available. Am I doing something wrong not able to figure it out.
You need versions:update-property to update the content of properties in your POM.
See https://www.mojohaus.org/versions-maven-plugin/update-property-mojo.html

Issue in adding third party dependency in Maven during Jenkins build - ODM

I am trying to build ODM projects outside of eclipse using the Jenkins pipeline and Maven plugin. I am following the link : https://www.ibm.com/support/knowledgecenter/en/SSQP76_8.9.0/com.ibm.odm.dserver.rules.designer.run/build_topics/con_buildcmd_intro.html
Though this link works well without the Jenkins pipeline in my local(Windows), but when I try to run the same setup in Jenkins(Linux machine), I am getting the following error :
[WARNING] The POM for com.ibm.rules.buildcommand:rules-compiler-maven-plugin:jar:8.10.0.0 is missing, no dependency information available
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # helloWorld:hello-xom:[unknown-version], /var/lib/jenkins/workspace/odm-devops-build/Hello XOM/pom.xml, line 19, column 21
[ERROR] Unresolveable build extension: Plugin com.ibm.rules.buildcommand:rules-compiler-maven-plugin:8.10.0.0 or one of its dependencies could not be resolved: Failure to find com.ibm.rules.buildcommand:rules-compiler-maven-plugin:jar:8.10.0.0 in https://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 #
[ERROR] Unknown packaging: decisionservice # helloWorld:hello-main:[unknown-version], /var/lib/jenkins/workspace/odm-devops-build/Hello Main Service/pom.xml, line 14, column 16
The pom file which is referred in the above error is as below:
<?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>
<parent>
<groupId>helloWorld</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>hello-main</artifactId>
<packaging>decisionservice</packaging>
<build>
<plugins>
<plugin>
<groupId>com.ibm.rules.buildcommand</groupId>
<artifactId>rules-compiler-maven-plugin</artifactId>
<configuration>
<deployments>
<deployment>
<name>simple dep</name>
</deployment>
</deployments>
<resolvers>
<resolver>
<!-- The values of the kind and url of the project correspond to the 'kind' and 'url' attribute values of an 'entries' element in the .ruleproject file. -->
<kind>JAVA_PROJECT</kind>
<url>platform:/Hello XOM</url>
<!-- The artifactKey references the groupId and artifactId of a Maven dependency. -->
<artifactKey>${project.groupId}:hello-xom</artifactKey>
</resolver>
</resolvers>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>hello-xom</artifactId>
<type>jar</type>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Please let me know if anyone has faced a similar issue or has a possible resolution to the above issue.
Thanks in advance.
Possible resolution: "install the Build Command Maven plugin and its related Operational Decision Manager artifacts in your Maven repository" ... "on each machine that contains build agents"
To deploy the Build Command Maven plugin to a remote Maven repository, you must configure Maven in your environment. You then use the following command: mvn deploy:deploy-file -Dfile=rules-compiler-maven-plugin.jar -DpomFile=rules-compiler-maven-plugin.pom
This requires access to the Jenkins / Maven server, and at many companies would be done by DevOps.
You install the Build Command Maven plugin and its related Operational Decision Manager artifacts in your Maven repository.
Deploying the Build Command plugin
You deploy the plugin only once on each machine that contains build agents.
To deploy the Build Command Maven plugin to a remote Maven repository, you must first configure Maven in your environment.
Then, in <InstallDir>/buildcommand/rules-compiler, open a command prompt.
Use the following command:
mvn deploy:deploy-file -Dfile=rules-compiler.jar -DpomFile=rules-compiler-maven-plugin.pom
If you do not have a remote repository, you can test the plugin locally. You run the following command:
mvn install:install-file -Dfile=rules-compiler.jar -DpomFile=rules-compiler-maven-plugin.pom
This command adds the following plugin in your local Maven repository:
com/ibm/rules/buildcommand/rules-compiler
 Deploying the annotations archive
If you want to build COBOL projects or projects that use XOM annotations, you must also deploy the annotations archive to your environment before you can build the projects.
In <InstallDir>/buildcommand/rules-compiler, open a command prompt.
Use the following command:
mvn deploy:deploy-file -Dfile=rules-compiler.jar -DpomFile=xom-annotations.pom
If you do not have a remote repository, you can test the plugin locally. You run the following command:
mvn install:install-file -Dfile=rules-compiler.jar -DpomFile=xom-annotations.pom
This command adds the following plugin in your local Maven repository:
com/ibm/rules/buildcommand/xom-annotation
Source

Need explanation for maven error please

http://blog.bigpixel.ro/2012/07/building-cc-applications-with-maven/comment-page-1/#comment-8196
I'm following the example above for the maven nar plugin, but I get the following error when I do a mvn package
“could not find artifact net.sf.antcontrib:cpptasks-parallel:jar:1.0-beta-5-parallel-1-SNAPSHOT” but I see the following folder tree and its contents in my ~/.m2/repository... What gives?
~
.m2
repository
net
sf
antcontrib
cpptasks-parallel
1.0-beta-5-parallel-1-SNAPSHOT
Change dependency
<dependency>
<groupId>net.sf.antcontrib</groupId>
<artifactId>cpptasks-parallel</artifactId>
<version>1.0-beta-5-parallel-1-SNAPSHOT</version>
</dependency>
to
<dependency>
<groupId>org.codeswarm</groupId>
<artifactId>cpptasks-parallel</artifactId>
<version>20121119</version>
</dependency>
Unfortunately, neither maven-nar-plugin nor cpptasks-parallel are currently deployed to Central. So you need to mvn install them yourself (or better, mvn deploy them to your own Maven repository). You can find both projects on GitHub.
EDIT: nar-maven-plugin version 3.0.0 has been released, and is now available from Maven Central. Two notes:
The groupId and artifactId changed; the GAV is now:
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
The cpptasks-parallel project has been merged into nar-maven-plugin, so no need to worry about that dependency anymore.

Artifactory maven 3 unable to find a snapshot file

I am having problems getting artifactory to suppy a jar file to a maven 3 build process
I have deploy the jar file gwt-openlayers-server-1.0-SNAPSHOT.jar to libs-snapshot-local
I can find this jar file by using the general lookup in the Artifacts tab, it shows up as
<dependency>
<groupId>org.gwtopenmaps.openlayers</groupId>
<artifactId>gwt-openlayers-server</artifactId>
<version>1.0-20130320.151820-1</version>
</dependency>
So I known artifactory has it.
When I attempt to do a build using a pom with the following section in it
<dependency>
<groupId>org.gwtopenmaps.openlayers</groupId>
<artifactId>gwt-openlayers-server</artifactId>
<version>1.0-SNAPSHOT</version>
I get a build error with a diagnostic about being unable to find gwt-openlater-server, see listing.
I don't understand why I am having this problem, artifactory has the file!
I am using mvn -U compile
Any suggestions
Check if you have maven-metadata.xml corruption, or perhaps your snapshot info is empty. It shouldn't be.

Maven - Unable to resolve dependencies

Im trying to compile a Maven project. The compile fails however due to a "Failure to find xx.xxx.jar" in the repository i have specified in my settings.xml. I have access to this repository and when i navigate to the Url of the repository maven is trying to use i can see a pom file with the name of the jar but no jar. When i open the pom it contains the correct groupid and artificatid and jar name however the jar is not in the same directory.
Maven gives another error saying that "resolution will not be reattempted until the update interval of my repo-server has elasped or updated are forced".
What is happening here?
When maven goes to the repo i specify in settings.xml and finds a pom for the jar does it then try and go out to some external site to resolve the dependency or should the jar exist in the same folder as the pom?
What module are you attempting to download?
I discovered something similar with the following Maven central module:
http://search.maven.org/#artifactdetails|net.sf.json-lib|json-lib|2.4|jar
The Maven POM packaging declaration was jar, but no jar in Maven called "json-lib-2.4.jar"
When I looked at the files actually stored, I discovered that the author is providing two versions of the jar, each compiled for different versions of the JVM:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk13</classifier>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>

Resources