アノテーションによるアサーション(その2 mavenプラグイン編)
フェーズ
設定
以下は main 系のコードにアサーションを織り込みたい場合のプラグイン設定です。
<plugin> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-mojo</artifactId> <version>0.0.8</version> <executions> <execution> <goals> <goal>main-weave</goal> </goals> </execution> </executions> </plugin>
以下は test 系のコードにアサーションを織り込みたい場合のプラグイン設定です。
<plugin> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-mojo</artifactId> <version>0.0.8</version> <executions> <execution> <goals> <goal>test-weave</goal> </goals> </execution> </executions> </plugin>
以下は main 系と test 系の両方のコードにアサーションを織り込みたい場合のプラグイン設定です。
<plugin> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-mojo</artifactId> <version>0.0.8</version> <executions> <execution> <id>after-compile</id> <goals> <goal>main-weave</goal> </goals> </execution> <execution> <id>after-test-compile</id> <goals> <goal>test-weave</goal> </goals> </execution> </executions> </plugin>
pom.xmlのサンプル
<?xml version="1.0" encoding="UTF-8"?> <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"> <!-- POM Reference : http://maven.apache.org/pom.html --> <modelVersion>4.0.0</modelVersion> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-mojo-sample</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <repositories> <repository> <id>jboss</id> <name>jboss</name> <url>http://repository.jboss.org/maven2</url> </repository> <repository> <id>codehaus</id> <name>codehaus</name> <url>http://repository.codehaus.org</url> </repository> <repository> <id>objectfanatics</id> <name>objectfanatics</name> <url>http://domaingen.sourceforge.jp/maven2</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>objectfanatics</id> <name>objectfanatics</name> <url>http://domaingen.sourceforge.jp/maven2</url> </pluginRepository> </pluginRepositories> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> <encoding>utf-8</encoding> </configuration> </plugin> <plugin> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-mojo</artifactId> <version>0.0.8</version> <executions> <execution> <id>after-compile</id> <goals> <goal>main-weave</goal> </goals> </execution> <execution> <id>after-test-compile</id> <goals> <goal>test-weave</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>jp.objectfanatics</groupId> <artifactId>assertion-constraints</artifactId> <version>0.0.8</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>5.8</version> <scope>test</scope> <classifier>jdk15</classifier> </dependency> </dependencies> </project>