How do I tell IDEA about my css and js file mappings?

1076 views
Skip to first unread message

Dave Merrill

unread,
Jun 23, 2012, 10:40:55 AM6/23/12
to cfml-plugin-fo...@googlegroups.com
The web root of my project is a directory below the project root. IDEA highlights all the css and js file links in both cfml and html files as unresolved, when they're all relative to that web root. How can I fix that? 

I have a ColdFusion mapping defined in IDEA, and it understands cfinclude paths relative to it. (But not cfmodule paths; see here.)

How do I accomplish the same thing for the javascript and css files in my project, ideally in a way that works in both cfml and html files?

Thanks in advance,
Dave Merrill

Mark Mandel

unread,
Jun 25, 2012, 2:37:35 AM6/25/12
to cfml-plugin-fo...@googlegroups.com
Can you set up a web module?

Mark

Jamie Krug

unread,
Jun 25, 2012, 7:28:25 AM6/25/12
to cfml-plugin-fo...@googlegroups.com
Right, I generally create a Web facet beneath my main (Java/CFML) module, and specify one or more Web Resource Directories. I usually just have one, for /, because my project root is not my Web root (I usually have a "web" folder under the project/module root). But you can also specify a resource for non-Web root locations (e.g., to account for an Apache Alias situation, and still get all the IDEA goodness from that resource).

Best,
Jamie

Dave Merrill

unread,
Jun 25, 2012, 11:16:02 AM6/25/12
to cfml-plugin-fo...@googlegroups.com
Hmmm, I've never done this. It doesn't appear that I can expand the one module this project contains in the Project Settings dlg, it has no children.  Do I need to enable Java EE Integration or some other plugin to be able to add that facet? 

Thanks,
Dave

Jamie Krug

unread,
Jun 25, 2012, 11:55:49 AM6/25/12
to cfml-plugin-fo...@googlegroups.com
I just add a Web facet to my Java module. Every IDEA project requires at least one module, and generally, a Java module is the only one (and the one we use for CFML). So, add a Web facet under a Java module and you should see what I'm talking about. If not, let me know and I'll whip up a quick screencast or something...

Dave Merrill

unread,
Jun 25, 2012, 12:30:46 PM6/25/12
to cfml-plugin-fo...@googlegroups.com
I do have a module at the root of this project, of course, and I expect it's a Java module (what else could it be and work for CFML?). However, I don't see any way to see what it is for sure, or how to add a facet to it.

Right-click menu > New shows only Module. Is that where Facet should be? Do you have  Java EE Integration enabled? There is a substantial amount of Java in this project, but all the directly web-related stuff is CFML (and js), and I don't need or want IDEA to create the various artifacts it says that comes with, so I've never enable it.

Thanks for your help, sorry to be thick,

Dave

Dave Merrill

unread,
Jun 26, 2012, 9:20:22 AM6/26/12
to cfml-plugin-fo...@googlegroups.com
Hi, don't mean to be a pain, but still not getting this.

Is there a way to explain a little more without you having to do a whole screencast thing?

Thanks,
Dave

Jamie Krug

unread,
Jun 26, 2012, 10:43:31 AM6/26/12
to cfml-plugin-fo...@googlegroups.com
  1. Ctrl+Alt+Shift+S to open Project Structure
  2. Click "Modules" under "Project Settings"
  3. Right-click your Java module (2nd column) and choose New > Web
  4. Under "Web Resource Directories" specify your Web root (and any other Web-accessible directory paths; e.g., Apache Alias directories)
HTH!

Dave Merrill

unread,
Jun 26, 2012, 12:44:59 PM6/26/12
to cfml-plugin-fo...@googlegroups.com
Thanks Jamie, but as I said, under that New submenu I see only Module. Do I need some plugin or some other project setting to make Web available as an option?

Dave Merrill

Jamie Krug

