The Structure101 Key Measures can be reported via SonarQube. The configuration to do this is straight forward and can re-use an existing Structure101 Build configuration file.

It is assumed that SonarQube Scanner is already configured within your gradle build.

The plugin is installed by copying the sonar-structure101-plugin.jar file to the SonarQube extensions/plugins folder and restarting the SonarQube daemon.

The plugin is configured by adding to the existing SonarQube properties in the project’s gradle configuration.

If you have an existing Structure101 Build configuration file this can be used by the plugin.

sonarqube {
    properties {
        property "sonar.projectName", "Example Project"
        property "sonar.projectKey", "$project.group:$project.name"
        property "sonar.language", "java"
        <snip>
        property "structure101.java.disabled", "false"
        property "structure101.java.headless.config", "$rootDir/structure101-build-conf.xml"
    }
}

The plugin will use the class path, Structure101 Repository location and Structure101 project name defined in the configuration file. The Structure Spec and Architecture Diagrams in the Repository project are used during the plugin analysis in the same way they are used in the Structure101 Build process.

 

Note that defining the structure101.java.classpath property does not allow each class path entry to be associated with a module name. If you are using Structure101 Workspace and Studio projects created from a Workspace .hsw file it is recommended that you use a Build configuration file. The class path defined in the configuration file allows each entry to be associated with a module name.

This class path is either an override defined in the configuration file or the class path of the Studio project referenced in the configuration file. (See this post for details)

Where there is no existing Structure101 Build configuration file and the module naming is not required then the classpath, project and repository location properties should be used.

sonarqube {
    properties {
        property "sonar.projectName", "Example Project"
        property "sonar.projectKey", "$project.group:$project.name"
        property "sonar.language", "java"
        <snip>
        property "structure101.java.disabled", "false"
        property "structure101.java.project", "My Application"
        property "structure101.java.repository", "c:/my-repository"
        property "structure101.java.classpath", "$rootDir/project1/build/classes/java/main/;$rootDir/project2/...”
    }
}

Turn Off Sub-Projects in Multi-Project Builds

It is not necessary to run the Structure101 analysis on the individual sub-projects. It should be disabled using the structure101.java.disabled property. This will save unnecessary processing during  your build.

subprojects {
    sonarqube {
        properties {
            property "structure101.java.disabled", true
        }
    }
}

Structure101 Measures

The Structure101 Key Measures can be viewed in the SonarQube web application’s Measures page

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.