The IDEA gradle import creates module compile output paths that are different to the gradle build output paths. Structure101 Workspace uses the IDEA module compile output paths to find the bytecode. So, running a gradle build will not propagate changes to the code into the Structure Map.

A workaround is to run the IDEA build to generate bytecode into the module compile output paths. But this only works if the setting “Delegate IDE build/run actions to gradle” (under Project Settings | Build, Execution, Deployment | Build Tools | Gradle | Runner) is unchecked. And it is not ideal since there are two sets of bytecode generated.

An alternative solution is to use the gradle Idea plugin to override the module compile output paths when the project is imported into IDEA.

Add the following to the root build.gradle file: –
(Use directory names appropriate for your gradle build)

apply plugin: 'idea'

subprojects {
  idea {
   module {
     outputDir file("$buildDir/classes/java/main")
     testOutputDir file("$buildDir/classes/java/test")
     inheritOutputDirs = false

Import your gradle project into IDEA in the usual way. You can use either the file or folder based format for the project

If you check “Create separate module per source root” in the import dialog the import will create IDEA modules for each source root in the  gradle module. The module names will be suffixed, usually with _main and _test. Having separate modules for test code is useful when extracting modules from the monolith. (After the import completes you can toggle this setting off and on in the gradle settings dialog)

The separate test modules allow the test code to be excluded from the Structure Map by adding excludes in the Structure101 Workspace settings dialog (<module_name>.*). This patterns excludes the code and the module from the Structure Map.

After import the module compile output paths will be set to the gradle output paths that you added to the build.gradle file. Building with gradle at the command line will now update the bytecode that Workspace is referencing.

If you wish to trigger the gradle build using the IDEA build commands the “Delegate IDE build/run actions to gradle” setting can be checked.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.