akhikhl / wuff

Gradle plugin for automating assembly of OSGi/Eclipse bundles and applications
MIT License
152 stars 51 forks source link

Scaffold command fails on OSX #7

Closed aalmiray closed 10 years ago

aalmiray commented 10 years ago

Encountered an error when following the instructions laid out at https://github.com/akhikhl/wuff/wiki/Create-first-RCP-app

Environment

------------------------------------------------------------
Gradle 2.0-rc-1
------------------------------------------------------------

Build time:   2014-06-06 07:02:41 UTC
Build number: none
Revision:     b6ead6fa452dfdadec484059191eb641d817226c

Groovy:       2.3.2
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_05 (Oracle Corporation 25.5-b02)
OS:           Mac OS X 10.9.3 x86_64

Error on output

Downloading file: http://mirror.netcologne.de/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-null-x86_64.null

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'test'.
> java.io.FileNotFoundException: http://mirror.netcologne.de/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-null-x86_64.null
akhikhl commented 10 years ago

OK, I'll have a look.

akhikhl commented 10 years ago

I looked through my code, result: config for Linux and Windows implemented, for OSX - not. Will try to fix it tomorrow.

aalmiray commented 10 years ago

I'm afraid the problem persists with version 0.0.7

gradle dependencies
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/wuff/wuff-plugin/0.0.7/wuff-plugin-0.0.7.pom
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.pom
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-eclipse2maven/0.0.12/unpuzzle-eclipse2maven-0.0.12.pom
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-utils/0.0.12/unpuzzle-utils-0.0.12.pom
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-osgi2maven/0.0.12/unpuzzle-osgi2maven-0.0.12.pom
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/wuff/wuff-plugin/0.0.7/wuff-plugin-0.0.7.jar
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.jar
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-eclipse2maven/0.0.12/unpuzzle-eclipse2maven-0.0.12.jar
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-utils/0.0.12/unpuzzle-utils-0.0.12.jar
Download http://dl.bintray.com/akhikhl/maven/org/akhikhl/unpuzzle/unpuzzle-osgi2maven/0.0.12/unpuzzle-osgi2maven-0.0.12.jar
Downloading file: http://mirror.netcologne.de/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-null-x86_64.null

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'test'.
> Failed to notify project evaluation listener.
   > http://mirror.netcologne.de/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-null-x86_64.null

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 12.02 secs

Perhaps it would be a good idea to collaborate on a branch before pushing another release? ;-)

akhikhl commented 10 years ago

You are right. I was over-confident it just works :smile:. I created a branch "macosx".

The heart of the beast is here: https://github.com/akhikhl/wuff/blob/macosx/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy This file contains all configurations for all eclipse versions.

akhikhl commented 10 years ago

This part deals with detecting current OS and current architecture: https://github.com/akhikhl/wuff/blob/macosx/libs/wuff-plugin/src/main/groovy/org/akhikhl/wuff/PlatformConfig.groovy#L46-L56 I forgot to update this part. Could you, please, have a look and give advice what should be there for Mac OS?

aalmiray commented 10 years ago

Evaluating those properties on Groovy Console results in

groovy> println System.getProperty('os.name') 
groovy> println System.getProperty('os.arch') 

Mac OS X
x86_64
akhikhl commented 10 years ago

I added these two lines: https://github.com/akhikhl/wuff/blob/macosx/libs/wuff-plugin/src/main/groovy/org/akhikhl/wuff/PlatformConfig.groovy#L51-L52

Could you, please, try it?

git clone git@github.com:akhikhl/wuff.git
cd wuff
git checkout macosx
gradle build
cd examples/RcpApp-1
gradle build
aalmiray commented 10 years ago

Looks like you may need to tweak the build files in order to locate locally built components

* Where:
Build file '/Users/aalmiray/dev/github/wuff/libs/unpuzzle/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':libs:unpuzzle'.
> Could not resolve all dependencies for configuration 'classpath'.
   > Could not find org.akhikhl.unpuzzle:unpuzzle-plugin:0.0.12.
     Searched in the following locations:
         file:/Users/aalmiray/.m2/repository/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.pom
         file:/Users/aalmiray/.m2/repository/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.jar
         http://jcenter.bintray.com/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.pom
         http://jcenter.bintray.com/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.jar
         http://repo1.maven.org/maven2/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.pom
         http://repo1.maven.org/maven2/org/akhikhl/unpuzzle/unpuzzle-plugin/0.0.12/unpuzzle-plugin-0.0.12.jar
     Required by:
         unspecified:unspecified:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.421 secs
