Is there way to tell IntelliJ IDEA which output folder to use for GWT compiler? - gwt

Is there way to tell IntelliJ IDEA which output folder to use for GWT compiler ? I know it copies artifacts to project folder but it doesn't copy extras which I set using "-extra" command line parameter of gwt compiler.
IntelliJ IDEA leaves it in USER_HOME/.IntelliJIdea10/system/gwt/project_name_with_hash/module_name_with_hash/compile/www
UPDATE: Strangely I didn't find list of possible path macroses on IntelliJ's website. But I found them in idea.jar. Possible macroses are:
APPLICATION_HOME_DIR
PROJECT_DIR
MODULE_DIR
USER_HOME

Have you tried constructing the path using ${PROJECT_DIR} path variable? That will resolve to the project location and then you can specify the rest of the path. Like ${PROJECT_DIR}/reports/extras. I haven't used IntelliJ for a few years, but I am pretty sure that's the path variable name.
EDIT: sorry built in path macros in IntelliJ are specified using $...$ syntax. So I think it should be $PROJECT_DIR$

There is no way to change output folder for GWT compiler in IDEA. However you can specify absolute path to any directory after '-extra' parameter.
By the way for what purpose do you use '-extra'?

As of November 18, 2011 it is impossible to use path macroses in settings of project modules. Jetbrain is aware of this and there is feature request in their JIRA.
My work-around for a team with multiple engineers for now is to use system TEMP folder for GWT compiler extra output and move files in post-build event to folder I want it to be at.

Related

Eclipse: script compiler as part of a project

This question is not limited to lex and yacc, but how can I add a custom script compiler as part of a project? For example, I have the following files in the project:
grammar.y
grammar.l
test.script
The binary 'script_compiler' will be generated using grammar.y and grammar.l compiled by lex, yacc and g++. And then I want to use that generated script_compiler to compile test.script to generate CompiledScript.java. This file should be compiled along with the rest of the java files in the project. This setting is possible with XCode or make, but is it also possible with Eclipse alone? If not, how about together with Maven plugin?
(I might setup the script compiler as a separate project, but it would be nice if they can be put in the same project so that changes to the grammar files can be applied immediately)
Thanks in advance for your help!
You can add a custom "Builder" from the project properties dialog. This can be an ant script (with an optional target) or any other script or executable.
There are also maven plugins for ant and other scripting languages
If you just want to run an external program in Maven this is what you want: http://mojo.codehaus.org/exec-maven-plugin/ -- you can then run Maven targets from your IDE or command line and it should do the right thing either way.
To integrate with the normal compilation bind the plugin to the "generate-sources" phase and add the location where the Java files are generated to the "sourceRoot" option of the exec plugin. That way the compiler will pick them up.
Ideally you generate the code into a folder "target/generated-sources/MY_SCRIPT_NAME". That is the standard location for generated sources in the Maven world and e.g. IntelliJ IDEA will pick up source files inside of that location. Note that this doesn't work if the files are directly in "target/generated-sources".
The other option is to write your own Maven plugin, which is actually quite easy as well. See e.g. https://github.com/peterbecker/maven-code-generator

How to get Eclipse to create bin/main and bin/test

