We use Eclipse for our Java development, and we've got Maven compiling our JSPs into servlets to be used in our embedded Jetty instance. This means that to run the project from Eclipse, I have to include ./target/jsp-source as a source folder, which works great. The warnings that show up for that generated code are everywhere though, and I want to filter them out.
mainMenu_jsp.java has a warning about a local variable not being used. It's generated code, so I don't care about it, but I can't figure out how to filter out any warnings by filename pattern.
I know I can define a working set, but because I'm always opening,closing, and sometimes adding and deleting projects, I don't want another point of manual bookkeeping that I have to keep up to date. If I add a new project and forget to go in and add it to the working set, I won't get any warnings for it, which with all the other projects, I might not notice. Working sets would only really work if there was a way to set them to dynamically expand to include all projects (not just all right now), and have their filtering automatically apply to each new project as it's added.
Just use a Working Set. Details about how to do it here:
Excluding Unfixables from Eclipse Problem View
And here:
Eclipse Problems view
[Using a Working Set] doesn't work for a lot of situations.
For example, the Android Eclipse plug-in generates code into the same project.
A working set consists of one or more projects, in their entirety, so a working set can't filter out generated warnings that are intra-project.
Edit:
I learned something super-useful: working sets can filter out parts of projects. It's simple to do--click on the project in the left pane of the working-set editor and expand it. Then only add what you want.
A working set works well with multiple projects. I suggest you try using one.
Related
I have two "errors" with url references that appear when using struts forms in a new project I'm templating out in IntelliJ Idea. It's the strangest thing because neither of them are actual errors. The program builds and deploys as I expect
The first one is this. Now I'm sure that I could extract a copy of the "Struts-Tags" and put it somewhere but why am I getting this <statement> or delimiter error.
The second one is of the same line, it has to do with the zero config project I'm trying to build with convention I think. This one fails to recognize that I'm mapping to an action via the convention plugin without a config.
I'm just getting started on a project that I plan to use as a template for a larger project and I like to keep my projects clean of any errors. If I'm breaking best practices and that's the issue I'd love to hear about it but I was rather fond of building my template framework this way so I'd be disappointed if I was I guess. I'm new to the convention plugin but it seemed like a pretty clean way to set up a business application, more so than my last xml configured struts2 app on 2.3.
Anyway here are some additional references in case there is an issue elsewhere that I am overlooking.
Struts 2 plugin enabled (have tried all 8 combinations of the 3 struts intellij plugins)
Empty struts.xml file
web.xml file (some spring stuff cut off but the removal of all spring dependencies and configs did not affect intellij showing me these errors)
Maven struts dependencies
Action class... don't mind Data, it just generates my getters and setters, again #Component definitely isn't the issue as I have already tried removing all my spring stuff
Package Layout
If it helps you can download the project:
https://github.com/DrakeFramework/DrakeNelson
I was hoping to get my jpa and 3 deployments configured but I just can't stand committing a project and saying "OK" to errors, that's how it grows out of control and before you know it the 10,000 warnings are all just ignored.
The first problem is not reproducible in your sample project:
It could be that you've injected something like SQL into the parameter using Alt+Enter | Inject language or reference context menu. You can repeat this step, but use the Un-inject option.
The second problem is also not reproducible for some reason:
I dislike the build tools that exist for Java. So I wrote my own. But there is one feature that it doesn't have yet; auto-import of changes into the IntelliJ project.
I'm having trouble finding information on how to do this. Tutorials on how to write IntelliJ plugins throw tons of useless stuff at me (creating UI for example).
I know this isn't your typical stackoverflow I-have-a-bug question but I'm quite lost and could use a pointer in the right direction.
If you need to know when a certian file was changed and auto-import information from this file you can use VirtualFileManager.addVirtualFileListener().
Or even use fileDocumentManagerListener extension point. Whatever suits your needs more.
So far I've managed to create a simple IntelliJ plugin. The start is fairly simple. IntelliJ has the plugin project skeleton built in. File->new Project is enough there.
From there I've created a class that implements ModuleComponent. The documentation here (https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_components.html) says it will be loaded whenever a module is opened.
To get it to work I had to add this stuff in the plugin.xml:
<module-components>
<component>
<interface-class>packagename.ClassName</interface-class>
<implementation-class>packagename.ClassName</implementation-class>
</component>
</module-components>
The documentation manages to hide this next step but its possible to give the ModuleComponent a constructor like so:
public ClassName(final Module module) {}
This should give me an instance of the Module class to read values from and to modify the way I need.
As it turns out IntelliJ makes it difficult to figure out how to do things. There is no Javadoc for example. People seem to suggest reading the source code. Weird..
A quick look through the methods of Module didn't really help me much. Google let me know that in order to make changes to the Module I could do the following:
ModuleRootManager.getInstance(module).getModifiableModel()
I can call several methods on this model and finally call .commit() when I'm done to persist the changes. The ModifiableRootModel has two methods that look very promissing:
ModifiableRootModel.addModuleOrderEntry()
ModifiableRootModel.addLibraryEntry()
The first takes a Module instance. I'm hoping that if I add the correct Module this will allow me to well, add modules :). I can think of two situations here. First, the module is already loaded in the project, in which case I will need to find it and add it. And second, the module is not loaded yet so I will need to tell IntelliJ to load it and add it to the project.
The second method takes a Library instance. Just new Library() doesn't work, and google isn't very helpful here. From my buildfile I can extract the groupId:artifactId:version:scope value. So I'll need a way to turn those strings into a Library that works.
This is how far I've gotten so far. Current problems are:
I need to find the already loaded modules so I can find the one I'm linking to
I need a way to add a module to the project if it hasn't been loaded yet
I need a way to turn a maven style dependency into a Library object so I can add it to the module
I need a way to list all the existing modules and libraries so I don't end up adding duplicates
I have 5 packages in my workspace. One is the "core" package that holds the critical java files for my application, and the name of this package also happens to be the name that I want the working set that contains it to be. The other packages in the workspace (4 of them) are on the build path and provide convenience methods and the like. I want to create a working set based on this core package and have all the other packages on its build path automatically enter its working set.
How do I achieve this without manually setting these extraneous packages to the working set, and then manually updating the working set when the dependencies change?
In my real life setting I have numerous working sets I need to manage so this quite quickly becomes overly tedious.
I don't think you can unless you provide an external script. Eclipse help file states
Newly created resources are not automatically included in the active
working set. They are implicitly included in a working set if they are
children of an existing working set element. If you want to include
other resources after you have created them you have to explicitly add
them to the working set.
I have a relatively small project (50 classes) that has included 13 JAR libraries (android-support, gson, guava etc) and uses one Android library (Sherlock).
The problem is that whenever I press "Build Project" it takes around two minutes to build/deploy to a device. (However newly created android project takes no more than 5 seconds to build).
Is there something I can do with it (limit number of libs, switch to another IDE)? Or it is just usual behavior.
The project takes that long to compile because it needs to add the JAR files and Sherlock library. Every library added to the project will increase the build time of the project.
Switching to another IDE would not make a huge difference because a lot of the building is handled by the Android SDK.
Your best bet would probably be to limit the libraries of your project using elimination to see which causes the largest build time increase.
AlexR has a good answer. To add:
I use IDEA so I don't know how to do this in Eclipse but I know it can be done - probably right click context menu.
Exclude any layouts that you don't really need for dev/test from your build. I tend to put placeholder layouts in early in a project then refine them later in the project when the main code is getting to alpha quality. I exclude everything except one set, e,g. "normal" portrait, do all of my code creation then only add the layouts back in near the end.
Same goes for assets. Do you have a lot of assets or assets of large size? Exclude these, or perhaps temporarily replace with smaller ones.
All this said, the compilers used do a very good job of optimisation and as the number of classes grows, it is inevitable that your build time will increase. It's not exponential (I've never actually measured it) but it's certainly worse than linear.
I do not have direct answer to your question but I can recommend you the following steps.
You compare build+deploy of "Big" project with build of "Small" project. Did you try to compare exactly same operation for both? What the result is?
Try to create new workspace. Sometimes it helps to Eclipse.
Try to take "Small" project and move from it to "Big" one step-by step. For example add dependencies first. Try to build the project. The time did not significantly changed? Go forward and add 20 custom classes etc. The time changed? Try to find which library causes this. You can also choose other strategy: try to add classes without adding dependent jars, just comment out code that uses dependencies. This way may be more complicated but I believe still possible since your project is indeed to too big.
Good luck.
I'm working on a couple of web services that use JAXB bindings for the messages (in JAX-WS or spring-ws). When using these bindings there's always some code that is automatically generated from the WSDL to bind the message objects. I'm struggling to figure out the best way I can make this work so that it's easy to work with, hard to break and integrates nicely with IDEs (mostly using eclipse).
I think there are a couple of ways to go about this. The three main options I see right now are:
Generate code, keep the source artifacts and check them into the repository. Pros: integrates easily with IDEs (source highlighting etc), works within the build system. Cons: generated code changes each time you regenerate it, possibly creating noisy commits. It's also redundant since the WSDL file is already checked in, usually.
Generate code as part of the build process. Don't keep source artifacts or only keep them in output directories. Pros: fixes all the cons from the previous one. Cons: harder to integrate with IDE, though maybe this build step can be run automatically? I currently use this on one of my projects but the first time I checkout the project it appears broken, which is a minor nuisance.
Keep generated bindings in separate libraries (jars) included with maven or manually updated jars, depending on your build process. I got the idea from a thread on java.net. This seems more stable and uses explicit versioning but seems a bit heavyweight.
Which one of these options would you implement and how? We're currently using maven and eclipse, so any ideas in that regard would be great. I think this problem generalises to most other build systems and IDE combinations though, even other languages perhaps.
I went for option 3. If you already host your own repository (and optionally CI), it's not that heavyweight. All it takes is a simple POM. It's even possible to include some utility/wrapper/builder classes (that often make life easier with generated classes) and use them in several projects.
I'd go for option 2 and generate code in the "standard" ${project.build.directory}/generated-sources/<toolname> location as part of the build process. Using generated sources is well supported by m2eclipse (use Maven > Update Project Configuration once sources have been generated) and, if I remember well, by the maven eclipse plugin as well (i.e. the folder will be added to the Java Build Path). Actually, I think NetBeans also handle this fine. Not sure for Idea.
For the generation itself, you may need the maven-jaxb2-plugin if I understood correctly.