Little feature request: "getBuildDir" in GradleProject

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Little feature request: "getBuildDir" in GradleProject

alex.ruiz.05
Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

Many thanks,
-Alex
Reply | Threaded
Open this post in threaded view
|

RE: Little feature request: "getBuildDir" in GradleProject

Magnus Rundberget-3
Hi !

If you are impatient you could do it by using a custom model :-) It's not that hard (check out the tooling-api samples with the all distribution).

I've done something related for a groovy/gradle plugin for Light Table.
Highlights:
1. Created a simple plugin project (https://github.com/rundis/generic-gradle-model)
2. Add dependency to plugin from my project using the tooling-api 
3. Retrieve custom model through tooling api, apply the custom plugin through a init script (see sample code below)
4. Enjoy retrieving the richness of the gradle project model to you hearts desire ! :-)


Get model
this.genericModel = con.action(new GetGenericModelAction())
                            .withArguments("--init-script", new File("lib/lt-project-init.gradle").absolutePath)
                            .addProgressListener(listener)
                            .run()

private static class GetGenericModelAction implements Serializable, BuildAction<GenericModel> {
        @Override
        GenericModel execute(BuildController controller) {
            controller.getModel(GenericModel)
        }
    }


Sample init script:
initscript {
    repositories {
        maven {
            url 'http://dl.bintray.com/rundis/maven'
        }
    }
    dependencies { classpath "no.rundis.gradle:generic-gradle-model:0.0.1" }
}

allprojects {
    apply plugin: org.gradle.tooling.model.generic.GenericGradleModelPlugin
}



cheers
Magnus



Date: Tue, 10 Jun 2014 07:37:14 -0700
From: [hidden email]
To: [hidden email]
Subject: [gradle-dev] Little feature request: "getBuildDir" in GradleProject

Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

Many thanks,
-Alex
Reply | Threaded
Open this post in threaded view
|

Re: Little feature request: "getBuildDir" in GradleProject

Radim Kubacki
In reply to this post by alex.ruiz.05
Hi,

generally I'd agree with Magnus. You can use your own model for this purpose. There is at least one big advantage to this: your model can work with older Gradle releases. I think if we add this to GradleProject we won't be able to adapt instances obtained from older providers to give you that information. 

I'd like to see that information available for example to implement http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-queries/org/netbeans/spi/queries/SharabilityQueryImplementation.html in NetBeans plugin). Adding this to BasicGradleProject can be OK. It seems simple enough and we want to keep its related model ligthweight.

Some other comments below.

On Tue, Jun 10, 2014 at 4:37 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

I am not sure why you need to do this. Can you be more specific?
 
Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

http://www.gradle.org/docs/release-candidate/javadoc/org/gradle/tooling/model/idea/IdeaModule.html#getCompilerOutput() doesn't return $project.buildDir It only returns values that can be customized as shown in http://www.gradle.org/docs/release-candidate/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html It means if you want to know where are classes compiled by IDEA stored it can be better to query IDEA project APIs directly. If you need to know where Gradle puts output files you need this API.

Perhaps if you can point us to your bug reports we can find some good way how to solve this. 

-Radim

Many thanks,
-Alex

Reply | Threaded
Open this post in threaded view
|

Re: Little feature request: "getBuildDir" in GradleProject

alex.ruiz.05
Thanks a lot for the responses!

Here are some comments:

1. We are obtaining buildDir from a custom model that IDEA applies to projects using --init-script when importing a project. I agree that writing models is easy, because I made the modifications to that model. The problem is that seems not reliable on Windows 8.1 (according to reports.)
2. The Android Gradle plug-in provides a model that exposes "buildDir." The issue are projects that are not Android projects: 1. Java library projects and 2. The top-level project
3. It is already non-trivial to create Android applications, asking users to add yet another plug-in to their build files, just to obtain "buildDir" seems an overkill.

Ideally, #1 would work, but unfortunately, doesn't. GradleProject, or even better, BasicGradleProject seem to be the natural home for this property.

The reason we need to get to buildDir is that in this directory is where we have the "exploded" AAR files (Android archives, like jars but with Android-specific information.) All the common libraries are expanded there, and that folder, inside buildDir, needs to be not-excluded.

