fny
fny

Reputation: 33537

Gradle Builds an Empty Jar File

I converted a project to gradle using gradle init from maven after updating the dependencies. gradle test works as expected. However, when I run gradle build, the jar file that's generated is entirely empty.

I've attempted to tweak the source set to make something happen, but that doesn't seem to solve the problem. The directory structure matches what gradle expects from what I can tell everything is nested in src/main/groovy

The project's full code is available on Github.

In general what causes no files to be added to a build? Is there additional configuration I need to add besides whatever gradle init creates?

Gradle build file:

plugins {
    id 'java'
    id 'maven-publish'
}

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
}

dependencies {
    implementation 'org.codehaus.groovy:groovy-all:3.0.5'
    implementation 'com.github.javafaker:javafaker:1.0.2'

    testImplementation 'org.spockframework:spock-core:2.0-M3-groovy-3.0'
    testCompileOnly 'org.projectlombok:lombok:1.18.12'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
}

group = 'nl.topicus.overheid'
version = '0.2.0'
description = 'java-factory-bot'
sourceCompatibility = '1.8'

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

Upvotes: 1

Views: 2003

Answers (1)

Chayne P. S.
Chayne P. S.

Reputation: 1638

What going on now is the project is try to build as Java project and get src from src/main/java as it is default from Java project. So, you need id 'groovy' not id 'java' in plugins section to make it look into src/main/groovy and build both .java and .groovy files in there.

Upvotes: 1

Related Questions