Creating javadoc with gwt-user.jar through Gradle - gwt

I'm trying to compile the javadocs for my application, and for some reason it throws errors while compiling like this:
/Users/Sander/.gradle/caches/artifacts-23/filestore/com.google.gwt/gwt-user/2.4.0/jar/949dcb5d14cb0e2c8dec98efc0760be68753c124/gwt-user-2.4.0.jar(com/google/gwt/dom/client/CanvasElement.java):18: error: cannot access Context
import com.google.gwt.canvas.dom.client.Context;
All the errors thrown are found in gwt-user-2.4.0.jar. Basically, what (I think) it's trying to do is compile the .java source files the jar file contains, which it shouldn't do. Is there a way to make the javadoc command ignore java source files?
I've tried removing the source files from the jar manually, this way the build succeeds. However, since the jar is a gradle dependency, manually altering the file is not an option.

I finally got it to work. As it turned out, the javadoc command needed a sourcepath flag set, because otherwise it would start looking for the source files in the classpath, which contained some source files from the GWT jar file. Since the MinimalJavaDocOptions GWT class doesn't support this, I had to set it manually by adding the following line:
options.addStringOption("sourcepath", <path_to_source>)
This fixed the problem. Obviously it is not ideal, a topic in the Gradle Support Forums has already been created, see http://forums.gradle.org/gradle/topics/allow_javadoc_sourcepath_to_be_set_directly

Related

Intellij Idea is loading *.class file instead of *.scala from library source

My problem is best described with a screenshot:
As you can see, there is a org.virtuslab:unicorn-core_2.11 dependency loaded in my SBT/Scala project. The jar file with corresponding sources is available as well. For some reason, Intellij Idea decided to ignore the available source file Table.scala and uses the .class file instead. Clearly, all other files are okay.
Obviously, without the information contained in the .scala file, Intellij is not able to properly analyze my code and I'm getting Cannot resolve symbol BaseIdRepository errors (and similar) all over my project.
I manually checked the source package and the Table.scala file is there and seems alright. Plus this worked flawlessly until two days ago. I don't know why it broke down. I tried to revert my project using git to an earlier version when this was still working, but no luck.
I tried to both downgrade and upgrade the library, I tried to remove it and add it again, I tried create a completely new project based on existing sources, but once again, no luck.
Just for the record, I'm able to compile and run my project. The only thing that might be related is this warning that I get when compiling the project:
[warn] /home/tobik/scala/payola-viz/src/app/model/appgen/repository/UsersRepository.scala:7: Could not find any member to link for "BaseIdRepository".
I got an update for the Scala plugin which seems to fix this issue.
In case you experience similar problems, this temporary solution worked for me: I added the unicorn sources directly to my code base and manually removed it from the project libraries. I got rid of the errors and it still compiles as the library remains as a dependency inside built.sbt. To avoid polluting my project, I added the included sources to .gitignore. The workaround broke after a while but all I had to do was repeat the procedure again.

Eclipse can't find class DefaultSolver of OptaPlanner and throws ClassNotFoundException

Hi I'm building a program using optaplanner, and everything seems to be imported and working fine, but when I run and debug the code, I get a ClassNotFoundException "org.optaplanner.core.impl.solver.DefaultSolver". I believe I've imported all the jar files correctly, but just to be sure, what jar file is the DefaultSolver class in?
As a follow up, I keep getting prompted to edit the source lookup path. This happens after running SolverConfig.buildSolver() line 156: "DefaultSolver solver = new DefaultSolver();" I'm running OptaPlanner 6.1.0.Final.
Found the problem, I realized that I had both imported the examples jar file into my buildpath and at one point imported a class from the examples jar file when I was messing around with the examples. Rereading the manual I saw it explicitly said not to import the examples jar file, so I unimported that and found the culprit pretty fast. Thanks for your help.
Both the class SolverConfig and the class DefaultSolver are in the jar optaplanner-core-*.jar.
So this doesn't make sense: if the jar is in the classpath, it should find DefaultSolver. If the jar is not in the classpath, it shouldn't even find SolverConfig. What you're seeing can never happen in a normal classpath.
Are you using anything like OSGi, JBoss modules, jigsaw, Karaff or other classloading magic?

Groovy:unable to resolve class org.apache.commons.lang.time.DateFormatUtils

I have a Groovy script in Eclipse and I get the following at the import statement:
Groovy:unable to resolve class org.apache.commons.lang.time.DateFormatUtils
When I add the external commons-lang-2.4.jar to the Libraries in the build path, the error message goes away. But if I remove it and instead add the external Class Folder that contains this and other jars, then I get the error message.
Try adding the jar by navigating to Preferences->Java Build Path->Libraries and using add External JARs. I don't believe Eclipse will pick up the various jar files in a folder for compilation - you may need to be explicit with each JAR, and I don't think it supports wildcards for those as command-line javac does these days. (See aspects of this answer for some treatment of this, and a potentially interesting plugin).

Location of config file for devmode in Eclipse?

I have a multi module GWT project (say a.gwt.xml, b.gwt.xml, c.gwt.xml) that I am building in eclipse and testing in devmode. All was working well until I deleted one of the gwt module file and associated source. Now when I try to launch devmode from eclipse it fails with the following error message.
Loading modules
com.fubar.b
[ERROR] Unable to find 'com/fubar/b.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] shell failed in doStartup method
I assume that this means there is a stale reference to the now defunct b.gwt.xml but I can't seem to find it in any of the config files. Any ideas?
At present I am working around this by doing a copy+rename a.gwt.xml -> b.gwt.xml (so there are effectively 2 copies of the a module names a + b) which works fine but compiles 2 copies of same module :(
What I think is your runtime configuration which is gone wrong. Individual projects should be fine. Open the runtime configuration which you were running and check the entries in GWT! If the module you have deleted still exists here, then you need to remove it.
Runtime config for project
You can refer to the following Video.
http://www.youtube.com/watch?v=UW4WSYs1bKE
To rename
Right Click on the project.
Select Run As ---> Run Configurations.
In the Arguments Tab, change the Old Module Names in Program
Arguments.
Also Make sure, in GWT Tab, Selected module name is correct.
ALREADY I HAVE ANSWERED THIS HERE : GWT:how can i rename my module

How to mark .jar file as excluded from publish/export structure?

I have a .war project in Eclipse. It is probably not relevant but I should mention that it was converted from a maven project using mvn eclipse:eclipse plugin.
I saw a warning that various .jar files on the Build Path were not being exported. To fix this I went to Project Properties -> Deployment Assembly and added the jars that needed to go into the .war
However, one .jar file does not need to go into the .war because it will be provided by the container. It is on the build path merely to get the project to compile.
For this .jar file, I want to get rid of the warning. One way was to Ctrl+1 to QuickFix which caused the Properties->Java Build Path->Libraries tab->...jar file to have an extra line on expanding it which says: Excluded from publish/export structure: (None)
My question is how could I have done this without Quick Fix? I could not find any way to exclude from publish/export structure without using the Eclipse Ctrl+1 Quick Fix.
There is no other UI beyond the quick fix for setting the ignore flag.
m2e-wtp automatically takes care of this for you - any dependency that has the scope as provided is excluded from the publish\export structure.