Resource files missing from compiler output

Having a problem with resource patterns I think. This project seems to have the default resource pattern:
!?*.java;!?*.form;!?*.class;!?*.groovy;!?*.scala;!?*.flex;!?*.kt;!?*.clj

But when I compile the output folders are missing resources like *.properties; *.xml; *.xsl; *.png; *.gif ... All I can see in the out/ folder is folders, class files and one solitary .ftl file. None of the latter patterns I need included appear to be excluded from via the default resource pattern. These files exist alongside the .java files in the source packages. I'm stumped as to why this isn't working. I'm reading the resource patterns as all exentions not matching these, but they don't seem to work as expected?

This is IDEA 13 on Linux (CentOS6). Any ideas?

13 comments
Comment actions Permalink

This is maddening been trying to get IDEA to compile this project for last hour without sucess. I tried changing the resource patterns to include the resources I need:
?*.properties;?*.xml;?*.xsl;?*.xsd;?*.dtd;?*.tld;?*.ftl

But no joy, no change whatsoever. After building I still only get .class and .ftl?

Tried wiping the output folders, moving the output folders, closing idea, wiping the caches & reindexing everything. But still no resources in the output??

This is a maven project importe from a pom.xml file. But it's not being built by maven, we only use it for depenency management - could that cause an issue here? Seems like a reach as the resources missing are inside this modules src folders. Any IDEA 13 EAP bugs in this area? 133.124 I think I've got (RC2).



Attachment(s):
Capture.PNG
0
Comment actions Permalink

Hmm this does seem to be something todo with the maven nature of the project.

In despreation I went back to IDEA 12, tried compiling there and at first the same problem was present. None of my key resources are present. One thing that's been odd is every time I reopen this project the output folders get reset. They keep pointing to individual paths for both production & test output folders but every time I open the project I have to set inherit from project again. Doesn't matter which set of output folders I looked in though, the resources where never present.

What I notice in IDEA 12 is the compiler tab has an extra checkbox "use external build". When I turn this off and rebuild. My resources suddenly appear in the output.

But this option is missing in IDEA 13? how do I turn off the external maven compiler build nature in IDEA 13?

0
Comment actions Permalink

See attached for an example this is just the basic mvn archetype:generate project. I imported the pom as a project in IDEA, accepted all defaults.

Once project is open rebuild all in IDEA. The src folder has a few resources.

i.e. $ find src/main/java -name "*.xml"
src/main/java/com/mycompany/app/question.xml

The compiler, resource pattern defaults to: !?*.java;!?*.form;!?*.class;!?*.groovy;!?*.scala;!?*.flex;!?*.kt;!?*.clj so any non .java  files should be copied to output folders right?
But after full rebuild: $ find target -name "*.xml" returns nothing $ find target -name "*" only shows classes in the output ?
PS Suspect opening project in IDEA12, turning off "use external build" in compiler settings would produce the desired result.



Attachment(s):
test-app.zip
0
Comment actions Permalink

Hello.

Probably this comment gives the explanation: http://youtrack.jetbrains.com/issue/IDEA-97454#comment=27-419708

I have added resource definition to your project and it has helped:

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
    </build>

There are a lot of issues in the tracker related to external build, Maven and resources. I will re-ask our developer, is there any status update on this.

Regards,
Alexander.

0
Comment actions Permalink

Thanks I'll try something like that myself tomorrow, the real project is a bit more complicated and I didn't add the maven bits myself.

So in a nutshell the resource patterns in the compiler settings don't have any effect if the project was imported from a pom? (even though importing a pom seems to create a .iml and .idea/ project folder?)

Because I've tried turning off the maven setting: 'do not use output directories' and also tried redirecting modules output folders to alternative folders outside of the maven configuration (outside /target) and those showed the same effect (only classes and .ftl copied). In this project we're only using maven to manage dependencies not using mvn compile, clean or test, we only call a mvn resolve target from Ant (which replaces older Ivy targets that did the same kind of thing).

Didn't think any maven targets are called during an IDEA make/rebuild. I also turned off compiler; 'rebuild module on dependency change' as this was one of the only 'external build' options IDEA13 seemed to expose. It also didn't help.

0
Comment actions Permalink

> So in a nutshell the resource patterns in the compiler settings don't have any effect if the project was imported from a pom? (even though importing a pom seems to create a .iml and .idea/ project folder?)

Yes, because the generated project is still tied with poms and synchronized with them. Pom files are treated as primary model in this case.
Another point is that all possible maven resource descriptions cannot be modelled with IDEA's resource descriptions, so for modules that are pom-originated, Maven plugin registeres a special resource builder that replicates Maven's behaviour. This way the resulting content of output directories is the same as if the project were built with Maven.

> Didn't think any maven targets are called during an IDEA make/rebuild.

they are not. IDEA's build is incremental, and this requires different approach than simply building everything from scratch. At the same time we are trying to provide the same output and files layout as if the project were built with Maven.

> I also turned off compiler; 'rebuild module on dependency change'

This option controls whether the module should be fully rebuilt if you change the order of its classpath, SDK, libraries etc. While this theoretically should be done always, in some cases, when you know the library change won't affect the code,  this functionality can be turned off in order to avoid massive rebuilds if you change classpath frequently.