I want my Ant build to take all Java sources from src/main/*, compile them, and place them inside bin/main/. I also want it to compile src/test/* sources to bin/test/. I wan this behavior because I want to package the binaries into different JARs, and if they all just go to a single bin/ directory it will be impossible* (extremely difficult!) to know which class files belong where.
When I go to configure my build path and then click the Source tab I see an area toward the bottom where it reads Default output folder: and then allows you to browser for its location.
I'm wondering how to create bin/main and bin/test in an existing project without "breaking" Eclipse (it happens). I'm also wondering that if I just have my Ant build make and delete those directories during the clean-n-build process, that Eclipse might not care what the default output is set to. But I can't find any documentation either way.
Thanks in advance for any help here.
In Eclipse, you can only have one output folder per project for your compiled Java files. So you cannot get Eclipse to do the split you want (i.e. compile src/main to bin/main and src/test to bin/test).
You can, if you want, create two Eclipse projects, one main project and one test project, where the test project depends on (and tests) the main project. However, in that case, each project should be in its own directory structure, which is not what you are asking for. But this is a common approach.
Another way, which I would recommend, would be to not mix Ant compilation and Eclipse's compilation. Make the Ant script the way you describe (i. e. compile the main and test directories separately and create two separate jar files). Change the Eclipse compile directory to something different, for instance bin/eclipse. Use the Ant script when making official builds or building for release. Use Eclipse's building only for development/debugging. This way, your two build systems will not get in each other's way and confuse each other.
Hope this answers your question and I understood it correctly. Good luck!

How to get Scala Compiler Plugin to work in Scala IDE

Note: This is an exact repost of the same question on the Scala-IDE mailing list, where I got zero reply and gave up waiting after 5 days.
I'm writing a Scala Compiler Plugin. It's currently called
scalawrapper (but I might find a better name later). I have the
Typesafe Stack installed, and I put my plugin in it under:
C:\Program Files\typesafe-stack\misc\scala-devel\plugins
Now I can call scalac like this:
scalac -classpath ... -Xplugin-require:scalawrapper test\...
and it finds and uses my plugin automatically.
Unfortunately, I just can't get the Scala-IDE to use it. I always get
Missing required plugin: scalawrapper. In the "Project Properties
\Scala Compiler (Use Project Settings)\Advanced" tab, I have entered
scalawrapper in the Xplugin-require field, and that works, since I get
the error. But nothing I can type in Xpluginsdir seem to have any
effect.
I have tried the absolute path given above, have tried with forward
and backward slashes, have tried a temporary directory without spaces
in it, have tried relative to project directory, have tried relative
to workspace. It just will not use anything. I should also note that
is is not specific to my own plugin, as I tried to use the ScalaCL
plugin before in a previous version of the Scala-IDE, and failed for
the exact same reason.
I have just updated today (15.10.2011) and so should have the latest
version (it seems I can finally explicitly set the indentation to 4,
but maybe I just overlooked the setting in the past).
Can someone tell me what it actually expects, and what is uses as
default when I don't put anything in Xpluginsdir?
The Scala IDE uses the presentation compiler, not the compiler that you've installed. To use a plugin, with Scala IDE, you need to specify it in the preferences in Eclipse.
Try Windows->Preferences->Scala->Compiler. See the Advanced tab. The paths are relative to the workspace.
EDIT: When I say relative to the workspace, I mean the actual workspace directory under which the .metadata is stored ($workspace_loc). I have a project where project files including the source code is stored in one directory and the workspace is elsewhere, i.e the $project_loc (c:\code\project\source) is different from the $workspace_loc (c:\code\project\workspace). The directory that you specify in the compiler parameters is relative to the workspace ($workspace_loc).
To find out if you have a similar setup, go to the project and select Properties->Resource->Linked Resources.
I created a directory under $workspace_loc called plugin and placed the jar file in there. Under Windows->Preferences->Scala->Compiler Advanced tab I have
Xplugin = C:\code\project\workspace\plugin\xxx-0.0.1.jar
Xplugin-require = xxx
Please note that you can specify the plugin in the project properties as well, but it still uses $workspace_loc. The above configuration works for me.

Netbeans project to scripted build

I'm trying to convert a Netbeans 6.9.1 project into a scripted build (without netbeans). Of course, it fails (or I wouldn't be asking for help).
In the failure it says that the org.apache.commons.httpclient package does not exist. (Of course, it worked when we ran the build in Netbeans).
Now I know exactly where the commons-httpclient.jar file is located in my project structure, but I can't seem to tell it to the compiler via the ant build files and the netbeans property files.
Perhaps related to this is when I ran "ant -v" to build my software, it said,
Property lib.mystuff.classpath has not been set. This variable is important, I guess, because
the file nbproject/project.properties uses lib.mystuff.classpath in its definition of javac.classpath, which of course tells the Java compiler where to find the JARs.
So...when moving a Netbeans project to a netbeans-independent scripted build, how can the build script set these properties? Also, how can I ensure that the jar file gets included in the ant build?
I appreciate any help I can get, as I am a Java newbie.
UPDATE AFTER ACCEPTING ANSWER FROM vkraemer:
There are a few best practices for build scripts for production software:
Put everything needed for a build under a single directory tree. (Netbeans = fail)
Put everything in source code control. (I did that)
The first line of the build script should clear all environment variables.
The next section of the build script should explicitly set all environment variables to values which are known to work.
The next part of the build should be able to execute using command-line programs such as javac, ant, cc, etc, and must not depend on firing up an IDE such as Eclipse or Netbeans.
It is a shame that Netbeans makes this hard.
I did a quick look in a Java Application project and found the following...
javac.classpath = ${libs.MyStuff.classpath}
libs.MyStuff.classpath is defined in %HOME%/.netbeans/6.9.1/build.properties.
You may be able to get by doing the following...
ant -Dlibs.MyStuff.classpath=c:\a\b\c.jar
You would need to do more if you have multiple jar files in the MyStuff library that you created in NetBeans.

Add raw .groovy file to output dir in Eclipse with Groovy Plugin

I'm using Eclipse and I have the Groovy Plugin installed.
From within a standard Java project I want to include a file with a .groovy extension on the runtime classpath. I have a source folder (src/main/resources) which includes all files and has no exclusion filters. Inside that directory I have 2 files: foo.groovy and foo.txt. When I clean and rebuild the project from eclipse and look in the output directory I see foo.txt, but foo.groovy is nowhere to be found.
Does anyone know if it's possible to have Eclipse treat a file with a .groovy extension like any other resource file while still having the Groovy plugin installed and having other Groovy projects in the same workspace?
In case you are wondering, I'm trying to get logback configured using a groovy script. If there's some other way to accomplish this please let me know.
There is a new feature in Groovy-Eclipse 2.1.0 that allows you to specify script folders. These folders contain groovy files that are not compiled and are optionally copied to the output folder. src/main/resources is a script folder by default.
To enable this, install 2.1.0 (or later) and go to preferences -> Groovy -> compiler.
I ran into the same thing a few years ago. The Groovy plugin treats .groovy files as source files. The same way a .java files do not get put into the output directory, neither do .groovy files. At the time I could not find a way around this. I don't know if there is a way around it but I did come up with a workaround.
I used the extension .g for groovy files that I wanted to keep as scripts and have them interpreted at runtime. These would be skipped by the groovy compiler and would end up in the output directory. Also doing things this way allows you to mix compiled groovy (.groovy) and runtime interpreted groovy files (.g).
** EDIT **
See comment from #Andrew Eisenberg. This answer was correct when this question was originally asked. His answer is correct going forward since there is a new version of the eclipse plugin.