If you wish to perform cross Maven module aggregate analysis on a large number of Maven modules, please setup your build using your Structure101 project file, .hsp, as follows:
- Load your Maven project into Structure101 Studio
- Publish your project to your Structure101 repository.
- Create your build configuration file, typically named structure101-conf.xml.
The following example walks through the steps using the apache-maven source code for the analysis.
First load the apache-maven source root pom.xml file into Structure101 Studio, via File -> New -> Maven -> Add root pom.
Once your project is loaded save it as pom.xml.java.hsp (or use the filename of your choice).
Once you’ve loaded your sample Maven project into Structure101 Studio you will see your Maven project in the Model view:
Now create a cross-module architecture diagram for your project before publishing your project to a Structure101 repository. For example:
To publish your project, select the 'Publish' option on the Project menu, and give your project a name, hit ‘Next’
Make sure the ‘Publish architecture’ is ticked and hit ‘Finish’
Once you have published your project to a Structure101 repository, you are now ready for configuration
Configuration for maven projects
The hsp file created above pom.xml.java.hsp should be used as local-project paramter value in root pom.xml
<plugin> <groupId>com.structure101.java</groupId> <artifactId>structure101-maven-plugin</artifactId> <version>13412</version> <configuration> <project>${project.name}</project> <breakOnError>false</breakOnError> <fail-build-on-violations>false</fail-build-on-violations> <localProject>location to .java.hsp file</localProject><overwrite>true</overwrite> <repository>${structure101repository}</repository> <arch-output-file>${structure101outputDir}\arch-violations.csv</arch-output-file> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>check-architecture</goal> </goals> </execution> </executions> </plugin>
Configuration to execute the project from command line
create your configuration file, structure101-conf.xml, that you will pass to the Structure101 Build command. This XML file must be in the same directory as the Structure101 project file you created earlier, pom.xml.java.hsp
The content of structure101-conf.xml file will look like:
<headless> <operations> <operation type="check-architecture"> <argument name="output-file" value="const(THIS_FILE)/arch-violations-java.xml" /> <argument name="onlyNew" value="false" /> <argument name="detailed" value="true"/> </operation> </operations> <arguments> <argument name="local-project" value="const(THIS_FILE)/pom.xml.java.hsp"> <override attribute="include-injected-dependency" value="false"/> </argument> <argument name="repository" value="/Users/geniusraghvendra/vss/work/structure101-repository" /> <argument name="project" value="apache-maven" /> <argument name="useBaselineExcludes" value="false"/> </arguments> </headless>
Note: “const(THIS_FILE)” indicates the pom.xml.java.hsp is relative to the structure101-conf.xml. In this instance, Structure101 Build will determine that pom.xml.java.hsp and structure101-conf.xml are in same directory.
If we look at the content of pom.xml.java.hsp file, we can see the location of the root pom file is in the same directory in which pom.xml.java.hsp is present.
Now we can perform the analysis with the following command:
For maven :mvn compile
Command line :java -jar structure101-java-build.jar structure101-conf.xml
The result of your analysis will look like: