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

 

The check-spec operation is used when you wish to enforce the Structure Spec 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-spec">
            <argument name="output-file" value="c:/abc/arch-violations.csv"/>
            <argument name="output-dir" value="const(THIS_FILE)/ide-data"/>
            <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 Spec 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 a structure spec has been published to), e.g. c:/repository, /home/usr/x/repository, or, if remote, http://<servernameorip><:portno>/s101j/data.
project yes The name of the project in the repository (where a structure spec has been published to)
local-project no See project-spec.
output-file no File to which violations to the structure spec are written in CSV format. This can be a relative or absolute path.
output-dir no Path to the directory where the XML files: spec-diagrams.xml and spec-violations.xml, and an image representing the state of the Structure Spec are written. This can be a relative or absolute path.
onlyNew no If true then a check against the baseline is done before reporting an item as unassociated. Otherwise all unassociated items in the Structure Spec 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 useBaselineExcludes set to true, then the local-project will have its excludes overridden by the baseline's. Default value is false.
useProjectFileSpec no If set to true then the structure spec in the specified project file is used instead of the repository structure spec. Default value is true.
detailed no If detailed is set to “true”, then the list of elemental (lowest level) violations will be saved to output. If false, the default, violations will rolled up to the relevant cell level, e.g. package-to-package.
check-unassociated no If true and onlyNew is also set to true then it will check the baseline before reporting an item as unassociated otherwise it will report all unassociated items in the Structure Spec.
fail-on-violations no Default value is true, if fail-on-violation is set to true then a runtime exception will be thrown if a violation is found.
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.


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