[API] Java API: How do I add dependencies to the classpath?

Post Reply New Topic
RELATED
PRODUCTS

Post

Hi,

where do I need to drop my dependencies (eg log4j) in order for the extension classloader to find them?
I tried creating a fat fat using maven shade, but I still get NoClassDefFoundError exceptions.

thanks,
felix

Post

Can you post your pom.xml?

Post

Code: Select all

<?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>
	<groupId>de.mossgrabers</groupId>
	<artifactId>DrivenByMoss</artifactId>
	<packaging>jar</packaging>
	<name>DrivenByMoss</name>
	<version>LOCAL-23</version>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <bitwig.extension.directory>/home/felix/Bitwig Studio/Extensions</bitwig.extension.directory>
	</properties>

	<repositories>
		<repository>
			<id>bitwig</id>
			<name>Bitwig Maven Repository</name>
			<url>https://maven.bitwig.com</url>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>com.bitwig</groupId>
			<artifactId>extension-api</artifactId>
			<version>5</version>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>2.7</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.7</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-slf4j-impl</artifactId>
			<version>2.7</version>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.5.1</version>
				<configuration>
					<optimize>true</optimize>
					<fork>true</fork>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
					<maxmem>1024m</maxmem>
				</configuration>
			</plugin>

			<plugin>
				<groupId>com.coderplus.maven.plugins</groupId>
				<artifactId>copy-rename-maven-plugin</artifactId>
				<version>1.0</version>
				<executions>
					<execution>
						<id>rename-file</id>
						<phase>install</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<sourceFile>${project.build.directory}/${project.build.finalName}.jar</sourceFile>
							<destinationFile>${bitwig.extension.directory}/DrivenByMoss.bwextension</destinationFile>
						</configuration>
					</execution>
				</executions>
			</plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>com.bitwig:extension-api</exclude>
                                </excludes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <finalName>uber-${artifactId}-${version}</finalName>
                </configuration>
            </plugin>

		</plugins>
	</build>

</project>

Post

You need to run the shader before the copy plugin.

Post

Yes, thanks, that worked!

Post Reply

Return to “Controller Scripting”