No source code is available for type <xyz>; did you forget to inherit a required module? - eclipse

I'm trying to add a dependency to my GWT project. The problem is that I am getting the following error:
[INFO] --- gwt-maven-plugin:1.0-beta-2:codeserver (default-cli) # mahlzeit-web ---
[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO] workDir: E:\java\mahlzeit-web\mahlzeit-web\target\gwt\codeserver
[INFO] Loading Java files in com.mahlzeit.web.App.
[INFO] Tracing compile failure path for type 'com.mahlzeit.web.GoogleCalendarPanel'
[INFO] [ERROR] Errors in 'file:/E:/java/mahlzeit-web/mahlzeit-web/mahlzeit-web-client/src/main/java/com/mahlzeit/web/GoogleCalendarPanel.java'
[INFO] [ERROR] Line 54: No source code is available for type com.bradrydzewski.gwt.calendar.client.Calendar; did you forget to inherit a required module?
[INFO] [ERROR] Line 161: No source code is available for type com.bradrydzewski.gwt.calendar.client.event.DeleteHandler<T>; did you forget to inherit a required module?
[INFO] [ERROR] Line 162: No source code is available for type com.bradrydzewski.gwt.calendar.client.event.DeleteEvent<T>; did you forget to inherit a required module?
I know I would have to add something like <source ...> to my App.gwt.xml file but that is generated. I am using the gwt-maven-archetypes in Eclipse.
How can I add this dependency s.t. the GWT Compiler finds the sources in the library .jar file?

