Maven offline build fails when it encouners google guava url with invalid character - eclipse

I need to make my Tycho-Maven build work in offline mode, so I can deploy it to environments with no Internet connection and let people run the build from the previously downloaded artifacts for the third party code my app depends on. The product being built is an Eclipse RCP product, using the org.eclipse.tycho:target-platform-configuration plug-in to load the dependencies from an RCP target file.
First I run mvn -Dmaven.repo.local=/some/path/ -DgeneratePom=true clean install to create the artifacts, and that build succeeds. Then when I run mvn -Dmaven.repo.local=/some/path/ -o clean install it fails because it's running in offline mode and there is no local cache available for http://download.eclipse.org/tools/cdt/releases/8.6
So then I run mvn -Dmaven.repo.local=/some/path/ dependency:go-offline to make it download all the artifacts it needs for the build, but it fails with this message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins
(resolve-plugins) on project : Nested: Could not transfer
artifact com.google.guava:guava:jar:[10.0.1,14.0.1] from/to central
(https://repo.maven.apache.org/maven2): Illegal character in path at
index 60:
https://repo.maven.apache.org/maven2/com/google/guava/guava/[10.0.1,14.0.1]/guava-[10.0.1,14.0.1].jar
Index 60 is the "[" character in the version range specifier for the guava jar. I have no idea where that URL gets created and why it's not URL-encoded. It would be nice to get the dependency:go-offline goal to complete execution, but I don't think it's the source of my problem.
The reason I say that is when I run that goal, I see this in the output
[INFO] Adding repository
http://download.eclipse.org/tools/cdt/releases/8.6 [INFO] Fetching
p2.index from http://download.eclipse.org/tools/cdt/releases/8.6/r/
(0B at 0B/s)
I don't know why it downloads 0 Bytes, but I assume this is why I can't find a cache of the CDT bundles when I try to do an offline build.
If anyone has an idea how to work around this failure, or any other approach to make an offline build work, that would be very helpful.

I created this Maven bug report in the issue tracker.

In the course of creating a stripped down project to demonstrate the problem, I discovered the cause. The presence of org.eclipse.xtend:xtend-maven-plugin in the pom was causing the problem. The plug-in is not used, and was perhaps misconfigured, per a message I saw in the build output.

Related

intellij/activator/sbt are downloading dependencies previously downloaded by the other

I'm not an expert with sbt so probably my question is a bit noob, but I've notice than when I create a project and download its dependencies with sbt, if I open the project with intellij, all the dependencies are redownloaded again, the same happen in the inverse orden intellij->sbt and also activator..
my (poor) knowledge about sbt is than this use ivy and the dependencies are downloaded in ~/.ivy2/ folder...that is where sbt is downloading my deps, but seems than intellij is using other folder.
personally I don't use so much activator, but I would like configure sbt and intellij for use the same ivy path...
2)recently I publish finagle-postgre to my local ivy using sbt +publishLocal, I can check in my ivy folder
/home/yo/.ivy2/local/com.twitter/finagle-postgres_2.11/0.1.0-SNAPSHOT
but unfortunately intellij is unable to resolve this dependency, I try adding this line to my build
resolvers += Resolver.file("Local", file( Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)
but seems not works
3) the path where is downloaded the dependencies is related to which sbt-launch.jar file is used? How can I know what sbt-lauch.jar file is using sbt right now...
thanks guys!
If we're talking about IntelliJ appearing to download artifacts after they've already been downloaded by SBT/Activator, then it turns out that it's probably just that IntelliJ is downloading the sources - it's not redownloading the binary artifacts, just the source artifacts that accompany them.
This isn't readily apparent when you're looking at the Refreshing SBT project task in the Background Tasks popup, because the full download path is truncated, so you see something like this:
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcompo...
..it's natural to assume that this is the same binary artifact you already saw SBT download on the console, but you can see the full story if you check the full log (go Help -> Show Log in files and open sbt.last.log in the file browser).
You'll see that the only artifacts getting downloaded end with -sources.jar:
$ grep repo1.maven.org /home/roberto/.IntelliJIdea2016.3/system/log/sbt.last.log
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/com/googlecode/javaewah/JavaEWAH/0.7.9/JavaEWAH-0.7.9-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/org/pegdown/pegdown/1.2.1/pegdown-1.2.1-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3-sources.jar ...
```
If you don't have the Sources checkbox checked when you're doing Import project, these source downloads won't happen.
tested using IntelliJ 2016.3.5 and Scala plugin v2016.3.9
First, the activator is just a launcher for SBT itself, so there should be no difference in behaviour.
Second, IntelliJ also uses the files in ~/.ivy2 by default if you have not told it otherwise (by setting SBT_OPTS environment variable for example, but that depends on your IntelliJ version).
A difference might result if you're using different scala versions (e.g. 2.10.x vs. 2.11.x) when you do not have set the scalaVersion in your project explicitly. Then, each tool would download the corresponding libraries for the appropriate scala version it has configured by default.
Another thing is that IntelliJ will download source and javadoc jars for each dependency if you have enabled that in your settings which might look like it downloads the dependencies again.
Note, I'm wildly guessing here because you have not included any output of the programs you're using, so it's hard to say what the real problem is.

can't compile play showcase html

I installed playN however I get this error:
[INFO] --- gwt-maven-plugin:2.4.0:compile (default) # playn-showcase-html ---
[ERROR] Error: Could not find or load main class com.google.gwt.dev.Compiler
I checked the m2 repository, and the gwt jars for 2.4 2.5 gwt seem to be there.
If I try to use GWT 2.5 in the project then I get this
The GWT SDK 'C:\Users\user.m2\repository\com\google\gwt' on the project's build path is not valid (Version is not supported, must be 2.0.0 or later)
playn-showcase-html
Unknown Google Web Toolkit Problem
Does this make sense at all?
How to fix it?
Thanks
It seems that some gwt jars in the maven repository were corrupted. I deleted them, i run the playN sample again, the jars were downloaded correctly, and the whole think worked
C:\Users\user.m2 <-- this is very strange. it looks like somehow your maven repository path is munged up.
Check your environmental variables for MAVEN_REPOSITORY and see if its set to C:\Users\user. Also, find your maven installation directory, and look under the conf directory for a settings.xml, and see if you have <localRepository>${env.MAVEN_REPOSITORY}/.m2/repository</localRepository>.

How do I run a maven/eclipse/GWT/playN app in production mode?

There seems to be an issue if you want to launch a playN/GWT/maven app from eclipse in production mode using the following procedure:
Right click on playn-showcase-html and select Goolge-GWT Compile
Compiling module playn.showcase.Showcase
Resolving com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator
Found type 'com.google.gwt.validation.client.constraints.AbstractDecimalMaxValidator'
Found type 'javax.validation.constraints.DecimalMax'
[WARN] Detected warnings related to 'javax.validation.Constraint'. Is validation-<version>.jar on the classpath?
Specify -logLevel DEBUG to see all errors.
[WARN] Ignoring unresolvable annotation type javax.validation.Constraint
Compiling 1 permutation
Compiling permutation 0...
Compile of permutations succeeded
Linking into /Users/bryan/dev/playn-samples/showcase/html/target/playn-showcase-html-1.0-SNAPSHOT/showcase
Link succeeded
Compilation succeeded -- 19.459s
Anyone know what these warnings are about?
Right click on playn-showcase-html and select Run As web application
Go to URL http://127.0.0.1:8888/Showcase.html in your browser and you'll get an error that says GWT module 'showcase' may need to be (re)compiled.
The only way around this appears to be if you swap steps 1 & 2, but that just seems backwards. I think the problem is that the when you run the web app from eclipse that the gwt maven plugin is compiling/deploying the artifacts again which step on your previous GWT compile step.
Anyways, this isn't a huge deal since you can reverse the order of steps to get it to work, but I was just curious if anyone has found a solution to this.
I suggest that you try to compile/run it with maven directly, not through Eclipse, first go to the root directory of your game and do the following:
mvn clean package
that should compile your game without problems, and then
mvn test -Ptest-html
and that should run your game in http://localhost:8080/
Hope this helps, and I strongly suggest that use maven directly whenever you can, because Eclipse has a lot of incompatibility problems with some things.

Eclipse maven plugin getting HTTP 416 when retrieving jar

I'm getting this error in the eclipse logs when I use the maven integration plugin for eclipse in my project:
Build errors for transport-data; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (default-resources) on project transport-data: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4, org.apache.maven.shared:maven-filtering:jar:1.0-beta-4, org.codehaus.plexus:plexus-interpolation:jar:1.13: Failure to transfer org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-interactivity-api:jar:1.0-alpha-4 from/to central (http://repo1.maven.org/maven2): Failed to transfer http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar. Error code 416, Requested Range Not Satisfiable
From the browser I can access the jar but how come the plugin gets a 416 status response?
I'm using STS 2.7.2.RELEASE (Eclipse 3.6) with the Maven Integration plugin on Maven 2.2.1
and my OS is Ubuntu 10.10. If someone could please help explain this mystery to me I'd be very grateful.
Thanks!
I know that this is a very old request, but I just came across it too. What worked for me was deleting the relevant downloaded components in the .m2 repository. I figured that there may be some partially-loaded bits in there as I had used both Eclipse and command line with maven.
Hope this helps...
HTTP 416 means that the client requested only a portion of the file, but the server probably doesn't support such requests. Though I would be surprised if maven would have broken their repo webserver.
Another possibility is that you are behind a proxy which doesn't support range requests.

GWT Development Mode with Eclipse/Maven

I am just starting with GWT. I use Eclipse and have installed the GWT plugin.
I have followed the directions here Maven GWT 2.0 and Eclipse to set up a GWT project using the gwt-maven-plugin. When I run the Maven goals gwt:compile gwt:run, GWT Development Mode is launched and I can copy the url from it to my browser and view the label.
However, the project has this problem:
Description: The web.xml file does not exist
Resource: WEB-INF
Path: /GWTExample/war
Location: Unknown
Type: Google Web App Problem
If I try to run the project as a Google Web Application, I get this warning:
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
I can get rid of the problem by copying the web.xml to the war directory, but I still get the URL issue when running as a Google Web App.
If I'm using Maven and GWT in Eclipse, should I just ignore the web.xml problem and always run applications in development mode via the Maven goals? Or is there a way to set things so I can run as a Google Web App?
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run? I have added breakpoints to my application but it doesn't stop on them. I'm not sure if it is something I've configured wrong or if it's just not possible.
Update:
In response to Prem's answer...
When I run a compile gwt:run, the web.xml file isn't copied. When I run the install gwt:run, I get this error:
[INFO] --- gwt-maven-plugin:1.2:test (default) # SampleGWT ---
[INFO] using GWT jars from project dependencies : 2.0.4
[INFO] establishing classpath list (scope = test)
[ERROR] java.lang.NoClassDefFoundError: org/codehaus/mojo/gwt/test/MavenTestRunner
[ERROR] Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.gwt.test.MavenTestRunner
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[ERROR] Could not find the main class: org.codehaus.mojo.gwt.test.MavenTestRunner. Program will exit.
[ERROR] Exception in thread "main"
I’m guessing that bug http://jira.codehaus.org/browse/MGWT-24 is included in version 1.2 of the gwt-maven-plugin. Normally I wouldn’t run install on a project that builds a war file, but I would expect to at least get past the test phase of the build cycle.
Does anybody have any idea why I would get this error on the install but not the compile goals? Also, should I be expecting either goal to copy the web.xml file from src/main/webapp/WEB-INF/web.xml to the /war directory?
Description: The web.xml file does not exist
gwt-maven-plugin creates a project with 'war' packaging format (it's a web app so no surpirse here). Web.xml for this project will be under 'src/main/webapp' folder which will be copied to the 'war' directory (which is set as the output directory) as part of the 'resources' phase in the maven build life-cycle. You should always use
mvn compile gwt:run
or
mvn install gwt:run
so that resources are copied, all java files are compiled and gwt:compile is also invoked (since it is bound to the 'compile' phase automatically)
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
As per the stackoverflow link you used as reference, only your maven build file is setup with startupUrl. In order for it to work in Eclipse, you must edit the Run Configuration of your project and add the '-statupUrl' command line arguments to the existing arguments in the "Arguments" panel.
However, this is just a warning and it should not stop you from running your GWT application from eclipse. If you are facing the same "web.xml" problem here as well, it could be because you did not compile your project in your IDE before invoking "Run as Web Application". I suggest you to disable "Build Automatically" option for this project and always build it manually and invoke "GWT Compile" and then try "Run as web application"
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run?
In general you must use "Remote Application" debug configuration for remote debugging a process. However I am not sure if it will work for GWT projects.
I got me too this warning:
No startup URLs supplied and no plausible ones found
when I have followed this gwt tutorial
In that screenshot there is no checkbox with "Generate sample code" . In my IDE ( sdk 2.5) it is, so I have unchecked...
It wasn't created any of the server and client packages, I have created the client manually, as the tutorial required. The tutorial until that step doesn't say I must have a server package too. That and his configuration is missing from project.
If you right-click on your project and go to Properties -> Google -> Web Application, your WAR directory might be something like either war or src/main/webapp/WEB-INF/classes.
Change that to src/main/webapp.
Also un-check the box next to "Launch and delploy from this directory..."
That's what fixed this problem for me. It also fixed the "can't find gwt-servlet.jar" problem at the same time.