Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

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

Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

alex.ruiz.05
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex

Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

Radim Kubacki
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex


Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

Szczepan Faber-2
Hey Alex,


Cheers!


On Thu, Mar 6, 2014 at 8:55 PM, Radim Kubacki <[hidden email]> wrote:
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex





--
Szczepan Faber
Principal engineer@gradle; Founder@mockito
Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

alex.ruiz.05
Thanks Radim and Szczepan. I apologize I didn't explain the problem well. What I'm saying is that I was expecting IdeaCompilerOutput to return, for example "build/classes/main" and "build/classes/tests" if I haven't configured the output directories of a project.


On Thu, Mar 6, 2014 at 12:39 PM, Szczepan Faber <[hidden email]> wrote:
Hey Alex,


Cheers!


On Thu, Mar 6, 2014 at 8:55 PM, Radim Kubacki <[hidden email]> wrote:
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex





--
Szczepan Faber
Principal engineer@gradle; Founder@mockito

Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

Radim Kubacki
No worry. I think I see where you are going.

Gradle doesn't know and doesn't care what is the default output directory for project or for module. It only adds this information to its Idea model if it is told that the output location should be customized. That's all what is needed to generate IDEA project and module files offline or to build a model that will be used through toolingApi to synchronize Gradle project with IntelliJ's project.


On Thu, Mar 6, 2014 at 11:27 PM, Alex Ruiz <[hidden email]> wrote:
Thanks Radim and Szczepan. I apologize I didn't explain the problem well. What I'm saying is that I was expecting IdeaCompilerOutput to return, for example "build/classes/main" and "build/classes/tests" if I haven't configured the output directories of a project.


On Thu, Mar 6, 2014 at 12:39 PM, Szczepan Faber <[hidden email]> wrote:
Hey Alex,


Cheers!


On Thu, Mar 6, 2014 at 8:55 PM, Radim Kubacki <[hidden email]> wrote:
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex





--
Szczepan Faber
Principal engineer@gradle; Founder@mockito


Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

Daz DeBoer-2

Just to clarify: it's intentional that the idea output dirs and the gradle classes dirs are not shared. Trying to share compiler output has proved problematic.
Is that what you're trying to achieve?

On 7 Mar 2014 02:55, "Radim Kubacki" <[hidden email]> wrote:
No worry. I think I see where you are going.

Gradle doesn't know and doesn't care what is the default output directory for project or for module. It only adds this information to its Idea model if it is told that the output location should be customized. That's all what is needed to generate IDEA project and module files offline or to build a model that will be used through toolingApi to synchronize Gradle project with IntelliJ's project.


On Thu, Mar 6, 2014 at 11:27 PM, Alex Ruiz <[hidden email]> wrote:
Thanks Radim and Szczepan. I apologize I didn't explain the problem well. What I'm saying is that I was expecting IdeaCompilerOutput to return, for example "build/classes/main" and "build/classes/tests" if I haven't configured the output directories of a project.


On Thu, Mar 6, 2014 at 12:39 PM, Szczepan Faber <[hidden email]> wrote:
Hey Alex,


Cheers!


On Thu, Mar 6, 2014 at 8:55 PM, Radim Kubacki <[hidden email]> wrote:
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex





--
Szczepan Faber
Principal engineer@gradle; Founder@mockito


Reply | Threaded
Open this post in threaded view
|

Re: Question about IdeaModule/IdeaCompilerOutput behavior (Android Studio-related)

alex.ruiz.05
More or less, yes, but that was not intentional. This is how we are doing things Android Studio land:

- User has Gradle-based Android project, opens it in Studio
- Studio queries Gradle for the IdeaProject model of the project
- We use that model only to have a notion of how many modules (in IDEA terminology) the project has

Things get interesting when we have multi-project setup. Some projects may be Android projects, some may be only Java libraries. For the Java libraries I was hoping to use the information in IdeaModel (and IdeaCompilerOutput) to set up the module.

My intention with this thread was to have a better understanding of the expected behavior in Gradle. If the expected behavior is what Radim mentioned, that is perfectly fine and I can see why. Now that I understand it is not a bug in Gradle (I had the wrong set of expectations,) I can get what I'm looking for from IDEA :-)

Thanks everybody for the help!
-Alex

On Fri, Mar 7, 2014 at 7:03 AM, Daz DeBoer <[hidden email]> wrote:

Just to clarify: it's intentional that the idea output dirs and the gradle classes dirs are not shared. Trying to share compiler output has proved problematic.
Is that what you're trying to achieve?

On 7 Mar 2014 02:55, "Radim Kubacki" <[hidden email]> wrote:
No worry. I think I see where you are going.

Gradle doesn't know and doesn't care what is the default output directory for project or for module. It only adds this information to its Idea model if it is told that the output location should be customized. That's all what is needed to generate IDEA project and module files offline or to build a model that will be used through toolingApi to synchronize Gradle project with IntelliJ's project.


On Thu, Mar 6, 2014 at 11:27 PM, Alex Ruiz <[hidden email]> wrote:
Thanks Radim and Szczepan. I apologize I didn't explain the problem well. What I'm saying is that I was expecting IdeaCompilerOutput to return, for example "build/classes/main" and "build/classes/tests" if I haven't configured the output directories of a project.


On Thu, Mar 6, 2014 at 12:39 PM, Szczepan Faber <[hidden email]> wrote:
Hey Alex,


Cheers!


On Thu, Mar 6, 2014 at 8:55 PM, Radim Kubacki <[hidden email]> wrote:
Hello Alex,

I am not sure what you want to achieve / why you want to access these values. What I think is the expected behavior here is:

- no inheritOutputDirs or true creates .iml saying that output dirs are inherited from project settings
- inheritOutputDirs set to false and no output dirs will tell IDEA to use project specific output dirs and IDEA or user will set exact location
- inheritOutputDirs set to false and output dirs tells IDEA that this module should use specific dirs for its outputs.

IMO if you are looking for classes from some library inside your AS plugin you should be able to query IJ API. And if they should be separated from classes built by android project/library then set inheritOutputDirs to false and optionally specify folders.

-Radim


On Thu, Mar 6, 2014 at 7:44 PM, Alex Ruiz <[hidden email]> wrote:
Greetings,

In Android Studio we set up a Gradle-based Android project by first getting the structure of the project from Gradle (IDEA's infrastructure gets a org.gradle.tooling.model.idea.IdeaProject using the Gradle tooling API.)

We currently have a problem when setting up Java-only library modules (non-Android.) The problem is that when we get an IdeaCompilerOutput from an IdeaModule, the output paths are null. The only way I can get it return a value is by adding this to a build.gradle file:

apply plugin: 'idea'

idea {
    module {
        inheritOutputDirs = false
        outputDir = file('muchBetterOutputDir')
        testOutputDir = file('muchBetterTestOutputDir')
    }
}

Even setting up the output path in the Gradle Java plug-in as follows:

sourceSets.main.output.classesDir = file('muchBetterClassesDir')

has no effect on IdeaCompilerOutput.

Is this the expected behavior? I originally thought this was a bug, but if this the expected behavior, and given that there is no Java model (like the Android model the Android plug-in provides,) what would make more sense:
1. Us writing our own Java model (IntelliJ already has something like this and we could extend it,)
or
2. Have this functionality provided by Gradle
?

Many thanks in advance,
-Alex





--
Szczepan Faber
Principal engineer@gradle; Founder@mockito