akhikhl commented 10 years ago

Ah, this is the same as with Wuff: Unpuzzle repo is not included at jcenter yet. Temp solution:

git clone git@github.com:akhikhl/unpuzzle.git
cd unpuzzle
gradle build

then build Wuff.

akhikhl commented 10 years ago

Or just add:

buildscript {
  repositories {
    maven { url 'http://dl.bintray.com/akhikhl/maven'  }
  }
}

to wuff/build.gradle, then it should compile.

akhikhl commented 10 years ago

When scaffolding, you might see messages saying that Wuff cannot create extension points. These should be treated as warnings, not errors (scaffolding works despite of these messages). I already fixed it on Wuff master.

aalmiray commented 10 years ago

I'm afraid the error persists, even after building and installing unpuzzle (0.0.13 is the version I've got from cloning the repo)

:libs:unpuzzle:downloadEclipse
Downloading file: http://mirror.netcologne.de/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-null-x86_64.null
akhikhl commented 10 years ago

Hold on, together we will fix it :smile:. The error message means - architecture is chosen correctly, but OS is still not detected. Could you, please, insert two lines at line 53 of PlatformConfig:

println "System.getProperty('os.name') -> ${System.getProperty('os.name')}"
println "System.getProperty('os.name').equalsIgnoreCase('Mac OS X') -> ${System.getProperty('os.name').equalsIgnoreCase('Mac OS X')}"

then do gradle build on Wuff and on app? What's the message?

aalmiray commented 10 years ago

I've got the following result

System.getProperty('os.name') -> Mac OS X
System.getProperty('os.name').equalsIgnoreCase('Mac OS X') -> true
akhikhl commented 10 years ago

Good, I look further into sources.

akhikhl commented 10 years ago

I just simulated your environment by forcibly setting current_os = 'Mac OS X' at line 46 of PlatformConfig.groovy and things are working fine. The program downloads, unpacks and installs eclipse-jee-kepler-SR2-macosx-cocoa-x86_64.tar.gz. You are on gradle 2.0-rc-1, aren't you? I'll try switching to it to see if problem is related to gradle version.

akhikhl commented 10 years ago

The bug does not depend on gradle version. I tried it, Wuff works just fine with gradle 2.0-rc-1 (in my environment). Could you, please, insert the line:

 println "suffix_os=${suffix_os}, current_os=${current_os}, suffix_os[current_os]=${suffix_os[current_os]}"

at line 333 of file wuff/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy? Check: the next line must be:

source "$eclipseMirror/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-${suffix_os[current_os]}${suffix_arch[current_arch]}.${fileExt_os[current_os]}"

then do gradle build on Wuff and your app and tell me, what's the output?

aalmiray commented 10 years ago

I don't know what to tell you. The change doesn't go through. For some reason the build continues to point to the old binaries, the println statements never get executed :-(

akhikhl commented 10 years ago

Ah, that's good news :smile: Means: there's discrepancy in dependency include somewhere. We include old code and it gets executed. Let's look at the example app you were compiling:

aalmiray commented 10 years ago

I'm not even able to compile wuff at all :-( Here's the current diff based on the macosx branch

diff --git a/libs/unpuzzle/unpuzzle.plugin b/libs/unpuzzle/unpuzzle.plugin
index 98f5721..3cc9b57 100644
--- a/libs/unpuzzle/unpuzzle.plugin
+++ b/libs/unpuzzle/unpuzzle.plugin
@@ -6,7 +6,7 @@ buildscript {
   }

   dependencies {
-    classpath 'org.akhikhl.unpuzzle:unpuzzle-plugin:0.0.12'
+    classpath 'org.akhikhl.unpuzzle:unpuzzle-plugin:0.0.13'
   }
 }

