|
|
You can use the S101Headless utility with Maven. Simply add the following to the plugin section of your pom.xml <groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>1.1</version>
The Structure101 Maven plugin is hosted on http://repository.structure101.com. To configure Maven to use Structure101 add the following to your pom.xml file. <pluginRepositories>
<pluginRepository>
<id>structure101plugin</id>
<layout>default</layout>
<url>http://repository.structure101.com</url>
<releases>
<checksumPolicy>warn</checksumPolicy>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>structure101</id>
<url>http://repository.structure101.com</url>
<releases>
<checksumPolicy>warn</checksumPolicy>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
Goals OverviewThere are six Maven goals defined for Structure101.
Each goal is explained below UsageThe goals of the Structure101 Maven plugin by default execute after the test phase. This can be configured in plugin configuration. However, it is required to run after the compile phase so that Structure101 can perform byte-code analysis. Configuring Your Structure101 Maven PluginSetting up licenseThe default license directory is the project directory. Although a different license directory can be specified using <license-directory>C:\license_directory</license-directory> in the plug-in configuration. Goal: com.structure101.java:maven-structure101-plugin:publishPublishes a local project to a new snapshot in a repository. Available arguments include:
pom.xml configuration <build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<classpath>${build.outputDirectory}</classpath>
<date>system time</date>
<key></key>
<label>1.0.0</label>
<localProject>location to .java.hsp file</localProject><overwrite>true</overwrite>
<repository>${structure101repository}</repository>
<license-directory>${basedir}</license-directory>
<rpkey></rpkey>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>publish</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Goal: com.structure101.java:maven-structure101-plugin:check-architectureAs part of S101Headless 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. This goal is most likely to be useful when you wish to enforce the defined architecture in a continuous build environment. Available arguments include:
pom.xml configuration <build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<fail-build-on-violations>false</fail-build-on-violations>
<classpath>${build.outputDirectory}</classpath>
<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>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Goal: com.structure101.java:maven-structure101-plugin:check-xsAs part of S101Headless it is possible to check for detrimental XS changes prior to publishing, and if XS is found to be increasing, an exception can be raised to break the build. and hence abort the publish to the repository. This operation is most likely to be useful when you wish to enforce KALOI (keep a lid on it) in a continuous build environment. KALOI promotes the idea that where a codebase has XS (or not) it is undesirable for items with XS to increase, or to be introduced, even if that codebase has a large accumulative XS value to begin with. Available arguments include:
pom.xml configuration <build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<fail-build-on-violations>false</fail-build-on-violations>
<classpath>${build.outputDirectory}</classpath>
<localProject>location to .java.hsp file</localProject><overwrite>true</overwrite>
<repository>${structure101repository}</repository>
<check-xs-output-file>${structure101outputDir}\check-xs.xml</check-xs-output-file>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check-xs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Goal: com.headway.java:maven-structure101-plugin:report-metricsOutput the metrics to an XML file. Available arguments include:
pom.xml configuration <build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<fail-build-on-violations>false</fail-build-on-violations>
<classpath>${build.outputDirectory}</classpath>
<localProject>location to .java.hsp file</localProject><overwrite>true</overwrite>
<report-metrics-output-file>${structure101outputDir}\report-metrics.xml</report-metrics-output-file>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>report-metrics</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Goal: com.headway.java:maven-structure101-plugin:report-xsOutput the XS offenders to an XML file. Available arguments include:
pom.xml Configuration<build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<fail-build-on-violations>false</fail-build-on-violations>
<classpath>${build.outputDirectory}</classpath>
<localProject>location to .java.hsp file</localProject><overwrite>true</overwrite>
<report-xs-output-file>${structure101outputDir}\report-xs.xml</report-xs-output-file>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>report-xs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Goal: com.structure101.java:maven-structure101-plugin:report-summaryit is possible to generate a report, like the one in the Overview perspective. Available arguments include:
pom.xml Configuration <build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<breakOnError>false</breakOnError>
<fail-build-on-violations>false</fail-build-on-violations>
<classpath>${build.outputDirectory}</classpath>
<localProject>location to .java.hsp file</localProject><overwrite>true</overwrite>
<output-dir>${structure101outputDir}</output-dir>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>report-summary</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
Sample pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.structure101</groupId>
<artifactId>TestPlugins</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestPlugins</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.structure101.java</groupId>
<artifactId>maven-structure101-plugin</artifactId>
<version>0.5</version>
<configuration>
<!-- put your configurations here -->
<project>${project.name}</project>
<archoutputfile>${structure101outputDir}\arch.xml</archoutputfile>
<baseline></baseline>
<breakOnError>false</breakOnError>
<checkXsOutputFile>${structure101outputDir}\check-xs.xml</checkXsOutputFile>
<classpath>${build.outputDirectory}</classpath>
<date>system time</date>
<failBuildOnViolation>false</failBuildOnViolation>
<key></key>
<label>1.0.0</label>
<localProject>location to .java.hsp file</localProject>
<mem>256</mem>
<name></name>
<notips>false</notips>
<offendersOutputFile>${structure101outputDir}\offender.cva</offendersOutputFile>
<onlyNew>false</onlyNew>
<outdir>${structure101outputDir}</outdir>
<outputdir>${structure101outputDir}</outputdir>
<overwrite>true</overwrite>
<projectMetricOutputFile>${structure101outputDir}\report-metric.xml</projectMetricOutputFile>
<repository>${structure101repository}</repository>
<reppath></reppath>
<rpkey></rpkey>
<scriptfile></scriptfile>
<simulate></simulate>
<xml>true</xml>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>publish</goal>
<goal>check-architecture</goal>
<goal>check-xs</goal>
<goal>report-metrics</goal>
<goal>report-summary</goal>
<goal>report-xs</goal>
<goal>retropublish</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>structure101plugin</id>
<layout>default</layout>
<url>http://repository.structure101.com</url>
<releases>
<checksumPolicy>warn</checksumPolicy>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>structure101</id>
<url>http://repository.structure101.com</url>
<releases>
<checksumPolicy>warn</checksumPolicy>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
<properties>
<structure101outputDir>${project.build.directory}\structure101data</structure101outputDir>
<structure101repository>c:\structure101repo</structure101repository>
</properties>
</project>
|