Page 1 of 1

Oxygen plugins - how to include dependent libraries as jars in the install goal, or build?

Posted: Mon Feb 03, 2020 6:19 pm
by wmaclean
Hello,
I am using the oxygen-sample-plugin-workspace-access project as a basis for a proof-of-concept. I want to include a jar as a dependency.

I’ve added the jar to the local repository, with the following command:

Code: Select all

>mvn install:install-file -Dfile=C:\<path>\LinkFinder.jar -DgroupId=com.nom.id -DartifactId=linklookup -Dversion=1.0 -Dpackaging=jar
I can verify the jar, pom and other files are deployed here, in the local repository:

Code: Select all

C:\<path>\.m2\repository\com\nom\id\linklookup\1.0
I added the artifact to the project pom file like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<project>
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>myGroup</groupId>
		<artifactId>oxygen-sample-plugins</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<artifactId>oxygen-sample-plugin-workspace-access</artifactId>
	<dependencies>
		<dependency>
			<groupId>com.nom.id</groupId>
			<artifactId>linklookup</artifactId>
			<version>1.0</version>
		</dependency>
	</dependencies>
I’ve added some code to the project, referencing a class in the jar, and it compiles fine – so I know the project is finding the jar.

When I run the maven install goal, it builds successfully. But when I try to use the new code, I get this error:

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/nom/id/linklookup/LinkLookupQueryFrame
	at myGroup.mySample.workspace.CustomWorkspaceAccessPluginExtension.insertLink(CustomWorkspaceAccessPluginExtension.java:373)
I can find the project jar deployed to Oxygen here:

C:\<path>\oxygen\plugins\oxygen-sample-plugin-workspace-access-0.0.1\lib\oxygen-sample-plugin-workspace-access-0.0.1.jar

But, I can’t find the LinkFinder.jar file, which contains the class in the error. I need to include the jar as a dependency in the deployment for the code to work. How can I do that?

I was going to try using the <includes><include> tag under <configuration> in the pom.xml file, as documented here:

https://maven.apache.org/plugins/maven- ... clude.html

But, <include> does not appear to be an option in my project.

I was also looking at <includes> under <resources> in the pom.xml file, as covered here:

https://maven.apache.org/plugins/maven- ... clude.html

But jars don’t seem to be something you want to put in the \resources folder.

How do you include jar files as dependencies during the “install” goal in maven? Or, any standard way?

Thank you,
Will

Re: Oxygen plugins - how to include dependent libraries as jars in the install goal, or build?

Posted: Tue Feb 04, 2020 11:56 am
by Radu
Hi Will,

My advice for you is to start from this simple Maven Worskspace Access plugin project:

https://github.com/oxygenxml/sample-plu ... ce-access/

It has a readme which can help.
Clone/download it locally, use for example the Eclipse workbench to import the project as a Maven project in the workbench.
Then make changes to its "pom.xml". It uses an "assembly.xml" located next to it to copy all dependency JAR libraries inside the final created JAR library which will contain the entire set of plugin files (plugin.xml and both JAR libraries).

In the end if all goes well the plugin folder which you copy to the Oxygen "plugins" folder should look like this:

Code: Select all

C:\<path>\oxygen\plugins\oxygen-plugin-workspace-access-1.0\lib\oxygen-plugin-workspace-access-1.0.jar
C:\<path>\oxygen\plugins\oxygen-plugin-workspace-access-1.0\lib\LinkFinder.jar
C:\<path>\oxygen\plugins\oxygen-plugin-workspace-access-1.0\plugin.xml
.

Regards,
Radu

Re: Oxygen plugins - how to include dependent libraries as jars in the install goal, or build?

Posted: Tue Feb 11, 2020 6:15 pm
by wmaclean
Hi Radu,
Thank you very much for the suggestion. I will try it shortly.

I was able to find a workaround for the time being (manually copying the jars to the plugins folder), but will need the info you gave for the next version.

I appreciate the help!
Will