diff --git a/libs/wuff-plugin/build.gradle b/libs/wuff-plugin/build.gradle
index 71ef57d..68cf89c 100644
--- a/libs/wuff-plugin/build.gradle
+++ b/libs/wuff-plugin/build.gradle
@@ -1,6 +1,11 @@
 apply from: rootProject.file('libs/common.gradle')
 apply from: rootProject.file('libs/publish.gradle')

+repositories {
+    mavenLocal()
+    jcenter()
+    maven { url 'http://dl.bintray.com/akhikhl/maven' }
+}
 dependencies {
   compile gradleApi()
   compile 'org.akhikhl.gradle-onejar:gradle-onejar:0.0.11'
diff --git a/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy b/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy
index 6276fe1..a629dec 100644
--- a/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy
+++ b/libs/wuff-plugin/src/main/resources/org/akhikhl/wuff/defaultConfig.groovy
@@ -330,6 +330,9 @@ wuff {

     sources {

+ println "suffix_os=${suffix_os}, current_os=${current_os}, suffix_os[current_os]=${suffix_os[current_os]}"
+
+
       source "$eclipseMirror/eclipse//technology/epp/downloads/release/kepler/SR2/eclipse-jee-kepler-SR2-${suffix_os[current_os]}${suffix_arch[current_arch]}.${fileExt_os[curren       source "$eclipseMirror/eclipse//eclipse/downloads/drops4/R-4.3.2-201402211700/eclipse-SDK-4.3.2-${suffix_os[current_os]}${suffix_arch[current_arch]}.${fileExt_os[current_o       source "$eclipseMirror/eclipse//eclipse/downloads/drops4/R-4.3.2-201402211700/eclipse-4.3.2-delta-pack.zip"
akhikhl commented 10 years ago

diff look fine, thank you. There are two reasons, why it doen't compile for you:

  1. there are unit-tests in wuff-plugin, that rely on eclipse being downloaded and installed, if not, they attempt to download and install eclipse.
  2. The project "libs/unpuzzle" downloads and installs eclipse plugins. If there are errors in this process, Wuff compilation stops.

Could you, please, try the following:

cd libs/wuff-plugin
gradle install

This way we skip unit-tests and "libs/unpuzzle" and just compile and install Wuff to local maven repo.

When it works, try running tasks on sample application.

akhikhl commented 10 years ago

I was able to reproduce the last error you described. The source is the following: unpuzzle contains duplicate class PlatformConfig and another configuration of repositories, that is used by wuff/libs/unpuzzle.

I am now fixing it now. I'll update when fixed code is available at github.

This is exactly the case when code duplication gets nasty and costs time. Sorry.

akhikhl commented 10 years ago

Now the error seems to be solved. Unpuzzle and Wuff compile smoothly in simulated Mac OS X environment (current_os set to "Mac OS X" instead of system property).

Could you, please, try once more? Your help is very much appretiated. Many people on Mac OS X will surely enjoy compiling Eclipse plugins and apps with gradle.

  1. please do git pull on unpuzzle and switch to "macosx" branch
  2. do git pull on wuff, stay at "macosx" branch
  3. do gradle build on unpuzzle
  4. do gradle build on wuff
  5. try scaffolding/building/running an example program from tutorial

important: unpuzzle stays on version 0.0.13. Wuff version is now 0.0.8. If your sample app uses explicit version number, please upgrade to 0.0.8.

aalmiray commented 10 years ago

That did it. I was able to invoke gradle tasks --all and gradle run on the sample RPCapp project, however there was a problem with thread access

gradle run
suffix_os=[linux:linux-gtk, macosx:macosx-cocoa, windows:win32], current_os=macosx, suffix_os[current_os]=macosx-cocoa
:compileJava
:createExtraFiles
:processResources
:classes
:createOsgiManifest
:jar
:wrapLibs
:prepareRunConfig
:run
***WARNING: Display must be created on main thread due to Cocoa restrictions.
!SESSION 2014-06-23 17:47:50.192 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Command-line arguments:  -data /Users/aalmiray/dev/github/wuff/examples/RcpApp-1/MyRcpApp/build/run -consoleLog

!ENTRY org.eclipse.osgi 4 0 2014-06-23 17:47:50.993
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4397)
    at org.eclipse.swt.SWT.error(SWT.java:4312)
    at org.eclipse.swt.SWT.error(SWT.java:4283)
    at org.eclipse.swt.widgets.Display.error(Display.java:1076)
    at org.eclipse.swt.widgets.Display.createDisplay(Display.java:833)
    at org.eclipse.swt.widgets.Display.create(Display.java:816)
    at org.eclipse.swt.graphics.Device.<init>(Device.java:130)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:707)
    at org.eclipse.swt.widgets.Display.<init>(Display.java:698)
    at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:695)
    at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162)
    at myrcpapp.Application.start(Application.java:20)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