unread,
Jun 26, 2012, 2:19:01 PM6/26/12
to cfml-plugin-fo...@googlegroups.com
Okay, I see. Looks like I do have the Java EE plugin activated. I'm not sure if that's what provides the Web facet, but seems likely. I haven't enabled/disabled plugins in a couple years--just keep enjoying upgrades with the same config directory, so I have no recollection of what I enabled beyond defaults ;-)

Best,
Jamie

Dave Merrill

unread,
Jun 26, 2012, 2:40:27 PM6/26/12
to cfml-plugin-fo...@googlegroups.com
Thanks, my plugin config's been the same for quite a while too. I'll keep poking around.

Also, the web facet docs say it does some things I don't want:
  • Creates the structure of the module with the web and WEB-INF nodes
  • Creates a Web application deployment descriptor web.xml under the WEB-INF node.
  • Creates an index.jsp file that will be the home page of your application and stores it below the web node.
  • Configures a basic artifact of the type exploded with the following structure...
It looks like some of these can be suppressed (really, generated from annotations instead of explicitly created) by choosing a later version.

Do you have those artifacts in your CFML projects? Do you manually delete them?

Thanks again,
Dave Merrill

Jamie Krug

unread,
Jun 26, 2012, 10:52:52 PM6/26/12
to cfml-plugin-fo...@googlegroups.com
You have me curious now... It looks like creating a Web module would be just as effective, without the extra JEE stuff (though I'll address your points below too). I just created a new test project with only a Web module, instead of Java, and this works fine for CFML. And if you do have a mixed Java/CFML project, then you can create a Java module as well as a Web module to represent your Web root. In a Web module you can add additional content roots, similar to the idea of Web resource directories when you have a Web facet under a Java module.

This makes me think that my usage of Web facet is a workaround, in a way, yet it suits me just fine and does not leave any artifacts or anything laying around at all. So, on to your points below...

On Tue, Jun 26, 2012 at 2:40 PM, Dave Merrill <enig...@gmail.com> wrote:
Also, the web facet docs say it does some things I don't want:
  • Creates the structure of the module with the web and WEB-INF nodes
I generally have a CFML engine's WAR exploded in my Web root anyway, so the WEB-INF folder is already there (along with a web.xml file within). When I create a new Web facet and point it to my project's Web root (usually just a "web" or "www" folder beneath the project root, containing the CFML WAR's WEB-INF), IDEA does not create any additional files or folders. If you don't have a WEB-INF, I believe it will just create that folder and a very bare bones web.xml descriptor. So, tiny artifacts if you don't need them, but negligible and easy to .gitignore them (I already just ignore all WEB-INF/ in my global .gitignore).
  • Creates a Web application deployment descriptor web.xml under the WEB-INF node.
Covered above--I already have one, and it's easy to ignore a generated skeleton file. 
  • Creates an index.jsp file that will be the home page of your application and stores it below the web node.
No, I've never had an index.jsp generated when I create a Web facet. 
  • Configures a basic artifact of the type exploded with the following structure...
No, this is not necessary. I think there's a warning about having not configured an artifact for my Web facet as part of a build, but fine to ignore the warning. I've never had anything else generated or configured that I've noticed in any way. 

Hope that helps!

Best,
Jamie

Dave Merrill

unread,
Jun 27, 2012, 7:52:49 AM6/27/12
to cfml-plugin-fo...@googlegroups.com
Jamie, thanks very much for your detailed response and your investigations.

The major project I work on at work has only a single module, at the root of it. It's Java presumably, though a I said, I'm not sure how to tell for sure. I thought that was necessary because there are files I need to work with that are at the root, and I don't believe you can nest modules inside each other. Some dirs below that there there's a java source tree, which if I understand things correctly, means that that top-level module has to be Java anyway, so I can work with those files as java. Some other levels below that is the (roughly) shipping source tree, which includes both cfm/cfc files, and a large tree of pure html/js/css, which is where the lack of "mappings" is most annoying. 

The main point of all that is that my java, CFML, pure html/js, and other random artifact dirs aren't parallel to each other, they're at different places under the project root, which also has files I need to work with. Is it possible to have modules nested inside each other, if the higher-level ones explicitly exclude the trees included by child modules?

Also, according to to a msg near the end of this thread, a Web module "Creates an empty module that enables developing web applications using HTML/HTML5, PHP, JavaScript, and style sheets." Doesn't mention CFML, but the posters on that thread are thinking about JSF etc, not CFML. I gather you tried working with CFML in your web facet and got the usual support from IDEA?

All of which leaves me not knowing what to do here, I've been cruising along, and just plain out and out loving IDEA the way I'm set up. However, the more attention I pay to its warnings, and appreciate completion assists, the more the lack of mappings for html/js/css resources is unfortunate (and also the inability to map CFML namespaces to particular files or dirs).

I wish someone from JetBrains would jump in here with some definitive guidelines. (Not that you're not being super helpful Jamie...)

Dave

On Tue, Jun 26, 2012 at 10:52 PM, Jamie Krug wrote:
You have me curious now... It looks like creating a Web module would be just as effective, without the extra JEE stuff (though I'll address your points below too). I just created a new test project with only a Web module, instead of Java, and this works fine for CFML. And if you do have a mixed Java/CFML project, then you can create a Java module as well as a Web module to represent your Web root. In a Web module you can add additional content roots, similar to the idea of Web resource directories when you have a Web facet under a Java module.

This makes me think that my usage of Web facet is a workaround, in a way, yet it suits me just fine and does not leave any artifacts or anything laying around at all. So, on to your points below...

Jamie Krug

unread,
Jun 27, 2012, 10:11:40 PM6/27/12
to cfml-plugin-fo...@googlegroups.com
On Wed, Jun 27, 2012 at 7:52 AM, Dave Merrill <enig...@gmail.com> wrote:
Some other levels below that is the (roughly) shipping source tree, which includes both cfm/cfc files, and a large tree of pure html/js/css, which is where the lack of "mappings" is most annoying. 

Can you share a rough outline of your actual directory structure beneath your project root (i.e., you only module's root/location)? It might help to just be explicit with an example here.
 
The main point of all that is that my java, CFML, pure html/js, and other random artifact dirs aren't parallel to each other, they're at different places under the project root, which also has files I need to work with. Is it possible to have modules nested inside each other, if the higher-level ones explicitly exclude the trees included by child modules?

Not sure I understand the question here. Maybe examples will help. As for nested modules, I know I can create a Web module within my Java module, but you can't create multiple Web modules within the same tree. It's quick and cheap to create new IDEA projects, temporarily, and experiment, so hack away :)

Also, according to to a msg near the end of this thread, a Web module "Creates an empty module that enables developing web applications using HTML/HTML5, PHP, JavaScript, and style sheets." Doesn't mention CFML, but the posters on that thread are thinking about JSF etc, not CFML. I gather you tried working with CFML in your web facet and got the usual support from IDEA?

I assume you mean Web module and not Web facet above, but yes, in either case, usual CFML support is there in a Web module only project, a Java project, a Java project with a Web facet and a Java project with a Web module. I have a feeling that IDEA gives you the CFML support if you're working with a .cfm or .cfc file, plain and simple.
 
All of which leaves me not knowing what to do here, I've been cruising along, and just plain out and out loving IDEA the way I'm set up. However, the more attention I pay to its warnings, and appreciate completion assists, the more the lack of mappings for html/js/css resources is unfortunate (and also the inability to map CFML namespaces to particular files or dirs).

I've provided two options to experiment with, and Web facet works great for me ;-)
 
I wish someone from JetBrains would jump in here with some definitive guidelines. (Not that you're not being super helpful Jamie...)

I hear ya -- it's nice to have confirmation, but what I'm doing is working great. If there's a better way or a "best practice" path, I too would love to hear from a JetBrains guru. In the mean time, make backups and don't be afraid to experiment.

Cheers,
Jamie

Dave Merrill

unread,
Jun 28, 2012, 7:27:46 AM6/28/12
to cfml-plugin-fo...@googlegroups.com
On Wed, Jun 27, 2012 at 10:11 PM, Jamie Krug wrote:

Can you share a rough outline of your actual directory structure beneath your project root (i.e., you only module's root/location)? It might help to just be explicit with an example here.

Trying to be generic enough to be understandable, and leaving out a bunch of similar stuff, the project looks roughly like this:
  • project root
    • some xml and .bat files
    • build
      • java source tree
    • lib
      • java source tree
    • src
      • java source tree
    • web root
      • cfml source tree
      • non-cfml root
        • html/js/css source tree
The project has been ongoing for many years, and any significant reorganization to make IDEA (or even me) happier is pretty much off the table.
 
Not sure I understand the question here. Maybe examples will help. As for nested modules, I know I can create a Web module within my Java module, but you can't create multiple Web modules within the same tree. It's quick and cheap to create new IDEA projects, temporarily, and experiment, so hack away :)

 Hmmm, really do wonder what the rules are about nested modules, and why. As for experimenting, yes, I should do more of that. What I was doing here was trying to understand The Way(s) It Should Be Done, rather than just come up with something that works. That's by no means a criticism of your suggestion to try stuff, more that I bet JetBrains had some vision(s) of how people would work with this stuff, and understanding that, and what other folks are doing, seemed like a good idea.

Thanks again for talking this stuff out,

Dave Merrill

Jamie Krug

unread,
Jun 28, 2012, 10:27:45 AM6/28/12
to cfml-plugin-fo...@googlegroups.com
I'm not sure I understand this part of your directory structure:
  • web root
    • cfml source tree
    • non-cfml root
      • html/js/css source tree
Is what you label "web root" an actual Web root, as in the DocumentRoot for your Apache virtual host (or similar on IIS/other)? Or, do you not have a directory in your project structure that truly represents a Web root as is, and you instead require a build process to produce artifacts that result in an actual Web root?

If your "web root" is truly a Web root, then you should be able to simply create a Web module and point to that directory as its content root. The same idea would work with a Web facet.

If a build process is required, then I'd need more detail to make a suggestion. It would help if you gave a more concrete example.

Where might your site root's index.cfm reside?

What would the path reference be to something in your "non-cfml root?"

Is your "cfml source tree" Web accessible, or do you just use CF mappings to reference stuff there?

Best,
Jamie

Dave Merrill

unread,
Jun 28, 2012, 1:14:26 PM6/28/12
to cfml-plugin-fo...@googlegroups.com
That web root directory in my diagram is the genuine Apache web root. In HTML files it's referenced as /MyApp/, so /MyApp/css/somefile.css is actually {web root}/css/somefile.css (which I didn't show in my diagram, just to be clear). 

I was able to right click my existing root module and add a Web module with that as its content root, but it made no difference to IDEA's inability to resolve  /MyApp/ references in HTML files. I first named the module 'MyApp web root', then changed it to just 'MyApp', no change.

There is a build process that creates various generated artifacts, but it's not relevant here.

Sorry I'm being thick, and thanks once again for your patience.

Dave Merrill

Dave Merrill

unread,
Jul 1, 2012, 5:33:03 PM7/1/12
to cfml-plugin-fo...@googlegroups.com
Thanks Irina, that worked perfectly. I didn't have the Java EE Integration plugin enabled, and as I suspected but hadn't confirmed, that was why I couldn't create a Web facet, with or without a Web module.

I removed the Web module I had added recently while exporing this, since it didn't seem to be needed, and added a Web facet to the existing Java module that's at my project root. IDEA doesn't flag all the js and css file references in my html files as unresolved, and completion works there too.

So what exactly would a Web module get me that I don't already have?

Thanks again, and also to Jamie , for working through this stuff. I've been using IDEA for a could of years now, love it, just haven't sat down to figure out these bits I've never used, and everyone's help here has been great.

Dave Merrill

On Fri, Jun 29, 2012 at 7:44 AM, Irina Petrovskaya wrote:
Hi Dave,

    you don't really need to create the WebModule, but the Web facet can really help.
You should open the Project Structure dialog, select Modules in the left pane tree, select your module and invoke New/Web in its context menu.
If this facet is not available for you, you need to enable the JavaEEIntegration plugin)
Thus the web facet will be created in your module. Select its node to edit the facet settings.
Remove the entry in the DeploymentDescriptors part - it is not necessary;
Select the auto-created entry in the WebResourceDirectories list and edit it:
the "WebResourceDirectory" should point to the actual file system directory that is your web root: <project_path>/<web root>. 
The "PathRelativeToDeploymentRoot" should be the /MyApp (in your case).

Probably i've missed something, but this works for me. 


On Thursday, June 28, 2012 9:14:26 PM UTC+4, Dave Merrill wrote:
That web root directory in my diagram is the genuine Apache web root. In HTML files it's referenced as /MyApp/, so /MyApp/css/somefile.css is actually {web root}/css/somefile.css (which I didn't show in my diagram, just to be clear). 

I was able to right click my existing root module and add a Web module with that as its content root, but it made no difference to IDEA's inability to resolve  /MyApp/ references in HTML files. I first named the module 'MyApp web root', then changed it to just 'MyApp', no change.

There is a build process that creates various generated artifacts, but it's not relevant here.

Sorry I'm being thick, and thanks once again for your patience.

Dave Merrill
On Thu, Jun 28, 2012 at 10:27 AM, Jamie Krug wrote:
I'm not sure I understand this part of your directory structure:
  • web root
    • cfml source tree
    • non-cfml root
      • html/js/css source tree
Is what you label "web root" an actual Web root, as in the DocumentRoot for your Apache virtual host (or similar on IIS/other)? Or, do you not have a directory in your project structure that truly represents a Web root as is, and you instead require a build process to produce artifacts that result in an actual Web root?

If your "web root" is truly a Web root, then you should be able to simply create a Web module and point to that directory as its content root. The same idea would work with a Web facet.

If a build process is required, then I'd need more detail to make a suggestion. It would help if you gave a more concrete example.

Where might your site root's index.cfm reside?

What would the path reference be to something in your "non-cfml root?"

Is your "cfml source tree" Web accessible, or do you just use CF mappings to reference stuff there?

Best,
Jamie

Jamie Krug

unread,
Jul 1, 2012, 10:17:15 PM7/1/12
to cfml-plugin-fo...@googlegroups.com
Cool, sounds like you're setup as I am, and the Java EE integration was the missing piece to add the Web facet.

I'm pretty sure the Web module is just what it says. It's a module for Web stuff--namely, HTML/CSS/JavaScript. I doubt it offers anything additional beyond what you get from a Web facet in a Java/CFML project.

Best,
Jamie

Kirill Safonov

unread,
Jul 2, 2012, 1:44:50 PM7/2/12
to cfml-plugin-fo...@googlegroups.com

Hi,

 

Web module is primarily expected to be used for JavaScript or PHP development (technically, it is a module type that WebStorm and PhpStorm use). For example, you may see some JavaScript-specific actions, icons or behavior for the files in this module. Also, Project Structure dialog shows more simple UI (similar to WebStorm/PhpStorm) which we consider to be more convenient for JavaScript and PHP projects.

 

Kirill

Dave Merrill

unread,
Mar 28, 2013, 10:16:47 AM3/28/13
to cfml-plugin-fo...@googlegroups.com
Sorry to bring this up again, but I have at least one project where I don't seem to be able to add a Web module, while in others I can, and/or already have.

In at least that one project, right clicking on a module and hovering over the Add item shows only New Module and Import Module, and the facets panel shows "Nothing here"  when you click Add. 

At least one other project also shows a divider, then EJB, JPA, JavaEE Application, and Web, the Facets panel also lets me add those same items, and that project already has a Web module.

JavaEEIntegration is enabled. I'm using IU-129.111.

What am I missing here? What is it about a project that doesn't allow that functionality?

Thanks,
Dave Merrill


On Friday, June 29, 2012 7:44:35 AM UTC-4, Irina Petrovskaya wrote:
Hi Dave,

    you don't really need to create the WebModule, but the Web facet can really help.
You should open the Project Structure dialog, select Modules in the left pane tree, select your module and invoke New/Web in its context menu.
If this facet is not available for you, you need to enable the JavaEEIntegration plugin)
Thus the web facet will be created in your module. Select its node to edit the facet settings.
Remove the entry in the DeploymentDescriptors part - it is not necessary;
Select the auto-created entry in the WebResourceDirectories list and edit it:
the "WebResourceDirectory" should point to the actual file system directory that is your web root: <project_path>/<web root>. 
The "PathRelativeToDeploymentRoot" should be the /MyApp (in your case).

Probably i've missed something, but this works for me. 

On Thursday, June 28, 2012 9:14:26 PM UTC+4, Dave Merrill wrote:

Dave Merrill

unread,
Mar 28, 2013, 1:06:13 PM3/28/13
to cfml-plugin-fo...@googlegroups.com
Posted to the forums also: http://devnet.jetbrains.com/thread/443259

Dave Merrill

Jamie Krug

unread,
Mar 28, 2013, 1:43:53 PM3/28/13
to cfml-plugin-fo...@googlegroups.com
When you hover over the "+" (for Modules), did you click New Module? And do you not see a list of module types to the left, in the New Module dialog, including a Web Module under the Other section?


--
You received this message because you are subscribed to the Google Groups "CFML plugin for IntelliJ IDEA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfml-plugin-for-inte...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dave Merrill

unread,
Mar 28, 2013, 2:33:26 PM3/28/13
to CFML plugin for IntelliJ IDEA
Duh, I hadn't clicked New Module in that context menu, confused by the fact that the specific options were there on other contexts but not there. 

But I'm still confused. The Web module doesn't give me the option to map web resource directories, which is what I'm actually trying to do, I think, so IDEA understands paths to css etc.

Edit: Apparently it's only the JavaEE Application that lets you do that, not Web. Ended up deleting the default module, creating a new JavaEE module at the root (which can't be named the same as your app, because project-name.iml already exists), and setting things up from there.

In short, thanks, got it, sorry to be thick, or unfamiliar w this aspect of life, or something...

Dave


On Thu, Mar 28, 2013 at 1:43 PM, Jamie Krug wrote:
When you hover over the "+" (for Modules), did you click New Module? And do you not see a list of module types to the left, in the New Module dialog, including a Web Module under the Other section?

Jamie Krug

unread,
Mar 28, 2013, 2:48:01 PM3/28/13
to cfml-plugin-fo...@googlegroups.com
Oddly enough, I still had a dialog open from ealier, on a brand new Java project that I created, and the drop-down for the "+" now *does* show "Web" and a bunch of others, below New Module and Import Module. It definitely wasn't there earlier, so either something buggy or some indexing had not finished?


--

Dave Merrill

unread,
Mar 28, 2013, 3:00:48 PM3/28/13
to CFML plugin for IntelliJ IDEA
Interesting. Indexing isn't the thing in my case i'm pretty sure, since this is a simple fw/1 example project I snagged off github several days ago, and haven't modified at all. No reason I can think of for any indexing action.

Dave
Reply all
Reply to author
Forward
0 new messages