Regards,
-Alex


On Tue, Jun 10, 2014 at 9:31 AM, Radim Kubacki <[hidden email]> wrote:
Hi,

generally I'd agree with Magnus. You can use your own model for this purpose. There is at least one big advantage to this: your model can work with older Gradle releases. I think if we add this to GradleProject we won't be able to adapt instances obtained from older providers to give you that information. 

I'd like to see that information available for example to implement http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-queries/org/netbeans/spi/queries/SharabilityQueryImplementation.html in NetBeans plugin). Adding this to BasicGradleProject can be OK. It seems simple enough and we want to keep its related model ligthweight.

Some other comments below.

On Tue, Jun 10, 2014 at 4:37 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

I am not sure why you need to do this. Can you be more specific?
 
Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

http://www.gradle.org/docs/release-candidate/javadoc/org/gradle/tooling/model/idea/IdeaModule.html#getCompilerOutput() doesn't return $project.buildDir It only returns values that can be customized as shown in http://www.gradle.org/docs/release-candidate/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html It means if you want to know where are classes compiled by IDEA stored it can be better to query IDEA project APIs directly. If you need to know where Gradle puts output files you need this API.

Perhaps if you can point us to your bug reports we can find some good way how to solve this. 

-Radim

Many thanks,
-Alex


Reply | Threaded
Open this post in threaded view
|

Re: Little feature request: "getBuildDir" in GradleProject

Radim Kubacki

On Tue, Jun 10, 2014 at 8:07 PM, Alex Ruiz <[hidden email]> wrote:
Thanks a lot for the responses!

Here are some comments:

1. We are obtaining buildDir from a custom model that IDEA applies to projects using --init-script when importing a project. I agree that writing models is easy, because I made the modifications to that model. The problem is that seems not reliable on Windows 8.1 (according to reports.)

Can you try to narrow down why this is not working properly and fix this IDEA model? What if we fall into the same problem?
 
2. The Android Gradle plug-in provides a model that exposes "buildDir." The issue are projects that are not Android projects: 1. Java library projects and 2. The top-level project

Right, that makes sense.
 
3. It is already non-trivial to create Android applications, asking users to add yet another plug-in to their build files, just to obtain "buildDir" seems an overkill.

Just add this plugin in another init script. You do not have to tell people to put it into their project nor to distribute it through some central repository. 

Ideally, #1 would work, but unfortunately, doesn't. GradleProject, or even better, BasicGradleProject seem to be the natural home for this property.

I agree but it can lock you to 2.1 or 2.0 in the best.
 
The reason we need to get to buildDir is that in this directory is where we have the "exploded" AAR files (Android archives, like jars but with Android-specific information.) All the common libraries are expanded there, and that folder, inside buildDir, needs to be not-excluded.

You are looking for "exploded AAR" in non-Android projects? Interesting. 

Regards,
-Alex



On Tue, Jun 10, 2014 at 9:31 AM, Radim Kubacki <[hidden email]> wrote:
Hi,

generally I'd agree with Magnus. You can use your own model for this purpose. There is at least one big advantage to this: your model can work with older Gradle releases. I think if we add this to GradleProject we won't be able to adapt instances obtained from older providers to give you that information. 

I'd like to see that information available for example to implement http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-queries/org/netbeans/spi/queries/SharabilityQueryImplementation.html in NetBeans plugin). Adding this to BasicGradleProject can be OK. It seems simple enough and we want to keep its related model ligthweight.

Some other comments below.

On Tue, Jun 10, 2014 at 4:37 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

I am not sure why you need to do this. Can you be more specific?
 
Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

http://www.gradle.org/docs/release-candidate/javadoc/org/gradle/tooling/model/idea/IdeaModule.html#getCompilerOutput() doesn't return $project.buildDir It only returns values that can be customized as shown in http://www.gradle.org/docs/release-candidate/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html It means if you want to know where are classes compiled by IDEA stored it can be better to query IDEA project APIs directly. If you need to know where Gradle puts output files you need this API.

Perhaps if you can point us to your bug reports we can find some good way how to solve this. 

-Radim

Many thanks,
-Alex



