So Java 9 is there, soon to be followed by Java 10. Time we should make our libraries ready for use in Java 9 projects. I did it in the following way:
provide a module-info.java
added the (experimental) jigsaw plugin in build.gradle
Manually made changes according to the guide on the gradle site instead of using the jigsaw plugin.
So far, both approaches work fine, and I can use the generated Jar in Java 9 projects.
The problem is, the resulting Jar is not compatible with Java 8 although I used no Java 9 features except the module-info.java. When I set targetCompatibility = 8, an error message tells me to also set sourceCompatibility = 8 accordingly. Which then rejects the module-info.java for which I should set sourceCompatibility = 9.
How can this be solved?
I removed the jigsaw plugin again, and tried this, but am stuck:
set sourceCompatibility = 8 and targetCompatibility = 8
create a new source set moduleInfo that contains the single file module-info.java
set sourceCompatibility = 9 and targetCompatibility = 9 for the new sourceset
Now compilation works, and Gradle uses Java 9 when it tries to compile the module-info.java. However, modules (in this case log4j) are missing, and I get this error:
:compileJava UP-TO-DATE
:processResources NO-SOURCE
:classes UP-TO-DATE
:jar UP-TO-DATE
:sourcesJar UP-TO-DATE
:assemble UP-TO-DATE
:spotbugsMain UP-TO-DATE
:compileModuleInfoJava
classpath:
compilerArgs: [--module-path, , --add-modules, ALL-SYSTEM]
D:\git\utility\src\module-info\java\module-info.java:14: error: module not found: org.apache.logging.log4j
requires org.apache.logging.log4j;
^
warning: using incubating module(s): jdk.incubator.httpclient
1 error
1 warning
:compileModuleInfoJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileModuleInfoJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
5 actionable tasks: 1 executed, 4 up-to-date
This is the build.gradle used (Gradle version is 4.5.1):
plugins {
id "com.github.spotbugs" version "1.6.0"
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'com.github.spotbugs'
sourceCompatibility = 8
targetCompatibility = 8
group = 'com.dua3.utility'
repositories {
mavenLocal()
jcenter()
}
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.10.0'
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.10.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
ext.moduleName = 'com.dua3.utility'
sourceSets {
moduleInfo {
java {
srcDir 'src/module-info/java'
}
}
}
compileModuleInfoJava {
sourceCompatibility = 9
targetCompatibility = 9
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-SYSTEM'
]
classpath = files()
System.out.println("classpath: "+classpath.asPath)
System.out.println("compilerArgs: "+options.compilerArgs)
}
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled false
html.enabled true
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
// fails with jigsaw: archives javadocJar
}
defaultTasks 'build', 'publishToMavenLocal', 'install'
And this is module-info.java:
module com.dua3.utility {
exports com.dua3.utility;
exports com.dua3.utility.io;
exports com.dua3.utility.jfx;
exports com.dua3.utility.swing;
exports com.dua3.utility.lang;
exports com.dua3.utility.math;
exports com.dua3.utility.text;
requires javafx.controls;
requires javafx.web;
requires java.xml;
requires java.desktop;
requires org.apache.logging.log4j;
}
OK, I finally got it working. In case anyone else wants to know how to do it, this is what I have done:
set the Java version to 8, so that the library will be usable by Java 8 applications:
sourceCompatibility = 8
targetCompatibility = 8
configure the module name
ext.moduleName = com.dua3.utility
add a new sourceset consisting only of module-info.java:
sourceSets {
moduleInfo {
java {
srcDir 'src/module-info/java'
}
}
}
set compatibility to Java 9 for the moduleInfo, sourceSet, configure modules, and set the output directory:
compileModuleInfoJava {
sourceCompatibility = 9
targetCompatibility = 9
inputs.property("moduleName", moduleName)
doFirst {
classpath += sourceSets.main.compileClasspath
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-SYSTEM,org.apache.logging.log4j',
'-d', sourceSets.main.output.classesDirs.asPath
]
}
}
configure the jar task to include moduleInfo:
jar
{
from sourceSets.main.output
from sourceSets.moduleInfo.output
}
In case you are using the SpotBugs plugin, you also have to configure the sourceSet explicitly because it will otherwise fail when it tries to process the ModuleInfo sourceSet.
I finally ended up with this version of build.gradle:
plugins {
id "com.github.spotbugs" version "1.6.0"
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'com.github.spotbugs'
sourceCompatibility = 8
targetCompatibility = 8
group = 'com.dua3.utility'
repositories {
mavenLocal()
jcenter()
}
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.10.0'
testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.10.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
ext.moduleName = 'com.dua3.utility'
sourceSets {
moduleInfo {
java {
srcDir 'src/module-info/java'
}
}
}
compileModuleInfoJava {
sourceCompatibility = 9
targetCompatibility = 9
inputs.property("moduleName", moduleName)
doFirst {
classpath += sourceSets.main.compileClasspath
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-SYSTEM',
'-d', sourceSets.main.output.classesDirs.asPath
]
}
}
jar
{
from sourceSets.main.output
from sourceSets.moduleInfo.output
}
spotbugs {
sourceSets = [sourceSets.main]
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled false
html.enabled true
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
defaultTasks 'build', 'publishToMavenLocal', 'install'
The question is over a year old, but in case anyone stumbles here, this functionality is now supported by Gradle Modules Plugin since version 1.5.0.
With this plugin, you don't have to create a custom source set, and you only need to call modularity.mixedJavaRelease method.
Here's a sample of how to apply the plugin to one's main build.gradle:
plugins {
// your remaining plugins here
id 'org.javamodularity.moduleplugin' version '1.5.0' apply false
}
subprojects {
// your remaining subproject configuration here
apply plugin: 'org.javamodularity.moduleplugin'
modularity.mixedJavaRelease 8 // sets "--release 8" for main code, and "--release 9" for "module-info.java"
// test.moduleOptions.runOnClasspath = true // optional (if you want your tests to still run on classpath)
}
I have developed a Gradle plugin for this: https://github.com/Glavo/module-info-compiler
I have tried Gradle Modules Plugin, but there are still some troublesome problems, so I developed this plugin, a compiler specifically used to compile module-info.java.
It is not implemented by calling javac. It is a complete compiler that can run above Java 8. It recognizes the syntax of module-info.java and generates the corresponding module-info.class file according to it.
It only checks the grammar, and does not actually check those packages, classes or modules, so it can work without configuration of any module path.
This Gradle plugin has processed everything for you. For a Java 8 project containing module-info.java, you only need to do this:
plugins {
id("java")
id("org.glavo.compile-module-info-plugin") version "2.0"
}
tasks.compileJava {
options.release.set(8)
}
This answer copy the answer written by myself under another question (https://stackoverflow.com/a/72074642/7659948).
Related
The error gets thrown for org/apache/commons/compress/archivers/tar/TarArchiveInputStream as seen here.
I have referenced this library in eclipse (as seen here)
The dependency has also been specified in build.gradle. The contents of the gradle file:
plugins {
id 'org.spongepowered.plugin' version '0.9.0'
}
group = pluginGroup
version = pluginVersion
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
dependencies {
compileOnly 'org.spongepowered:spongeapi:7.2.0'
annotationProcessor 'org.spongepowered:spongeapi:7.2.0'
compile 'org.apache.commons:commons-compress:1.21'
}
sponge.plugin.id = pluginId
Eclipse also does not flag any errors. Lines of code such as tarInput.getNextTarEntry() appear in the correct colour with no red underlining, and eclipse even autocompletes the names of methods found in commons-compress.
Given eclipse seems to be working correctly with the dependency, and given that running ./gradlew build leads to a successful build, I am therefore at a loss for why I am getting the java.lang.NoClassDefFoundError error.
#nitind helped. I focused upon runtime and found the problem was to do with my build.gradle file (even though the build was successful!). I changed it to this and the error has vanished:
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'org.spongepowered.plugin' version '0.9.0'
}
apply plugin: 'java'
group = pluginGroup
version = pluginVersion
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
dependencies {
compileOnly 'org.spongepowered:spongeapi:7.2.0'
annotationProcessor 'org.spongepowered:spongeapi:7.2.0'
compile 'org.apache.commons:commons-compress:1.21'
}
jar {
from configurations.compile.collect { zipTree it }
}
sponge.plugin.id = pluginId
I have a script build.gradle, which created the IDEA development environment when creating a JavaFX project with Gradle support:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.4'
id 'org.javamodularity.moduleplugin' version '1.8.10' apply false
}
group 'com.prototype'
version '1.0'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.8.2'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
sourceCompatibility = '17'
targetCompatibility = '17'
}
application {
mainModule = 'com.prototype.simulationcrystalgrowth'
mainClass = 'com.prototype.simulationcrystalgrowth.SimulationApplication'
}
javafx {
version = '17.0.1'
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web']
}
dependencies {
implementation('org.controlsfx:controlsfx:11.1.1')
implementation('com.dlsc.formsfx:formsfx-core:11.4.2') {
exclude(group: 'org.openjfx')
}
implementation('net.synedra:validatorfx:0.2.1') {
exclude(group: 'org.openjfx')
}
implementation('org.kordamp.ikonli:ikonli-javafx:12.2.0')
implementation('org.kordamp.bootstrapfx:bootstrapfx-core:0.4.0')
implementation('eu.hansolo:tilesfx:17.0.11') {
exclude(group: 'org.openjfx')
}
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
After the "build" task is completed, the "distributions" folder appears in the build folder. It contains a zip archive with the following contents:
The bin folder contains two scripts, sh and bat.
The lib folder contains, as I understand it, all the required jar modules.
If JAVA_HOME is installed on Java 17 in my environment, then when executing the bat script, my program starts.
I expected that jlink is a kind of analogue of a more user-friendly assembly and packaging of the application, which will help to create something like an exe application launcher.
I also noticed that there are no tasks related to jlink in build.gradle is not called during the build process using the "build" task.
I tried to run them myself, and I got the same error:
I am confused by the mention of the "distributions/app" path in build.gradle, I expect there should be something else after the build.
What am I doing wrong?
What should I get at the output using jlink ?
The problem is solved.
The exclude of the org.openjfx module was removed from all dependencies.
Useful links:
https://openjfx.io/openjfx-docs/#gradle
https://github.com/openjfx/samples
https://developer.tizen.org/development/articles/openjdk-and-openjfx-installation-guide
Ok, so I'm new to Gradle and Kotlin and I am having a hard time understanding how things glue together here...
I need to configure a project that should run on Java 7 (client limitations -_-) and I want to use Kotlin with it.
Right now I have the following build.gradle file that is working but I want to ask a few things that I couldn't find anywhere else:
buildscript {
ext {
springBootVersion = '1.5.15.RELEASE'
kotlin_version = '1.1.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
group = 'com.springkotlin'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-security')
compile('com.onelogin:java-saml:2.3.0')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
runtime('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
testCompile group: 'javax.inject', name: 'javax.inject', version: '1'
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.6"
}
}
Now the questions:
I have tried using kotlin_version = '1.2.70' (released last few days!) and I got the error KotlinPluginWrapper : Unsupported major.minor version 52.0. I'm guessing then this is due to Kotlin 1.2.X only being able to "compile" (is that the word?) with Java 8+. Is that right? Is 1.1.1 the right version to use here or is there a way to use 1.2.70 that would work with Java 7? Will I be missing a lot of stuff for using it?
I want to understand the 3 kotlin stuff I had to setup on the script. Correct me please:
kotlin-gradle-plugin: Is used to define which version of Kotlin I will be using(?)
apply plugin: 'kotlin': As far as I know from Gradle, this should add tasks to work with Kotlin but running gradle tasks I didn't see anything different... So what is it really for?
kotlin-stdlib-jdk7: I'm guessing this is Kotlin lib of functions, classes, etc. What I don't understand though is the difference between stdlib and stdlib-jdk7. The documentation says it contains "addition extension functions". But which ones? Also, should I define a version for this guy? Or does it automatically picks up the kotlin-gradle-plugin version?
Thanks in advance,
Currently the compiler of the Kotlin language requires JDK 8 to run. A project compiled with Kotlin can target any Java starting from Java 6.
A recipe to setup Gradle build of a project that runs on Java 7 is following:
run Gradle with Java 8 or later
for all Kotlin compile tasks
specify jvmTarget = "1.6" in kotlinOptions
specify path to JDK 7 in jdkHome in kotlinOptions
if your project contains java code specify sourceCompatibility, targetCompatibility convention properties of the Java plugin
specify the following options of all java compile tasks:
isFork = true
forkOptions.javaHome = "<path to JDK 7>"
for all Test tasks specify executable as "<path to JDK 7>/bin/java"
The full sample:
sourceCompatibility = 1.7
targetCompatibility = 1.7
def JDK_7 = System.getenv("JDK_7") // or some other way to get path to JDK 7 installation
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "1.6"
jdkHome = JDK_7
}
}
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.javaHome = file(JDK_7)
}
test {
executable = "$JDK_7/bin/java"
}
Kotlin can target either Java 6 or Java 8 and I don't think this has changed. However, it is quite likely that the default has changed from Java 6 to Java 8, so try as suggested here:
compileKotlin {
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6
kotlinOptions {
jvmTarget = "1.6"
apiVersion = "1.2"
languageVersion = "1.2"
}
}
The version of kotlin-gradle-plugin is the version of the Kotlin compiler used to compile your code. The version of the stdlib is the version of your runtime library. It is highly recommended to use the same version here.
The apply plugin: kotlin adds some tasks under the hood - just continue using the java tasks like gradle assemble, gradle build and gradle run as they will invoke the kotlin specific tasks
kotlin-stdlib-jdk7 adds very little value - unless you use features of the java library that were introduced in java 7 and that have extensions from Kotlin's stdlib, you'll be fine to just use the default stdlib (which targets Java 6 and is a dependency of kotlin-stdlib-jdk7 anyways).
This is my build.gradle file
buildscript {
ext {
springBootVersion = '1.4.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'yBayApplication'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
springBoot {
mainClass = "com.ybayApplication.customerAccount.CustomerServiceApplication"
}
dependencies {
compile('org.springframework.cloud:spring-cloud-starter-eureka-server:1.2.3.RELEASE')
compile('org.springframework.cloud:spring-cloud-starter-zuul')
compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'
compile group: 'com.netflix.governator', name: 'governator-archaius', version: '1.6.0'
compile group: 'io.reactivex', name: 'rxjava-string', version: '0.22.0'
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.h2database:h2")
testCompile("junit:junit")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.BUILD-SNAPSHOT"
}
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
And this is the error message, I am receiving while building the gradle.
Gradle Distribution: Local installation at C:\gradle\gradle-3.4.1
Gradle Version: 3.4.1
Java Home: C:\Program Files (x86)\Java\jdk1.8.0_121
JVM Arguments: None
Program Arguments: None
Gradle Tasks: clean build
:clean UP-TO-DATE
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':detachedConfiguration5'.
> Could not find com.netflix.governator:governator-archaius:1.6.0.
Searched in the following locations:
https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo1.maven.org/maven2/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo.spring.io/snapshot/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.pom
https://repo.spring.io/milestone/com/netflix/governator/governator-archaius/1.6.0/governator-archaius-1.6.0.jar
Required by:
project :
project : > com.netflix.zuul:zuul-core:2.0.0-rc.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.77 secs
As you can see in the build.gradle file, I have added the missing dependency as well. I am tying to implement a Zuul filter based on this example in gradle https://spring.io/guides/gs/routing-and-filtering/.
On the first look, it looks like you need to remove the
compile group: 'com.netflix.zuul', name: 'zuul-core', version: '2.0.0-rc.1'
The compile('org.springframework.cloud:spring-cloud-starter-zuul') is dependent on zuul core so it will download it.
Additionally, for the governator-archaius I don't see the version 1.6.0.
I think you meant 1.16.0. Look at the link here to grab the accurate version https://mvnrepository.com/artifact/com.netflix.governator/governator-archaius
Let me know if this solves your problem.
I am facing one issue with gradle while building scala code.
$gradle makeJar
Error : org.gradle.api.tasks.TaskExecutionException :
Execution failed for task ':compileScala'.
Caused by : java.lang.NoClassDefFoundError: scala/Function1
$gradle -v
Gradle version - 1.6
groovy - 1.8.6
Ant - 1.8.4
ivy - 2.2.0
jvm - 1.7.0_55
OS - Linux 2.6x
My build.gradle file is below -
sourceCompatibility = '1.6'
apply plugin: 'scala'
def mypath = 'file://'+new File('test/lib').absolutePath
repositories {
flatDir dirs:"${mypath}"
}
configurations{
scalaPackage
}
sourceSets{
main{
scala{
srcDirs = ['test/src/scala']
}
}
}
dependencies {
compile fileTree(dir: mypath, includes: ['*.jar'])
}
task sourcePath{
sourceSets.main.scala.srcDirs = sourceSets.main.scala.srcDirs
sourceSets.main.java.srcDirs = []
}
task makeJar(type: Jar, dependsOn: compileScala){
archivename = "mytest.jar"
destinationDir = file("test/oplib")
from "build/classes"
classpath = configurations.scalaPackage
}
compileScala.dependsOn sourcePath
==========================================================
Here, my scala source code is present in - ./test/src/scala/test.scala
scala jar files present in - ./test/lib
expected output location - ./test/oplib
Is there anything wrong with build.gradle file which might be resulting in this error. Kindly suggest.
Many Thanks, Pralay
If you use spark-core_2.11 Version 1.2.0 you can define your dependencies as following:
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.spark:spark-core_2.11:1.2.0'
}
This dependency has Scala
org.scala-lang / scala-library / from 2.11.2 to 2.11.7
as a indirect dependency see
Maven Repository Search for spark-core
i take your build.gradle File and start it with a Gradle Wrapper with Gradle Version 2.3
first just with gradlew
Then i make 3 Corrections:
apply plugin: 'scala'
sourceCompatibility = '1.6'
def mypath = 'file://'+new File('test/lib').absolutePath
repositories {
flatDir dirs:"${mypath}"
}
configurations{
scalaPackage
}
sourceSets{
main{
scala{
srcDirs = ['test/src/scala']
}
}
}
dependencies {
compile fileTree(dir: mypath, includes: ['*.jar'])
}
task sourcePath{
sourceSets.main.scala.srcDirs = sourceSets.main.scala.srcDirs
sourceSets.main.java.srcDirs = []
}
task makeJar(type: Jar, dependsOn: compileScala){
archiveName = "mytest.jar"
destinationDir = file("test/oplib")
from "build/classes"
// classpath = configurations.scalaPackage
}
compileScala.dependsOn sourcePath
Move the Line sourceCompatibility after the Scala Plugin Import
Write archiveName instaed of archivename
Comment out classpath
Then i run gradlew tasks and gradlew makeJar without Error.
Scala projects need to declare a scala-library dependency.
Add this in your build.gralde File:
repositories {
mavenCentral()
}
dependencies {
compile 'org.scala-lang:scala-library:2.11.1'
}