ter Ant - Architecture Rules - Wiki

Ant

From Architecture Rules - Wiki
Jump to: navigation, search

Ant-Task

If you are not a Maven user, this Ant task is the the preferred means for asserting your architecture. The downside to this method of running the test, is that there is no means for you to provide any programmatic configuration - the entire configuration must be read from the XML configuration file. If you must use Ant, and you must provide programmatic configuration, you will need to see the next option, Ant Unit Test.

To use the Ant task, you must define the task with the taskdef directive, and then create a target to call assertArchitecture, and provide a name of the XML configuration file which you have placed in the project’s classpath.

To run with ant, you must include your own compile goal. This configuration below includes depends=”compile” within the test-architecture goal, so you need to implement that goal, or change the depends to your own goal, whatever you may have called your compile goal.

Also, you will need to point to all of the libs. If you’re an ant user, you probably have a /libs directory that you can point to.

For an up-to-date list of dependencies, see the dependencies list.

<property name="maven.repo" value="C:\dev\m2repo\"/>
 
  <path id="class.path">
    <pathelement id="test" path=".\target\test-classes"/>
    <pathelement id="main" path=".\target\classes"/>
 
<!-- updated list of dependencies available at -->
<!-- http://wiki.architecturerules.org/index.php?title=Dependencies  -->
 
   <pathelement id="junit"
   path="${maven.repo}\junit\junit\3.8.1\junit-3.8.1.jar"/> 
 
<!-- You must define all dependencies listed at  -->
<!-- http://wiki.architecturerules.org/index.php?title=Dependencies  -->
<!-- as a pathelement such as the junit-3.8.1.jar above  -->
 
  </path>
 
  <!-- you must define your own compile -->
  <target name="compile"/>
 
  <taskdef name="assertArchitecture"
      configurationFileName
      classname="org.architecturerules.ant.AssertArchitectureTask">
      <classpath refid="class.path"/>
   </taskdef>
 
   <target name="assert-architecture" depends="compile">
      <assertArchitecture
        configurationFileName="architecture-rules.xml" />
   </target>

Ant Unit Test

To run with ant, you must include your own compile goal. This configuration below includes depends=”compile” within the test-architecture goal, so you need to implement that goal, or change the depends to your own goal, whatever you may have called your compile goal.

Also, you will need to point to all of the libs. If you’re an ant user, you probably have a /libs directory that you can point to.

For an up-to-date list of dependencies, see the dependencies list.


   <property name="maven.repo" value="C:\dev\m2repo\"/>  
 
   <path id="class.path">  
     <pathelement id="test" path=".\target\test-classes"/>  
     <pathelement id="main" path=".\target\classes"/>  
 
 <!-- updated list of dependencies available at -->  
 <!-- http://wiki.architecturerules.org/index.php?title=Dependencies  -->  
 
    <pathelement id="junit"  
    path="${maven.repo}\junit\junit\3.8.1\junit-3.8.1.jar"/>   
 
 <!-- You must define all dependencies listed at  -->  
 <!-- http://wiki.architecturerules.org/index.php?title=Dependencies  -->  
 <!-- as a pathelement such as the junit-3.8.1.jar above  -->  
 
   </path>  
 
   <!-- you must define your own compile -->  
   <target name="compile"/>  
 
   <target name="test-architecture" depends="compile">  
     <junit haltonerror="true">  
       <classpath refid="class.path"/>  
       <formatter type="brief" usefile="false"/>  
       <test name="org.architecturerules.ant.AssertArchitectureTask"  
         haltonfailure="true"/>  
     </junit>  
   </target>
Personal tools