New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resource output directory configuration #1282

Open
madorb opened this Issue Feb 1, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@madorb

madorb commented Feb 1, 2017

Using Spring Loaded, Gradle, Intellij and Findbugs leads to issue because the output resources directory is not supported.

Using Spring Loaded with Gradle in Idea requires that the outputDir be configured (see: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-reload-springloaded-gradle-and-intellij-idea). This appears to control the output directory of not only the class files, but also resources. Thus when running Findbugs, it causes failures because findbugs expects only class or zip files in the output directory.

Expected Behavior

In IdeaModule there is the outputDir and testOutputDir configuration for classfile output, but it appears that intellij is also moving files from src/main/resources to this same output directory.

Ideally we'd be able to configure the output directory for resources to be something like /build/classes/main/resources

Current Behavior

Resources are copied to same folder as class files

Steps to Reproduce (for bugs)

Build a project using Gradle / Findbugs with the outputDir configured to be: outputDir = file("$buildDir/classes/main/")

This is related to issue: https://discuss.gradle.org/t/idea-plugin-resource-folders-support/5692

@bmuschko

This comment has been minimized.

Show comment
Hide comment
@bmuschko

bmuschko Feb 2, 2017

Contributor

I don't think IntelliJ makes a distinction between the output directory for class files and resources files. There's only a way to separate production class files and test class files.

IntelliJ 13 allows for assigning different source directories for Java source files and resource files. However, all of these files end up in the same output directory. Please let me know if you know of IntelliJ documentation that does let you configuring it.

Contributor

bmuschko commented Feb 2, 2017

I don't think IntelliJ makes a distinction between the output directory for class files and resources files. There's only a way to separate production class files and test class files.

IntelliJ 13 allows for assigning different source directories for Java source files and resource files. However, all of these files end up in the same output directory. Please let me know if you know of IntelliJ documentation that does let you configuring it.

@sgrimm-sg

This comment has been minimized.

Show comment
Hide comment
@sgrimm-sg

sgrimm-sg Apr 18, 2017

In IntelliJ's UI, you can configure the output directory for resources in Project Structure > Modules > (module name) > Paths, by picking the "Use module compile output path" radio button and entering the target paths. The trick is that this is the setting on the foo module, not foo_main or foo_test.

This causes the following to be written to .idea/modules/foo/foo.iml (in this example I've put the resources under the target directory):

<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":foo" external.linked.project.path="$MODULE_DIR$/../../../foo" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.group="com.example" external.system.module.version="0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager">
    <output url="file://$MODULE_DIR$/../../../foo/target/resources/main" />
    <output-test url="file://$MODULE_DIR$/../../../foo/target/resources/test" />
...

This is with IntelliJ 2017.1.1.

sgrimm-sg commented Apr 18, 2017

In IntelliJ's UI, you can configure the output directory for resources in Project Structure > Modules > (module name) > Paths, by picking the "Use module compile output path" radio button and entering the target paths. The trick is that this is the setting on the foo module, not foo_main or foo_test.

This causes the following to be written to .idea/modules/foo/foo.iml (in this example I've put the resources under the target directory):

<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":foo" external.linked.project.path="$MODULE_DIR$/../../../foo" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.group="com.example" external.system.module.version="0.1-SNAPSHOT" type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager">
    <output url="file://$MODULE_DIR$/../../../foo/target/resources/main" />
    <output-test url="file://$MODULE_DIR$/../../../foo/target/resources/test" />
...

This is with IntelliJ 2017.1.1.

@oehme

This comment has been minimized.

Show comment
Hide comment
@oehme

oehme Sep 15, 2017

Member

Can you try using idea.module.inheritOutputDirs = true? That will tell IDEA to use separate output dirs so it doesn't conflict with Gradle.

Member

oehme commented Sep 15, 2017

Can you try using idea.module.inheritOutputDirs = true? That will tell IDEA to use separate output dirs so it doesn't conflict with Gradle.

@oehme oehme added a:feature and removed a:question labels Sep 15, 2017

@mbogner

This comment has been minimized.

Show comment
Hide comment
@mbogner

mbogner Nov 12, 2017

@oehme
I'm also trying to create an application with intellij and gradle. Both should use the same output directory under build because the gradle build copies some files built by npm to the static directory. Syncing out and build, which I already tried, was a mess and I would really appreciate not having duplicated structures. So far everything is working, but after a gradle build intellij won't find the resource files. Of course, gradle puts them into a separate folder build/resources/main. So I have to do a Build > Rebuild Project to get everything set up again. Sometimes even that fails. No idea why yet.
I think everything would run smooth if I would be able to tell intellij also to put properties to the same directory as gradle and also look for them when the application is started. The missing things would be something like resourcesOutputDir and testResourcesOutputDir. Couldn't find something like that. But sorry if I overlooked it.

idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/java/main/")
        testOutputDir = file("$buildDir/classes/java/test/")
    }
}

mbogner commented Nov 12, 2017

@oehme
I'm also trying to create an application with intellij and gradle. Both should use the same output directory under build because the gradle build copies some files built by npm to the static directory. Syncing out and build, which I already tried, was a mess and I would really appreciate not having duplicated structures. So far everything is working, but after a gradle build intellij won't find the resource files. Of course, gradle puts them into a separate folder build/resources/main. So I have to do a Build > Rebuild Project to get everything set up again. Sometimes even that fails. No idea why yet.
I think everything would run smooth if I would be able to tell intellij also to put properties to the same directory as gradle and also look for them when the application is started. The missing things would be something like resourcesOutputDir and testResourcesOutputDir. Couldn't find something like that. But sorry if I overlooked it.

idea {
    module {
        inheritOutputDirs = false
        outputDir = file("$buildDir/classes/java/main/")
        testOutputDir = file("$buildDir/classes/java/test/")
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment