Ant task with native libs

I’m trying to integrate a SASS compiler into my gradle build and found a nice ant task that uses the native libsass library via JNA (found at https://github.com/cathive/sass-java).
On the page detailed information can be found on how to run in a maven environment (that is running fine) but I’m experiencing some strange problems trying to get it running with gradle.

A simple project using the task can be build with this script:

apply plugin: ‘java’

repositories {
jcenter()
}

configurations {
sass
}

dependencies {
sass “com.cathive.sass:sass-java:4.0.0”
}

task sassCompile << {
ant.taskdef (name:‘sass’, classname:‘com.cathive.sass.SassTask’, classpath: configurations.sass.asPath)
ant.sass (in: file(‘test.scss’), outDir: file(‘.’))
}

When executing the task I get this error message:

java.lang.UnsatisfiedLinkError: Unable to load library ‘sass’: Native library (win32-x86-64/sass.dll) not found in resource path ([file:/C:/Users/kloe/.gradle/wrapper/dists/gradle-2.14.1-bin/2r579t5wehc7ew5kc8vfqezww/gradle-2.14.1/lib/ant-1.9.6.jar, file:/C:/Users/kloe/.gradle/wrapper/dists/gradle-2.14.1-bin/2r579t5wehc7ew5kc8vfqezww/gradle-2.14.1/lib/ant-launcher-1.9.6.jar])

The solution seems to be extending the resource path as the libraries from the sass configuration are missing but I didn’t find any information on this topic.

How do I do this the gradle way?

Many thanks,
Steven

1 Like