You need to add the appropriate <inherits/> to your src/main/module.gwt.xml.
The plugin will only generate those inherits for JARs that contain a META-INF/gwt/mainModule (if that's what you mean by "that is generated"), i.e. almost none of them.

Related

Сan't run examples. Couldn't find artemis.home error

I get an error when I want to run any example through mvn verify
[ERROR] ********************************************************************************************
[ERROR] Could not locate suitable Artemis.home on either D:\Documents\IdeaProjects\activemq-artemis\examples\features\standard\security\..\..\..\.. or D:\Documents\IdeaProjects\activemq-artemis\examples\features\standard\security\..
\..\..\..\artemis-distribution\target\apache-artemis-2.18.0-SNAPSHOT-bin\apache-artemis-2.18.0-SNAPSHOT
[ERROR] Use the binary distribution or build the distribution before running the examples
[ERROR] ********************************************************************************************
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.087 s
[INFO] Finished at: 2021-02-26T22:03:39+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.activemq:artemis-maven-plugin:2.18.0-SNAPSHOT:create (create) on project security: Couldn't find artemis.home -> [Help 1]
I tried to specify the path to the directory with artemis at startup, but it does not help mvn verify -Dartemis.home="D:\Documents\apache-artemis-2.17.0"
How to fix this error?
It appears you're running the example directly from the project source since it reports 2.18.0-SNAPSHOT. If that's the case then you should do what the ERROR message indicates:
Use the binary distribution or build the distribution before running the examples
You can get a snapshot binary distribution here or you can build the distribution from the source using mvn install -Prelease -DskipTests.
If you must point the example at a different home directory you can do so using the activemq.basedir system property, e.g.:
mvn verify -Dactivemq.basedir="D:\Documents\apache-artemis-2.17.0"
Or you can change the activemq.basedir property defined in the example's pom.xml.

sbt: How to get dependent jar files list by Scala code

I'm new to sbt. I'd like to know how to get dependent jar files by Scala code, not executing sbt plugin.
In Gradle, it supports to get dependent jar files by Java code like the following (project is an instance of Project class):
Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration();
Set<File> jars = config.resolve();
I'd like to know a way to do like that in sbt and Scala. Does anyone know this? I tried to use sbt.Project#dependencies, but it seems that one doesn't meet for this purpose.
You are looking for dependencyClasspathAsJars:
sbt > inspect dependencyClasspathAsJars
[info] Task: scala.collection.Seq[sbt.internal.util.Attributed[java.io.File]]
[info] Description:
[info] The classpath consisting of internal and external, managed and unmanaged dependencies, all as JARs.
[info] Provided by:
[info] ProjectRef(uri("file:/home/claudio/foo"), "foo") / Compile / dependencyClasspathAsJars
[info] Defined at:
[info] (sbt.Classpaths.classpaths) Defaults.scala:1800
[info] Dependencies:
...
As you can see, this is a Task that returns a scala.collection.Seq[sbt.internal.util.Attributed[java.io.File]] where Attributed is just a simple wrapper around arbitrary data: https://www.scala-sbt.org/1.x/api/sbt/internal/util/Attributed.html
sbt > show dependencyClasspathAsJars
[info] List(Attributed(/home/claudio/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.13.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/twirl-api_2.13/jars/twirl-api_2.13-1.5.0.jar),
Attributed(/home/claudio/.ivy2/cache/org.scala-lang.modules/scala-xml_2.13/bundles/scala-xml_2.13-1.2.0.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-server_2.13/jars/play-server_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play_2.13/jars/play_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/build-link/jars/build-link-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-exceptions/jars/play-exceptions-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.play/play-streams_2.13/jars/play-streams_2.13-2.8.1.jar),
Attributed(/home/claudio/.ivy2/cache/org.reactivestreams/reactive-streams/jars/reactive-streams-1.0.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.akka/akka-stream_2.13/jars/akka-stream_2.13-2.6.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe.akka/akka-actor_2.13/jars/akka-actor_2.13-2.6.3.jar),
Attributed(/home/claudio/.ivy2/cache/com.typesafe/config/bundles/config-1.4.0.jar)
...)
If you want to process the value in any way, you probably want to write a custom task: https://www.scala-sbt.org/1.x/docs/Tasks.html

gwt 2.8 throws exception when compiling with guava 20

I am trying to upgrade to the newly released guava-gwt 20. I am getting this exception when I do a gwt compile. I did not get any errors prior to upgrading to guava 20. I am using the gwt 2.8.0. Is there a module I need to reference? Much appreciated!
[INFO] Tracing compile failure path for type 'java.util.concurrent.Future'
[INFO] [ERROR] Errors in 'jar:file:/Users/Eric/.m2/repository/com/google/guava/guava-gwt/20.0/guava-gwt-20.0.jar!/java/util/super/java/util/concurrent/Future.java'
[INFO] [ERROR] Line 32: No source code is available for type java.lang.InterruptedException; did you forget to inherit a required module?
[INFO] Tracing compile failure path for type 'java.util.concurrent.CountDownLatch'
[INFO] [ERROR] Errors in 'jar:file:/Users/Eric/.m2/repository/com/google/guava/guava-gwt/20.0/guava-gwt-20.0.jar!/java/util/super/java/util/concurrent/CountDownLatch.java'
[INFO] [ERROR] Line 30: No source code is available for type java.lang.InterruptedException; did you forget to inherit a required module?
[INFO] [ERROR] Aborting compile due to errors in some input files
This appears to be a Guava bug. Until we fix it, you can work around it by adding <inherits name="java.lang.Lang"/> to your .gwt.xml.

Gwt compiling error: unable to find entry point when it's not in src/main/java

I have an error compiling my app:
[INFO] Compiling module com.mycompany.myapp.MyAppMocked
[INFO] Finding entry point classes
[INFO] [ERROR] Unable to find type 'com.mycompany.myapp.client.mock.MockEntryPoint'
[INFO] [ERROR] Hint: Check that the type name 'com.mycompany.myapp.client.mock.MockEntryPoint' is really what you meant
[INFO] [ERROR] Hint: Check that your classpath includes all required source roots
In my .gwt.xml, I have:
<entry-point class="com.mycompany.myapp.client.mock.MockEntryPoint" />
The problem occurs when I put MockEntryPoint.java in src/mocked/java instead of src/main/java.
I need to have both directories to exclude everything in src/mocked/java when compiling the "no-mock" version.
If I move MockEntryPoint.java to src/main/java, the compilation will succeed with no error. In both cases, the class MockEntryPoint is in the package "com.mycompany.myapp.client.mock".
How can I tell gwt to look for my entry class in src/mocked/java?
Assuming this is a Maven project, you need to add src/mocked/java as a source folder. In Maven, it has to be done using the build-helper-maven-plugin's add-source mojo.
But there's little to no reason to have that src/mocked hierarchy:
you can put everything in src/main and just compile the GWT module you need/want (set the module or modules configuration property for the gwt-maven-plugin accordingly)
if you want them clearly separated, Maven wants you to use distinct Maven modules/projects. You don't want to fight against Maven.
Replace statement <source path='main'/> with <source path='mocked'/> in your .gwt.xml
Then compiler will know which directory to choose for compilation.
I hope it helps.

Error to compile when applying Single Script Linker

Because I am creating a chrome extension with GWT project, I want to use Single Script Linker to avoid inline scripting restriction (sigh...).
And I found this resource on line: http://tech-drum.blogspot.ch/2012/08/gwt-chrome-extension-using-version-2.html
This single script linker looks like a charm, but when I really added it into my gwt.xml file and compile, it got errors... (sigh again)
The following is the error msg:
[INFO] --- gwt-maven-plugin:2.5.1:compile (default) # fake-app ---
[INFO] auto discovered modules [com.fake...]
[INFO] Compiling module com.fake.name.app
[INFO] Compiling 6 permutations
[INFO] Compiling permutation 0...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 3...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 1...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 2...
[INFO] Compiling permutation 4...
[INFO] Compiling permutation 5...
[INFO] Compile of permutations succeeded
[INFO] Linking into /path/to/fake/app
[INFO] Invoking Linker Single Script
[INFO] [ERROR] The module must have exactly one distinct permutation when using the Single Script Linker; found 6
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
What's the problem with this? It looks that permutation number (assumed as js file?) to be larger than expected, but shouldn't the linker put size restriction when creating permutations? In short, how to fix this? Thanks a lot!
Selecting just the user agent for Chrome should fix your problem.
You don't need more user-agent permutations since your extension only works with one browser.
The linker you are using is the correct one for producing just a javascript file with the code of your extension.
<set-property name="user.agent" value="safari" />
The linker runs after the code is compiled, it can't make judgements about the output until that point. This particular linker expects to produce exactly one JS file (plus images, etc perhaps, but not more code) hence 'single script'. Generating more than one permutation prevents it from doing its job.
Consider selecting a different linker, or combining all of the properties you are using (likely just user.agent) into one permutation with this in your module file (from http://code.google.com/p/google-web-toolkit/wiki/SoftPermutations):
<collapse-all-properties />