An error has occurred. See the log file
/Users/aalmiray/dev/github/wuff/examples/RcpApp-1/MyRcpApp/build/run/.metadata/.log.
:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java'' finished with non-zero exit value 13

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I believe this is a well know problem when running SWT on OSX. You must specify an additional JVM flag -XstartOnFirstThread.

see http://stackoverflow.com/questions/8194838/how-to-execute-jar-in-mac-os-x-using-swt-eclipse

akhikhl commented 10 years ago

Great that it compiles :) could you, please, do 'build gradle' on example program, open 'build/output/appname' and add jvmarg to corresponding .sh script? Will modified script run? 23 июня 2014 г. 17:47 пользователь "Andres Almiray" < notifications@github.com> написал:

That did it. I was able to invoke gradle tasks --all and gradle run on the sample RPCapp project, however there was a problem with thread access

gradle run suffix_os=[linux:linux-gtk, macosx:macosx-cocoa, windows:win32], current_os=macosx, suffix_os[current_os]=macosx-cocoa :compileJava :createExtraFiles :processResources :classes :createOsgiManifest :jar :wrapLibs :prepareRunConfig :run ***WARNING: Display must be created on main thread due to Cocoa restrictions. !SESSION 2014-06-23 17:47:50.192 ----------------------------------------------- eclipse.buildId=unknown java.version=1.8.0_05 java.vendor=Oracle Corporation BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US Command-line arguments: -data /Users/aalmiray/dev/github/wuff/examples/RcpApp-1/MyRcpApp/build/run -consoleLog

!ENTRY org.eclipse.osgi 4 0 2014-06-23 17:47:50.993 !MESSAGE Application error !STACK 1 org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:4397) at org.eclipse.swt.SWT.error(SWT.java:4312) at org.eclipse.swt.SWT.error(SWT.java:4283) at org.eclipse.swt.widgets.Display.error(Display.java:1076) at org.eclipse.swt.widgets.Display.createDisplay(Display.java:833) at org.eclipse.swt.widgets.Display.create(Display.java:816) at org.eclipse.swt.graphics.Device.(Device.java:130) at org.eclipse.swt.widgets.Display.(Display.java:707) at org.eclipse.swt.widgets.Display.(Display.java:698) at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:695) at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162) at myrcpapp.Application.start(Application.java:20) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450) at org.eclipse.equinox.launcher.Main.main(Main.java:1426) An error has occurred. See the log file /Users/aalmiray/dev/github/wuff/examples/RcpApp-1/MyRcpApp/build/run/.metadata/.log. :run FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':run'.

    Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java'' finished with non-zero exit value 13

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I believe this is a well know problem when running SWT on OSX. You must specify an additional JVM flag -XstartOnFirstThread.

see http://stackoverflow.com/questions/8194838/how-to-execute-jar-in-mac-os-x-using-swt-eclipse

— Reply to this email directly or view it on GitHub https://github.com/akhikhl/wuff/issues/7#issuecomment-46862949.

akhikhl commented 10 years ago

Hi Andres, Sorry, was busy with other things in the mean time. News: I added -XstartOnFirstThread parameter to macosx-specific products, as well as to "run" and "debug" tasks, when current OS is Mac OS X. Could you, please, pull changes from github to wuff, "gradle build", then try example project? I would be rather thankful for the results :smile:

aalmiray commented 10 years ago

Holy Smokes! It's alive! no additional configuration was needed. I was able to run examples/RcpApp-1/MyRcpApp with just gradle run. Thank you! :smile:

akhikhl commented 10 years ago

I'm happy to hear that it works on Mac OS X as well :sun_with_face: So I do new release? Hopefully sooner than later, with growing user base and improved documentation on all features, it can get out of beta status.