Gradle 1.0m6 changes jar resource behavior


(Phil Swenson) #1

gradle 1.0m6 seems to have changed the behavior on building a jar containing only resources.

in m3 this worked:

sourceSets.main.resources {
    srcDirs = ["../../src/java/core"]
    include "com/web/bpo/ui/portlet/GlobalResources.properties"
}

I get this error on m6, runs fine on m3 12:21:10.473 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.IllegalArgumentException: A Jar can only accept a valid file or directory: /Users/pswenson/dev/sag/optimize/trunk/gradle/bpo-resource/build/classes/main

in m6, it looks for a “classes” directory and errors out.

Is there a work-around?


(Peter Niederwieser) #2

I can’t reproduce this. Can you show the rest of the build script? What task(s) do you run? Which OS?


(Phil Swenson) #3

OS X, “gradle assemble”

the project is very simple. For the subproject in question, there are no “source” files, only resources.

The root project is:

apply plugin: 'idea'
buildscript {
    dependencies {
        classpath(
                'com.myco.bas:bas-plugins-core:latest.milestone',
        )
    }
}
  subprojects {
    apply plugin: 'bas-osgi'
    sourceCompatibility = 5
    targetCompatibility = 5
    build.version.major=8
    build.version.minor=2
    build.version.micro=5
}

the subproject that is the prob is code is

sourceSets.main.resources {
    srcDirs = ["../../../src/java/core"]
    include "com/myco/bpo/ui/portlet/GlobalResources.properties"
}

(Peter Niederwieser) #4

Still can’t reproduce. Can you attach a project that demonstrates the issue?


(xuantinh) #5

I can reproduce this issue locally even with Gradle 1.0 Final Here is the step: -Create folder structure like this: +resource-only

|—build.gradle

|—src

|------main

|---------java

|---------resources

|------------sample-resource.conf (empty file) -Run ‘gradle jar’ Here is the content of the build.gradle

apply plugin: 'java'
apply plugin: 'osgi'

If I remove the plugin osgi, everything works as expected! So there is some wrong with osgi plugin in this case.


(Luke Daley) #6

Raised as GRADLE-2391.