Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Adding a sources jar to gwt {} for compileGWT #39

Closed
davepuchyr opened this issue May 22, 2014 · 6 comments
Closed

Adding a sources jar to gwt {} for compileGWT #39

davepuchyr opened this issue May 22, 2014 · 6 comments
Labels

Comments

@davepuchyr
Copy link

Thanks for your work on gwt-gradle-plugin. I am a newbie with gradle. How do I add a 3rd party source jar to the gwt {} stanza in build.gradle? I'd like to do something like below, but I can't figure out how to make it work.

gwt {
// this works...
// gwt-gradle-plugin/examples/war-using-library
src += files(project(':example-library').sourceSets.main.allJava.srcDirs) + files(project(':example-library').sourceSets.main.output.resourcesDir)

// ...this does not
// sources.jar contains 3rd party java source files
src += sources.jar
}

@steffenschaefer
Copy link
Owner

This should work:

dependencies {
    gwt files('sources.jar')
}

@davepuchyr
Copy link
Author

Thanks a lot for the quick reply. sources.jar actually originates from dependencies, so I get the error below. Any suggestions?

dependencies {
compile( [
'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0:sources',
'org.apache.oltu.oauth2:org.apache.oltu.oauth2.common:1.0.0:sources'
] )

    gwt files( 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0:sources' )

}

...
:lib:js:d3:jar UP-TO-DATE
:app:d3showcase:compileJava

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all dependencies for configuration ':app:d3showcase:gwt'.

    Cannot convert URL 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0:sources' to a file.

If I exclude the gwt entry from the dependencies stanza and then compileGWT I get
...
:app:d3showcase:compileGwt
Compiling module com.avaritia.app.d3showcase.D3Showcase
Finding entry point classes
[ERROR] Errors in 'file:/home/dave/src/gwt/app/d3showcase/src/main/java/com/avaritia/app/d3showcase/client/EntryPointImpl.java'
[ERROR] Line 89: No source code is available for type org.apache.oltu.oauth2.client.request.OAuthClientRequest; did you forget to inherit a required module?

@steffenschaefer
Copy link
Owner

This should work:

dependencies {
    gwt 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0:sources'
}

@davepuchyr
Copy link
Author

That doesn't work for me either.

In your examples I don't see any gwt entries within a dependencies stanza but I do see "src +=" adding source files in the gwt stanzas, so I'm fundamentally not understanding where sources should be added for the compileGWT task. Could you take a few minutes and add an example to the repo that uses 3rd party sources in a jar?

I sincerely appreciate the time you've already spent helping me.

@steffenschaefer
Copy link
Owner

Both things (dependencies and source) are ultimately added to the classpath when invoking GWT compiler. So technically it doesn't matter how source files are getting referenced.

There are two sources where stuff can come from:

  • From the project itself (source folders)
  • From dependencies

src is only thought to be used to define which source folders should be used by GWT. Referencing anything that is not in the scope of the same Gradle build is not the intention of this.

Everything that comes from the outside of the project should cleanly declared as dependency. Stuff that should only be seen by the Java compiler and GWT compiler but should not be part of the resulting *.war file, can be added using the "gwt" configuration.

Two counter questions:

  • What is a stanza (Sorry I'm not a native speaker)?
  • What doesn't work?

@davepuchyr
Copy link
Author

A stanza is a block of text, eg

dependencies {
compile project(':example-library')
}

or

repositories {
mavenCentral()
}

Anyway, it seems like I had something else wrong in my build.gradle file because when I tried a minimal example then

dependencies {
gwt 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.0:sources'
}

worked. Prior to this dialogue I didn't know that I could use dependencies { gwt ... }, so it was not a waste of time. Thank-you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants