Comments (6)
Stefen,
Looking at this issue:
This seems possible, can you please post an example (or update the docs)?
Thanks.
from gwt-gradle-plugin.
Ideally you would refactor your project into a multi module project so that you actually have a client, shared and server project each with its own build file. This would also separate the classpath so your GWT libraries do not interference with server libraries anymore.
I guess that would be a good additional example.
from gwt-gradle-plugin.
Yeah .. I figured that too, but I do not want the plug-in to force me to do
that. I added a comment to the issue, which seems to indicate a easier way
of doing it, but expect Steffen to comment too.
On Wed, May 14, 2014 at 8:51 AM, Jens Nehlmeier [email protected]:
Ideally you would refactor your project into a multi module project so
that you actually have a client, shared and server project each with its
own build file. This would also separate the classpath so your GWT
libraries do not interference with server libraries anymore.I guess that would be a good additional example.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-43098794
.
/ Hristo Stoyanov
from gwt-gradle-plugin.
About the first part (excluding server from GWT compilation): This isn't possible as the GWT compiler only gets the sources as part of the classpath. The classpath can only contain folders or jar files. The folders must contain valid java packages, so you can't simply reference a subpackage only.
About the second part (excluding client stuff from Java compilation): Here you go:
http://forums.gradle.org/gradle/topics/how_can_i_configure_certain_java_files_not_to_be_compiled
From my personal view, I would never want the client code to be excluded from Java compilation for the following reasons:
- Compiler checks + Lint tooling that needs class files
- Unit tests testing client code need those class files
- Dev Mode needs class files (I don't think it compiles the classes by itselves) -> ok this one will be obsolete with Super Dev Mode
So let's come to alternative solutions ... You either have to introduce separate projects (You already said you don't want to do this) for each of the parts or put them in separate sourceSets:
There are several facets of solving this. To make it as simple as possible, let's think about one thing: The only part that should be handled by both (GWT compiler and should be included in the war file) is the shared stuff. so let's put this into src/main/java.
For the other two we need additional sourceSets:
sourceSets {
client {
java {
srcDir 'src/client/java' // I'm not sure if it's necessary to do this explicitly
}
compileClasspath = sourceSets.main.compileClasspath + sourceSets.main.output
}
server {
java {
srcDir 'src/server/java' // I'm not sure if it's necessary to do this explicitly
}
compileClasspath = sourceSets.main.compileClasspath + sourceSets.main.output
}
}
Both sourceSets depend on the main sourceSet as both only compile with the shared stuff being available.
To add the server classes to the war, you need:
war {
classpath sourceSets.server.output
}
For GWT you need to add the client sources:
gwt {
src += sourceSets.client.allJava.srcDirs
}
To make all GWT tasks to work as expected you should also need something like this:
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
dependsOn tasks.compileClientJava
classpath += sourceSets.server.output
}
I can't test this by now so this is all untested code. But I think it should lead to a working solution with proper separation and up to date checks but without separate projects.
I hope this helps.
from gwt-gradle-plugin.
Thanks a lot, Steffen! I will give it a try ...but you see my pain: if i
change a class I'm my server folder/package, there is no need to do get
launch GWT compilation...
/Hristo Stoyanov
About the first part (excluding server from GWT compilation): This isn't
possible as the GWT compiler only gets the sources as part of the
classpath. The classpath can only contain folders or jar files. The folders
must contain valid java packages, so you can't simply reference a
subpackage only.
About the second part (excluding client stuff from Java compilation): Here
you go:
http://forums.gradle.org/gradle/topics/how_can_i_configure_certain_java_files_not_to_be_compiled
From my personal view, I would never want the client code to be excluded
from Java compilation for the following reasons:
- Compiler checks + Lint tooling that needs class files
- Unit tests testing client code need those class files
- Dev Mode needs class files (I don't think it compiles the classes by
itselves) -> ok this one will be obsolete with Super Dev Mode
So let's come to alternative solutions ... You either have to introduce
separate projects (You already said you don't want to do this) for each of
the parts or put them in separate sourceSets:
There are several facets of solving this. To make it as simple as possible,
let's think about one thing: The only part that should be handled by both
(GWT compiler and should be included in the war file) is the shared stuff.
so let's put this into src/main/java.
For the other two we need additional sourceSets:
sourceSets {
client {
java {
srcDir 'src/client/java' // I'm not sure if it's necessary
to do this explicitly
}
compileClasspath = sourceSets.main.compileClasspath +
sourceSets.main.output
}
server {
java {
srcDir 'src/server/java' // I'm not sure if it's necessary
to do this explicitly
}
compileClasspath = sourceSets.main.compileClasspath +
sourceSets.main.output
}
}
Both sourceSets depend on the main sourceSet as both only compile with the
shared stuff being available.
To add the server classes to the war, you need:
war {
classpath sourceSets.server.output
}
For GWT you need to add the client sources:
gwt {
src += sourceSets.client.allJava.srcDirs
}
To make all GWT tasks to work as expected you should also need something
like this:
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
dependsOn tasks.compileClientJava
classpath += sourceSets.server.output
}
I can't test this by now so this is all untested code. But I think it
should lead to a working solution with proper separation and up to date
checks but without separate projects.
I hope this helps.
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/33#issuecomment-43117057
.
from gwt-gradle-plugin.
I have a project in which I tried to write such a "3-in-1" build file. I have defined the source sets a bit different, so maybe thats useful for you too:
sourceSets {
client.java.srcDirs = ['src'] // replaces standard src/main/java with src
client.java.include 'com/example/app/client/**/*'
// maybe use main.java instead to reuse the main source set.
shared.java.srcDirs = ['src']
shared.java.include 'com/example/app/shared/**/*'
server.java.srcDirs = ['src']
server.java.include 'com/example/app/server/**/*'
}
dependencies {
// All dependencies for project import in IDEs
compile configurations.clientCompile
compile configurations.serverCompile
// Dependencies defined per "sub module" for proper compilation
clientCompile ... // dependencies for client/gwt compilation tasks
serverCompile ... // dependencies for server related tasks
}
Later on you can merge client + shared (gwt compilation) and shared + server source sets (build server war) depending on the task. You also have separate dependencies which allows to configure a task with just the classpath it needs, e.g. gwt compilation does not need server dependencies.
I haven't finished the build file because I switched to a multi module project but I think you get the idea. It is pretty similar to Steffen's approach.
from gwt-gradle-plugin.
Related Issues (20)
- [gwt 2.7.0/gradle 2.12./plug-in 0.6] gwtSuperDev - java.lang.OutOfMemoryError HOT 8
- [GWT 2.8/Pluging 0.6] Issue with gwt sub-projects HOT 1
- [GWT 2.8-SNAPSHOT/Gradle 2.13] Properties issue HOT 5
- Make gwt-unitcache and war directories configurable
- gwt + gradle + lombok issues resolved
- Have any way to generate i18n and generateAsync supported by gwt-maven-plugin? HOT 6
- vaadinCompile issue, with vaadin 8 at 1.0 version
- compileGwt is missing module descriptor of a submodule on classpath HOT 8
- Make the compile tasks cacheable
- Missing support for Gradle Composite Builds
- Gradle ... single directory for all classes .. is scheduled to be removed in Gradle 5.0 HOT 1
- gwt-gradle-plugin uses deprecated api by Gradle 4.0 HOT 3
- Updated GPE Changes Property Variables
- GenerateGdt Task Needs To Also Be a Dependency of eclipseWtp
- Gradle upgrade to 5.4 causes build failure HOT 3
- CreateProcess error=206, The filename or extension is too long HOT 1
- Buildship Support HOT 1
- Has this plug-in been tested with GWT 2.8.Beta? HOT 2
- Integreation with Gretty plugin
- example build failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwt-gradle-plugin.