Gradle with Intellij "Out" folder

I have a problem using gradle in intellij, maybe one of you have come across a solution and can help me. Intellij generates an “out” folder in a project when building. This gets generated in my assets folder, and the out folder contains compiled code, so all the assets are copied into it. And so when gradle builds the assets jar, it contains all the assets twice. I don’t know what I’m doing wrong. Here is the gradle.build:

group 'de.gamedevbaden'
version '0.1'

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'

repositories {
    jcenter()
    maven { url 'http://nifty-gui.sourceforge.net/nifty-maven-repo'}
}

mainClassName = 'de.gamedevbaden.crucified.tests.SimpleClientServerTest.ClientTest'
ext.jmeVersion = "[3.1,)"

project(":assets") {
    apply plugin: "java"

    buildDir = rootProject.file("build/assets")

    sourceSets {
        main {
            resources {
                srcDir '.'
            }
        }
    }
}

sourceSets {
    main {
        java {
            srcDirs = ['src']
        }
    }
}

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')

    //compile group: 'ch.qos.logback', name: 'logback-classic', version: jmeVersion.logback
    compile group: 'org.jmonkeyengine', name: 'jme3-core',       version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-effects',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-networking', version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-plugins',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-jogg',       version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-terrain',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-blender',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-bullet',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-bullet-native',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-niftygui',   version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-desktop',    version: jmeVersion
    compile group: 'org.jmonkeyengine', name: 'jme3-lwjgl',      version: jmeVersion

    //You need to uncomment nifty repository in the repositories section if you use this dependency
    compile "org.jmonkeyengine:jme3-niftygui:$jmeVersion"

    runtime project(':assets')
}

task runServer(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath + files('assets','.')
    main = 'de.gamedevbaden.crucified.tests.SimpleClientServerTest.ServerTest'
    standardInput = System.in
}

task runClient(type: JavaExec) {
    classpath sourceSets.main.runtimeClasspath + files('assets','.')
    main = 'de.gamedevbaden.crucified.tests.SimpleClientServerTest.ClientTest'
    standardInput = System.in
}

task wrapper(type: Wrapper) {
}

Hopefully this explains it.

Thanks

As a hack, you could add the “out” folder to the ignores for the assets project.

Not sure what is creating that out folder but I don’t think it’s gradle. So maybe there is a setting in Intelli-J somewhere.

Yes, it is intellij creating that folder. I think my problem was I would use the intellij build button “ctrl+F9” and I believe that does not use gradle build, even though the project is imported as a gradle. Every time I build using that, it creates an out folder in the assets folder, and an out folder in that assets folder, recursively… ended up with my assets.jar (when I used gradle build) being over 2gb and taking a few minutes to build… its always an issue with something between the monitor and the seat cushion. I will use the gradle build from now on and exclude the out folder from the build.

You got some explaining to do.
What do you actually want to do? Why do you manipulate like all sources with non convention paths?
Why do you do project specific configuration (“assets”) not in a build file in the assets project, as that would be the expected convention to do it.
why do you use some folder under build at all in the assets project?

Basically you would need two projects (and a pretty empty rootproject)
->one contains only the ressources and would create a jar with them, please read up on the conventions, using a simple apply plugin: ‘java’ should be enough to do this.
→ The second project references the first one via a dependency, and does a pretty normal java build as well.
That you are using idea should then be irrelevant, as no longer any path overlap with idea paths.

However since you kinda actually do not want two jars seperate as I understand it, but one jar with everything.
a simple java project with the assets at the right location should already do this.

https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_project_layout

ps. I’m sorry if this comes of a bit harsh :slight_smile:

How he has his project laid out looks like how we recommend in our examples. It’s a way of having an assets folder just like the SDK expects with no extra project file… which gradle is 10000% totally fine with.

It’s nice because it gives you a separate assets.jar just like the SDK would produce.

1 Like

Thanks for the info. We’re trying to maintain compatibility with the SDK if we can, so someone could download the project and be able to build it in the sdk, minus our special gradle tasks. We do want two separate jars - one for assets and one for code. With gradle being so extensible, further down the road if the project becomes bigger we could break out the assets folder into more jars, so they can be updated individually. If the game is updated through for example, steam, the user would not have a large download every time.

1 Like