> as this was one of the only 'external build' options IDEA13 seemed to expose

not at all. Other options (e.g. javac-specific, resources) are also effective.

0
Comment actions Permalink

I've added <resources> and <testresources> excludes to our pom.xml and that seems to work a lot better thanks. Guess because we're not using maven for builds our use case is a little unusual.

Might be an idea to add the notes above to the help and/or disable the compiler resources for maven based projects to avoid confusion.

One thing that is still annoying is the module output folders. After importing the pom I set the project output path to \bin and the module outputs to inherit the project path. But every time I reopened the project it seems to revert the change from project back to individual modules paths that point to maven defaults of: target\classes and target\test-classes instead?

so based on behaviour above I've tried adding:

 <outputDirectory>build/classes</outputDirectory>

 <testOutputDirectory>build/classes</testOutputDirectory>

To the build section of the pom, but on closing and reopening the project the maven output paths have not been used by the module output settings? Maven uses these paths if I call it from the command line, but IDEA keeps on trying to use default output folders under /target (deliberatly used different path for all three so I can tell who the winners were). Would I have to delete & re-import the project to pickup this kind of change? or are IDEA maven projects currently not picking up these maven build configurations to override the module output folders?

0
Comment actions Permalink

Can't reproduce the issue with output paths. I've inserted the outputDirectory and testOutputDirectory settings. Then reimport the Maven project. Then checked Project Structure / Modules / the module / Paths. Both settings are there. On closing or reopening the projecy this does not break. What step does fail for you?

Regards,
Alexander.

0
Comment actions Permalink

Opening & closing was related to the project output path. If you set the project output and then module output paths to inherit the project output. then closing & reopening the project resets the configuration back to module paths. Which can be confusing when you're more used to IDEA project defintions.

Was thinking it wasn't syncing, but after reading your reply and going back to try it out I'd forgotten I turned off "use maven output path" configuration while trying to find a workaround yesterday. But it turns out thats a project setting and the test-app doesn't have this turned off. Changing the paths in test-app pom doesn't change the IDEA module outputs.

So I'd guess as you didn't see the issue, module output paths are only preset to the maven outputs during project creation? changing the paths in the pom doesn't sync with module outputs?

0
Comment actions Permalink

Just for case you don't know it. This is not the reply, just information: when I say "reimport" I don't mean killing IDEA project with .idea/ and .iml files. Reimport is an action on maven module node in Maven Projects tool window. It updates .iml file if necessary.

Back to the topic. I'm a bit confused of talking about project output path: why do we need it at all? My understanding is that we have pom.xml with:
<outputDirectory>build/classes</outputDirectory> (etc)

And want to have Project Structure / Modules / the module / Paths:
. Use module compile output = Yes.
. Output path = .../build/classes

This is done for me on import and reimport actions, with Use Maven output directories = Yes. Project (not module) settings are not involved.

Was it the goal? Could you specify precisely, what is wrong: different input, different goal, different behavior on your side?

Thank you,
Alexander.

Message was edited by: Alexander Chernikov

0
Comment actions Permalink

Ok, did not know that about reimport. I've just been closing & reopeneing IDEA expecting to see changes :S

What I've been trying to do in a nutshell is keep on using IDEA. I'm the sole IDEA user in a large team of eclipse-only devs. They've been migrating a project from Ant&Ivy to Maven, but the partial maven build they've produced is full of m2e plugin magic I've been struggling to replicate in IDEA.

They set the maven output paths to WEB-INF/classes for both runtime and test resources. They use some sysdeo-tomcat plugin in eclipse not WTP. But this isn't any good for me, I want to build a web artifact in IDEA. So my first attempt on seeing the module path was wrong was to reset them  to /out as used by the project, which wouldn't overlap with eclipse or maven settings. Rinse & repeat. Trying to find a middle ground. I've currently got eclipse project files, an older IDEA ivyidea project and the new pom based project kicking around in the same codebase, trying to keep up.

So would IDEA reimport the pom if it was changed via VCS? or will I need to manually do this if builds break?

0
Comment actions Permalink

Ok, understood.

Simple answer on automatic reimporting: there is Settings / Maven / Importing / "Import Maven projects automatically" preference. With in On IDEA should listen to the changes in pom.xml (if it is imported as a module == shown in Maven Projects tool window), and update IDE's settings accordingly. Please try.

In general, IDEA's Maven integration intention is to import all module settings one way: pom.xml -> IDEA's .iml. I.e. the basic way to work is to make all changes in pom.xml and reimport: then IDEA should update .iml and act accordingly.

Direct editing of settings in Project Structure dialog has sense only if they do not conflict with pom settings. Otherwise they will be overridden on next reimport.

For more subtle cases there are some fine tuning options in Settings / Maven / Importing, like "Keep source and test folders on reimport" or already referenced "Use Maven output directories", that can "mute" some pom settings.

Well, maybe that helps. Don't hesitate to ask more questions.

Regards,
Alexander.

0
Comment actions Permalink

I think me & IDEA will be able to solider on, got a path to make enough work now much thanks - suspect IDEA will work better the more complete the mavenisation process gets. The imported eclipse projects where a bit of a pain in practise, if you used syncing settings in both directions at any rate.

0

Please sign in to leave a comment.