Reply | Threaded
Open this post in threaded view
|

Re: Little feature request: "getBuildDir" in GradleProject

Xavier Ducrohet



On Tue, Jun 10, 2014 at 12:26 PM, Radim Kubacki <[hidden email]> wrote:

On Tue, Jun 10, 2014 at 8:07 PM, Alex Ruiz <[hidden email]> wrote:
Thanks a lot for the responses!

Here are some comments:

1. We are obtaining buildDir from a custom model that IDEA applies to projects using --init-script when importing a project. I agree that writing models is easy, because I made the modifications to that model. The problem is that seems not reliable on Windows 8.1 (according to reports.)

Can you try to narrow down why this is not working properly and fix this IDEA model? What if we fall into the same problem?
 
2. The Android Gradle plug-in provides a model that exposes "buildDir." The issue are projects that are not Android projects: 1. Java library projects and 2. The top-level project

Right, that makes sense.
 
3. It is already non-trivial to create Android applications, asking users to add yet another plug-in to their build files, just to obtain "buildDir" seems an overkill.

Just add this plugin in another init script. You do not have to tell people to put it into their project nor to distribute it through some central repository. 

Ideally, #1 would work, but unfortunately, doesn't. GradleProject, or even better, BasicGradleProject seem to be the natural home for this property.

I agree but it can lock you to 2.1 or 2.0 in the best.
 

This is really not a problem for us. We are in pre-1.0 and plan to use things showing up in 2.x as they come so we'll almost always require the latest Gradle as our min requirement.
 
The reason we need to get to buildDir is that in this directory is where we have the "exploded" AAR files (Android archives, like jars but with Android-specific information.) All the common libraries are expanded there, and that folder, inside buildDir, needs to be not-excluded.

You are looking for "exploded AAR" in non-Android projects? Interesting. 


Not really. What happens is that you can have 2 different modules that each depend on the same aar. They both need to unarchive it somewhere. It used to be done in each project, take redundant space, and doing the unzipping twice. We are now using the root project's buildDir as a shared location for this unarchived aar.

I was actually surprised to see that default Gradle project with no plugin applied have no 'clean' task (they do have a buildDir though, but nothing to clean it).

It's a temp situation hopefully, I'm hoping we'll get a better way to handle these one day in Gradle, but for now we need this.
 
Regards,
-Alex



On Tue, Jun 10, 2014 at 9:31 AM, Radim Kubacki <[hidden email]> wrote:
Hi,

generally I'd agree with Magnus. You can use your own model for this purpose. There is at least one big advantage to this: your model can work with older Gradle releases. I think if we add this to GradleProject we won't be able to adapt instances obtained from older providers to give you that information. 

I'd like to see that information available for example to implement http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-queries/org/netbeans/spi/queries/SharabilityQueryImplementation.html in NetBeans plugin). Adding this to BasicGradleProject can be OK. It seems simple enough and we want to keep its related model ligthweight.

Some other comments below.

On Tue, Jun 10, 2014 at 4:37 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

We recently discovered a bug in Android Studio we need to "unexclude" (in IDEA terminology) some folders inside the "buildDir" folder in the top-level project. The problem is that the Gradle model APIs do not expose the location of "buildDir".

I am not sure why you need to do this. Can you be more specific?
 
Would it be possible to add "getBuildDir" to org.gradle.tooling.model.GradleProject for Gradle 2.0? pretty please? :-) Having this information will solve this and another related issues (that we discovered a few days ago.)

Or is there another way to obtain this information?

I'm so sorry for the last-minute request, we were obtaining this information from an IDEA model, but it seems that this is not reliable, according to user reports.

http://www.gradle.org/docs/release-candidate/javadoc/org/gradle/tooling/model/idea/IdeaModule.html#getCompilerOutput() doesn't return $project.buildDir It only returns values that can be customized as shown in http://www.gradle.org/docs/release-candidate/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html It means if you want to know where are classes compiled by IDEA stored it can be better to query IDEA project APIs directly. If you need to know where Gradle puts output files you need this API.

Perhaps if you can point us to your bug reports we can find some good way how to solve this. 

-Radim

Many thanks,
-Alex