Discussion:
War plugin question
Jefferson Magno Solfarello
13 years ago
Permalink
Hi guys, I have a question related to the War plugin.

My war project depends on another (path: ':bp.jars', configuration:
'search') at compile time.
It also needs the jar files on the lib dir of generated war file.

The documentation says "All the dependencies of the runtime configuration
are copied to WEB-INF/lib".
But I tried the following, without success (the jars were not been included
into the generated war file):

dependencies {
providedCompile project(path: ':bp.jars', configuration: 'search')
runtime project(path: ':bp.jars', configuration: 'search')
}

After many tries, It is now working when I use:

dependencies {
compile project(path: ':bp.jars', configuration: 'search')
}

Why the jars are not included when I use runtime configuration, but are
included when I use compile configuration?

Thanks a lot,

Jefferson
Rene Groeschke
13 years ago
Permalink
Hi Jefferson,
your dependency isn't added to the war because you declared it as
providedCompile and runtime dependency. You should avoid to declare the
same dependency for two scopes. Behind the scenes, gradle filters every
dependency that is declared as providedCompile dependency when the war
is created. Since your runtime dependency is exactly the same as your
providedCompile dependency. Normally there is no reason for adding your
dependency as providedCompile and Runtime. Instead you should just add
it as "compile" dependency.

regards,
René
--
--
Rene Groeschke
@breskeby

Principal Engineer,
Gradleware Inc. - Gradle Training, Support, Consulting
rene.groeschke-***@public.gmane.org
http://gradleware.com
...
Jefferson Magno Solfarello
13 years ago
Permalink
Hi René, thanks for the clarification! That is exactly what worked for me!

If you don't mind, I have another quick question: when I run two times the
task uploadArchives on a war project, I can notice that all the previous
tasks are UP-TO-DATE but it looks that the uploadArchives is always
executed.

Is there a reason for that? If the war task is UP-TO-DATE, is there a way
to skip the execution of uploadArchives?

Thanks a lot,

Jefferson
...
Rene Groeschke
13 years ago
Permalink
Hello Jefferson,
have a look at Gradle DSL Documentation at
http://gradle.org/docs/current/dsl/index.html. There you can find a
chapter about Gradle Tasks
(http://gradle.org/docs/current/dsl/org.gradle.api.Task.html). You can
use the onlyIf and didWork properties to skip the uploadArchives task
when the war is up-to-date:

--------------
uploadArchives {
onlyIf { war.didWork }
}
--------------

regards,
René
--
--
Rene Groeschke
@breskeby

Principal Engineer,
Gradleware Inc. - Gradle Training, Support, Consulting
rene.groeschke-***@public.gmane.org
http://gradleware.com
...
Rene Groeschke
13 years ago
Permalink
BTW. The gradle forum at http://forums.gradle.org provides broader
support of the gradle community then this mailinglist.

regards,
René
...
Jefferson Magno Solfarello
13 years ago
Permalink
Great!

Thanks again.

Jefferson
...
Jefferson Magno Solfarello
13 years ago
Permalink
Hi,

I am using successfully the following code snippet on my WAR projects:

uploadArchives {
onlyIf { war.didWork }
}

That way, I don't upload the artifacts to the repository in case the WAR
file hasn't changed.

Now I am generating an EAR file that includes the generated WAR and a
manifest file.

So ... if I put something dynamic on the manifest file, like a version
number, the ear task is always executed.

But I just want to generate a new EAR (with a new version) if the dependent
WAR (other project) has changed.

Is there a way to know (programmatically) if any task (let's say the
uploadArchives) of any dependency got executed?
I would like to use it in a similar way I do with the code snippet above.

Thanks in advance for any help.

Jefferson




I have another question,



Em 15 de fevereiro de 2012 16:21, Jefferson Magno Solfarello <
...
Loading...