tag:support.gradlefx.org,2011-05-23:/discussions/questions/12-upload-to-repositoryGradleFx: Discussion 2012-08-15T14:04:54Ztag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-11T19:02:22Z2012-06-11T19:05:45ZUpload to repository<div><p>Hi<br>
I'm new to Gradle (and GradleFx) and so far I'm liking it. I now
trying to upload the result of compilation to my local repository
(maven?, ivy? gradle? I'm not sure). Basically, I want to compile
this library project, install/upload it to my local repository so
my application (swf) project can use it as a dependency. I don't
want to use it as a subproject, because it's not.</p>
<p>Any example on how to do this? The Gradle documentation is
farely Java based and I'm not sure how stuff translates to
GradleFx.</p>
<p>Also, what does the publish task do?</p>
<p>Thanks!</p></div>Oliviertag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-11T20:12:20Z2012-06-11T20:15:00ZUpload to repository<div><p>You can do this by adding the following code to your build
file:</p>
<pre>
<code>userHome = System.getProperty("user.home")
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://{userHome}/.m2/repository/")
}
}
}</code>
</pre>
<p>Then you can install them to your local maven repository (in
your user directory) with "gradle uploadArchives"</p>
<p>The upload task just copies the content in the build directory
to a publish directory. Actually it doesn't do much useful, so we
probably should find a better cause for this task.</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-11T20:31:03Z2012-06-11T20:31:21ZUpload to repository<div><p>I've tried this snippet from the other post, but it doesn't
work. I get this error :</p>
<p><code>[ant:null] Error reading settings file
'C:\Users\ogroulx\AppData\Local\Temp\gradle_empty_settings3215823816589171383.xml'
- ignoring. Error was:
C:\Users\ogroulx\AppData\Local\Temp\gradle_empty_settings3215823816589171383.xml
(The file was not found)</code></p>
<p>And nothing is copied to the maven repo.</p>
<p>Also, mavenDeployer require <code>apply plugin : 'maven'</code>
to work. In fact, here's my configuration :</p>
<pre>
<code>buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.5'
}
}
apply plugin: 'gradlefx'
apply plugin: 'maven'
type = 'swc'
srcDirs = [
'src'
]
dependencies {
external files("lib")
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://C:/Users/ogroulx/.m2/repository/")
}
}
}</code>
</pre>
<p>Am I missing something?</p></div>Oliviertag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-11T20:57:43Z2012-06-11T20:57:43ZUpload to repository<div><p>mmm, haven't encountered this one before, but I tried it on one
of my sample projects and it's giving the same error now. Looks
like someone else is getting the same error on the Gradle forums
(not GradleFx related): <a href=
"http://forums.gradle.org/gradle/topics/_error_reading_settings_file_while_trying_simple_project_with_maven_plugin">
http://forums.gradle.org/gradle/topics/_error_reading_settings_file...</a></p>
<p>I'll post something in that thread, maybe Peter Niederwieser
knows a solution to this problem.</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T08:31:03Z2012-06-12T08:31:03ZUpload to repository<div><p>Perhaps you could give it another try with Gradle 1.0 which was
released earlier today?</p></div>Maxime Coweztag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T08:40:12Z2012-06-12T08:40:12ZUpload to repository<div><p>I'll try to track it down this evening by looking from which
Gradle version it has been going wrong.<br>
Maxime, aren't you using this same method to upload the artifacts
to your local maven repo? and is it still working for you?</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T09:12:08Z2012-06-12T09:12:08ZUpload to repository<div><p>Yep, still working fine here with the development build (which
should be the same as the 0.5 release)</p>
<hr>
<h2>Gradle 1.0-rc-3</h2>
<p>Gradle build time: Sunday, 29 April 2012 23:51:52 o'clock
UTC<br>
Groovy: 1.8.6<br>
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010<br>
Ivy: 2.2.0<br>
JVM: 1.7.0_02 (Oracle Corporation 22.0-b10)<br>
OS: Windows 7 6.1 x86</p></div>Maxime Coweztag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T12:22:15Z2012-06-12T12:22:16ZUpload to repository<div><p>I'll try with Gradle 1.0 today. The only difference with Max I
think is that I'm using Windows 7 64 bit.</p></div>Oliviertag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T12:25:24Z2012-06-12T12:25:24ZUpload to repository<div><p>mmm, I'm also using Windows 7 64 bit, so that could very well be
it.</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T12:45:23Z2012-06-12T12:45:23ZUpload to repository<div><p>Yennick, your output in the Gradle forum says Win7 x86</p></div>Maxime Coweztag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T13:56:15Z2012-06-12T13:56:15ZUpload to repository<div><p>Nope. Even with Gradle 1.0, the error still occur. From the
Gradle forum, <a href=
"http://forums.gradle.org/gradle/topics/_error_reading_settings_file_while_trying_simple_project_with_maven_plugin#reply_9139772">
bjansen has replied</a> that it's just a way of saying that the
artifact doesn't exist on the file system. I'm not sure what to do
with that.</p></div>Oliviertag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T20:24:18Z2012-06-12T20:24:18ZUpload to repository<div><p>I think I see what's going wrong. The uploadArchives task
doesn't depend anymore on the compile task (which is implemented by
GradleFx, but is a general name used by many plugins to compile
something), so it doesn't automatically execute the compile task,
which causes the artifact not being added.</p>
<p>Try this piece of code out:</p>
<pre>
<code>afterEvaluate {
uploadArchives {
dependsOn compile
repositories {
mavenDeployer {
repository(url: "file://{userHome}/.m2/repository/")
}
}
}
}</code>
</pre>
<p>The afterEvaluate statement is needed because the compile task
is only added in a later phase, so after the evaluation phase of
Gradle.<br>
Then I've defined a task dependency to the compile task, which
should make the compile task to execute before the uploadArchives
task is being executed.</p>
<p>Maybe this isn't the most optimal solution, so I'm trying to
find a better solution, but this should get you going :)</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-12T22:49:56Z2012-06-12T22:50:07ZUpload to repository<div><p>Alright, getting somewhere. The maven plugin was complaining
about the groupId being empty. I've added a <code>group</code> and
a <code>version</code> property to the build config and it worked!
Thanks!</p></div>Oliviertag:support.gradlefx.org,2011-05-23:Comment/165848742012-06-13T08:53:44Z2012-06-13T08:53:44ZUpload to repository<div><p>So why did it work for me? My guess is because I had executed
<code>gradle compile</code> manually prior to executing
<code>gradle upload</code>.</p></div>Maxime Cowez