Reputation: 332
I want to build a static library as a jar, so that it can be included into my project (without the need to compile it within our project).
I built a static library (with java and ant references valid):
cmake -DBUILD_SHARED_LIBS=OFF ..
build -j8
In IntelliJ, I referenced the .jar file as a dependency: ProjectStructure > Modules > Dependencies > Add Jar (scope = compile)
The file shows up in External Libraries as expected. Code completion works, e.g. import org.opencv.core.Core;
is found.
I noticed that unlike other External Libraries, this one doesn't have a "Gradle:" prefix.
When I build, I get an error:
/Users/tj/Documents/projects/myProject/src/main/java/edu/wpi/cscore/CameraServerJNI.java:17:
error: package org.opencv does not exist
import org.opencv.core;
Upvotes: 1
Views: 1039
Reputation: 34920
Doing so as you did (ProjectStructure > Modules > Dependencies > Add Jar) is not proper way of adding libraries into the Gradle or Maven project. All project's libraries in this case should be specified in build file, and Intellij Idea will automatically discover them and will include into its own Project description.
Upvotes: 1