IntelliJ and transitive dependencies in Flex projects
Hello everyone,
I have a problem with Flex projects that have transitive dependencies through their pom files.
I see that IntelliJ recreates the config-report files for such projects, and when it does it does not fetch transitive dependencies. The result of that is that projects that compile fine using Maven do not compile with IntelliJ.
Here's an example of what I mean:
Let's say we have a class structure like so C->B->A.
In projects A there is a class called "SoAndSo" and there is usage of that class in project C, but there is no dependency of A in C's pom.
When IntelliJ creates the config-report file for C it will not add a dependency in A and when compiling that project it will give an error message like "Class SoAndSo is not a compile-time constant".
What is the best way to solve this issue?
Thanks,
Guy
Please sign in to leave a comment.
Hi Guy,
we use Intellij and Maven a lot for flex development. I think I understand your setup and have this to say.
You have
1) C depends on B and B depends on A
2) C uses class SoAndSo in A
The flex config created for C should only contain a reference to B because C does not DEPEND on A.
If your class SoAndSo is not used in B then B will not contain the code for it and therefore C will not be able to find it.
This is the way SWC's and MXMLC work. You need to make C explicitly dependent on A.
Conrad WInchester
Hi and thanks for the answer.
What you said makes me wonder - Why does compilation with Maven works for those projects?
I think it is logical that when Maven compiles a SWC it includes all its classes because Maven does not know in advance which are used and which aren't.
If that is true then shouldn't IntelliJ behave the same?
Probably you've faced a bug in generating compiler config file by IDEA. What mvn and flexmojos plugin version do you use?
As a workaround run from command line mvn compile -DconfigurationReport=true for the root project - this will generate 100% correct config files. After that IDEA will be able to compile your project. Unfortunately on next mavne projects reimport IDEA will override config files by incorrect ones.
Hi Alexander and thanks for the answer,
We are using flexmojos 3.8, I'll put the plugin definition below.
The solution of creating the config-report files using maven is no good since the files maven creates points to SWCs that are located in .m2. I need the dependencies to point to that target folder of that project otherwise debugging in IntelliJ fails when I change when I change SWC projects that the SWF I am running depends upon.
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>3.8</version>
<extensions>true</extensions>
<configuration>
<licenses>
<flexbuilder3>${flex3.license}</flexbuilder3>
</licenses>
<!--sourcePaths>
<path>src/main/flex</path>
<path>src/main/resources</path>
</sourcePaths-->
<configFile>target/flex-config/flex-config.xml</configFile>
<services>target/flex-config/services-config.xml</services>
<skipTests>true</skipTests>
<configurationReport>true</configurationReport>
<ideOutputFolderPath>target</ideOutputFolderPath>
<ideOutputFolderLocation>target</ideOutputFolderLocation>
<debug>${flexmojos.maven.plugin.debug}</debug>
<targetPlayer>9.0.124</targetPlayer>
<!--enableModuleDebug>false</enableModuleDebug-->
<!--allowSourcePathOverlap>true</allowSourcePathOverlap-->
<keepAs3Metadatas>
<keepAs3Metadata>Autowired</keepAs3Metadata>
</keepAs3Metadatas>
</configuration>
<dependencies>
<dependency>
<groupId>com.adobe.flex</groupId>
<artifactId>compiler</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.flex.framework</groupId>
<artifactId>flex-framework</artifactId>
<version>${flex.sdk.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.adobe.flex.compiler</groupId>
<artifactId>license</artifactId>
<version>${flex.sdk.version}</version>
</dependency>
</dependencies>
</plugin>
If you run install goal then generated configs point to local repository (.../.m2/...), but 'mvn compile -DconfigurationReport=true' will generate configs pointing to target folders.
Nope, still directs the dependencies to .m2.
As far as I know there is no difference between install and compile in that sense, install is simply the phase that comes after compile.
Any idea when this bug will be fixed?
http://youtrack.jetbrains.net/issue/IDEA-66875 wil be fixed in 10.5 (first EAP coming soon).
Thanks for the quick answer. I'm waiting for 10.5...