It's it possible to bundle a jar inside a Jenkins plugin? - jenkins

I'm trying to write a Jenkins plugin that uses YUI compressor. Is it possible somehow to bundle the yui jar file with/inside my pluigin?

Yes it is possible. You need to add the dependency into the pom.xml file (assuming you are using Maven) and when you build the hpi file it will include it
add
<dependency>
<groupId>com.yahoo.platform.yui</groupId>
<artifactId>yuicompressor</artifactId>
<version>2.4.7</version>
</dependency>
into you dependencies - taken from here http://mvnrepository.com/artifact/com.yahoo.platform.yui/yuicompressor/2.4.7

Related

When running mvn versions:display-dependency-updates only some dependencies are processed

When I run
mvn versions:display-dependency-updates
Only some of my dependencies are processed.
For instance I have this dependency.
<dependency>
<groupId>com.github.kagkarlsson</groupId>
<artifactId>db-scheduler-spring-boot-starter</artifactId>
<version>6.2</version>
</dependency>
Im not informed that there is a version 6.6 available. Why is that?
Im using maven 3.6.0
Check if your project pom.xml or your maven settings.xml is not overriding the central repository, if central repo is customized, it may not contain the recent version of this dependency

Jenkins build failure due to use of custom jars in maven project

I am having a trouble while building my java maven project in jenkins.
In my project, there are few custom jars which I included in pom like this
<dependency>
<groupId>SMSGatewayClient</groupId>
<artifactId>SMSGatewayClient</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\lib\SMSGatewayClient.jar</systemPath>
</dependency>
But jenkins throwing exception
"Could not find artifact SMSGatewayClient:SMSGatewayClient:jar:1.0 at
specified path
/var/lib/jenkins/workspace/DEV-metal-auc/MetalBusiness_mvn\lib\SMSGatewayClient.jar"
and build is stopped.
How can I use that custom jar so that jenkins builds successfully?
Have you tried using ”/" path separators (or ${file.separator} ) in the path?
Your error shows a mix and /var/lib/ suggests you are on unix.
That assumes the ${basedir} resolved correctly.
You can also use relative notation ( ../ ) and is probably preferred if inside your workspace. You may wish to review Maven complaining about parent relative path and Maven: add a dependency to a jar by relative path
In maven, "${basedir} represents the directory containing pom.xml", so
<relativePath>./lib</relativePath>. If you had to fo up,and down, ../ for each level up, then path down.

How Jenkins plugins works

I had a situation where I have developed my own Jenkins plugin for the first time. The main purpose of the plugin is to publish a message to Google Cloud Platform. All the code that I have written in Jenkins is working fine in the local environment from eclipse. But when I am using the same code in Jenkins it is causing some dependency errors. Any help is really appreciated.
Thank you.
Note: Jenkins and Eclipse are on the same machine
How Jenkins resolves its dependencies is really a concern here for me.
Eclipse uses the M2eclipse plugin to add your dependencies to the classpath when running your plugin from Eclipse.
Jenkins only resolves dependencies between plugins. Furthermore Jenkins expects the .hpi packages to be self-contained, i.e. containing all JAR dependencies you need. mvn package should copy the jars of all your dependencies and put them in the .hpi file in the WEB-INF/lib folder.
In your specific case it seems that the Google Cloud implementation expects some implementation of a channel service provider on the classpath, so you should add a dependency on grpc-okhttp or grpc-netty, so they get packaged into the .hpi file as well.
Sometimes there could be a choice of class loader issue so please add follwing lines of code before calling classes of Google.
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
Also add the following code in Jenkins plugin pom.xml to specify Jenkins that the dependencies in the pom.xml should be loaded first rather than Jenkins dependencies.
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
**<configuration>
<pluginFirstClassLoader>true</pluginFirstClassLoader>
</configuration>**
</plugin>
</plugins>
</pluginManagement>

where to get Apache Tika jar?

All:
I try to build app using Apache Tika to parse PDF, but I wonder where can I get those libraries like tika-core/target/tika-core-.jar and tika-parsers/target/tika-parsers-.jar
I only find tika-app but there is no such jar like above.
http://tika.apache.org/1.11/gettingstarted.html
Apache Tika has a large number of dependencies it needs to run. Without those present, it will do very little!
You therefore need do use a dependency management tool to not only get Apache Tika, but also the other libraries it needs. If you're using Apache Maven to do that, you can follow the instructions on the Tika website to add it as a dependency to your project with a section in your pom like:
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.11</version>
</dependency>
The Apache Tika quickstart page also lists instructions on adding a dependency to Tika, along with all required dependencies, for both Gradle and Ivy builds too. You really ought to be using one of Maven, Gradle or Ivy to be handling the dependencies for you
If you really do want to handle all the dependencies yourself, you can find the Tika Core and Tika Parsers binary jars on Maven central, in the usual place. For Tika 1.11, that's here for the tika-core jar and here for the tika-parsers jar. But, as previously mentioned, you almost certainly don't want to be doing that by hand!

Why is Grails taking the jar dependencies instead of the existing maven project dependencies?

I'm using IntelliJ IDEA 10.0.2 (with groovy/grails support), maven 2.2.1 and grails 1.3.6.
We have a big maven project, which depends on many other maven projects. Let's say the workspace structure looks as follows:
backend-project (Java project, without further project dependencies)
output-project (Java project, without further project dependencies)
frontend-project (Grails project, which dependes on both, backend and output)
That means, within my frontend-project's pom.xml I have defined 2 Project Dependencies:
e.g.
<dependency>
<groupId>com.company.project</groupId>
<artifactId>backend-project</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.company.project</groupId>
<artifactId>output-project</artifactId>
<version>${project.version}</version>
</dependency>
Let's assume that I change some Java Source within the output or backend project. When I
run the grails application now, then it won't consider the changes. I have to publish the changed artifact locally and then resolve it again by the grails project before running the application in order to take effect.
This tells me that the grails project just depends on the project dependency jars within the maven repository and does not care about any existing project dependency "sources" within the workspace.
Does it have to be that complicated and if so, why?
Note that if my frontend project was a spring web project, the changes will be seen in IDEA and tomcat will even reload the change dynamically.
Note that when IDEA recognizes a mavenized grails project, it won't run the grails project with: "grail run-app" anymore but with a more complicated version of: "mvn grails:exec -Dcommand=run-app". Don't know if this is of any relevance..
Thanks!
Mr. Slash
Maven always picks up the jar files from the repositories (local and then remote etc depending on your pom.xml config).
Think about it: How would your main project know where the backend-project or the output-project files are located?
If you want a direct dependency then remove it from pom.xml and modify the project build path to directly add the projects' outputs to your main projects. In Eclipse open the properties page of the main project => build path => projects => add.

Resources