As part of Structure101 it is possible to check for (optionally only new) architecture violations prior to publishing, and if any (optionally only new) violations are found, an exception can be raised to break the build and hence abort the publish to the repository.

The check-architecture operation is used when you wish to enforce the defined architecture in a continuous build environment.

Example XML file to perform the operation:

<?xml version="1.0" encoding="UTF-8"?>
<headless version="1.0">
    <operations>
        <operation type="check-architecture">
            <argument name="output-dir" value="const(THIS_FILE)/arch-violations"/>
            <argument name="onlyNew" value="true"/>
            <argument name="check-unassociated" value="true"/>
            <argument name="fail-on-violations" value="false"/>
            <argument name="identifier-on-violation" value="Structure101 new Architecture violation found"/>
        </operation>
    </operations>
    <arguments>
        <argument name="local-project" value="C:\Documents and Settings\user\project.java.hsp">
            <override attribute="classpath" value="C:\classes-to-parse"/>
        </argument>
        <argument name="repository" value="C:\repository"/>
        <argument name="project" value="project"/>
    </arguments>
</headless>    
   

Available arguments include:

Argument Required Description
repository yes The path to the Structure101 Studio repository root directory (where architecture diagrams have been published to), e.g. c:/repository, /home/usr/x/repository, or, if remote, http://<servernameorip><:portno>/s101cpp/data.
project yes The name of the project in the repository (where architecture diagrams have been published to)
local-project no See project-spec.
output-file no File to which architecture violations are recorded. Stored in CSV format. This can be a relative or absolute path.
output-dir no Path to the directory where the XML files: violations.xml and diagrams.xml, and images representing the state of each Architecture diagram are written. This can be a relative or absolute path.
onlyNew no If set to true then the baseline is checked before reporting an item as unassociated. Otherwise all unassociated items in the Architecture diagrams are reported including any new ones.
baseline no If baseline is entered, then the snapshot with that label will be used to determine which violations are new. If not entered, then the baseline defaults to the latest snapshot.
useBaselineTransforms no If useBaselineTransforms set to true, then the local-project will have its transforms overridden by the baseline's (where baseline could just be latest by default). Default value is false.
useBaselineExcludes no If set to true, then the local-project will have its excludes overridden by the baseline's. (where baseline could just be latest by default). Default value is false.
useProjectFileDiagrams no If set to true then diagrams in the specified project file are used instead of repository diagrams. Default value is true.
detailed no If set to true then the list of elemental (lowest level) violations will be saved to output. If false the violations will be rolled up to the relevant cell level, e.g. package-to-package. Default value is false.
check-unassociated no If onlyNew is set to true then it will check the baseline before reporting an item as unassociated. Otherwise all unassociated items in the Architecture diagrams are reported including any new items not associated with an Architecture diagram.
fail-on-violations no If fail-on-violation is set to true then a runtime exception will be thrown if a violation is found. Default value is true
identifier-on-violation no If set then the text will be present in console output if a violation is found. This feature can be used in conjunction with Hudson or Jenkins (Textfinder plugin) to set the build status unstable or failed.
verbose no If set to true then the detected violations will be output to the console. Default value is false.

Important: Requires a valid license file in the current directory with a build license, or the -licensedirectory parameter to be set.