SAStruts + Doma の開発環境を maven2 + WTP で構築する手順
ここ1年くらい、SAStruts + S2JDBC で新規システムの開発してきたんですが、今月から別のシステムのメンテナンス画面を作ることになりました。
メンテナンス画面なので、データベースのスキーマはいじれないので、S2JDBC だと少しやりにくいな、と思っていたところにみつけたのが、Doma です。さっと使ってみて、Doma とってもいい感じだったので、じゃ、これで、と決めて、さっそくdoma-jpetstore を改造してセットアップしようとしたのですが、同梱の pom.xml が maven のコンパイラプラグインにバグがあるせいで、ant でビルドしているという、という荒業をやってました。あと、例によって WTP じゃない。
で、そのままでも良かったんですが、社内標準が maven + WTP なので、全部 maven で実行できるような pom.xml を書いてみました。ついでに、eclipse プロジェクトの設定も追加して、mvn eclipse:eclipse でエクリプスプロジェクトを作成できるようにしています。
<?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">
<modelVersion>4.0.0</modelVersion>
<!-- The Basics -->
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<!-- More Project Information -->
<name>App Name</name>
<description>App Description</description>
<url>http://xxx</url>
<inceptionYear>2010</inceptionYear>
<organization>
<name>XXX, Inc</name>
<url>http://xxx</url>
</organization>
<repositories>
<repository>
<id>maven.seasar.org</id>
<name>The Seasar Foundation Maven2 Repository</name>
<url>http://maven.seasar.org/maven2</url>
</repository>
<repository>
<id>maven.snapshot.seasar.org</id>
<name>The Seasar Foundation Maven2 Repository(snapshot)</name>
<url>http://maven.seasar.org/maven2-snapshot</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>maven.seasar.org</id>
<name>The Seasar Foundation Maven2 Repository</name>
<url>dav:https://www.seasar.org/maven/maven2</url>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>maven.seasar.org</id>
<name>The Seasar Foundation Maven2 Snapshot Repository</name>
<url>dav:https://www.seasar.org/maven/maven2-snapshot</url>
</snapshotRepository>
</distributionManagement>
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<properties>
<generatedSourceDirectory>target/generated-sources/apt/main/java</generatedSourceDirectory>
<sourceEncoding>UTF-8</sourceEncoding>
</properties>
<!-- Build Settings -->
<build>
<finalName>${artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>${generatedSourceDirectory}</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx512M</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${sourceEncoding}</encoding>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<compilerArguments>-encoding ${sourceEncoding} -Adao.subpackage=impl -Adao.suffix=Impl</compilerArguments>
<outputDirectory>${generatedSourceDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpversion>2.0</wtpversion>
<wtpContextName>enquete-admin</wtpContextName>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<!-- GlassFish V3 を使いたい場合はコメントアウトを解除してください
<classpathContainer>org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish Server Open Source Edition 3 (Java EE 6)</classpathContainer>
-->
</classpathContainers>
<additionalConfig>
<file>
<name>.factorypath</name>
<content><![CDATA[<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/org/seasar/doma/doma/1.8.0/doma-1.8.0.jar" enabled="true" runInBatchMode="false"/>
</factorypath>]]>
</content>
</file>
<file>
<name>.settings/org.eclipse.jdt.apt.core.prefs</name>
<content><![CDATA[eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target/generated-sources/apt/main/java
org.eclipse.jdt.apt.processorOptions/dao.subpackage=impl
org.eclipse.jdt.apt.processorOptions/dao.suffix=Impl
org.eclipse.jdt.apt.processorOptions/debug=false
org.eclipse.jdt.apt.reconcileEnabled=false
org.eclipse.jdt.apt.reconcileEnabled=true]]>
</content>
</file>
<file>
<name>.settings/org.eclipse.jdt.core.prefs</name>
<content><![CDATA[org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.processAnnotations=enabled
]]>
</content>
</file>
<!-- GlassFish V3 (Servlet 3.0) を使いたい人はコメントアウトを解除してください
<file>
<name>.settings/org.eclipse.wst.common.project.facet.core.xml</name>
<content><![CDATA[<faceted-project>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="jst.java" version="6.0"/>
</faceted-project>]]>
</content>
</file>
-->
</additionalConfig>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>source-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<header>http://www.seasar.org/license/header.txt</header>
<includes>
<include>src/**/*.java</include>
</includes>
<encoding>UTF-8</encoding>
<headerDefinitions>
<headerDefinition>http://www.seasar.org/license/header-definition.xml</headerDefinition>
</headerDefinitions>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav</artifactId>
<version>1.0-beta-2</version>
</extension>
</extensions>
</build>
<!-- Dependency Settings -->
<dependencies>
<dependency>
<groupId>org.seasar.doma</groupId>
<artifactId>doma</artifactId>
<version>1.8.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.seasar.sastruts</groupId>
<artifactId>sa-struts</artifactId>
<version>1.0.4-sp8</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-ejb_3.0_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_3.0_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_3.0_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<!-- JDBC Driver : Oracle の場合 -->
<dependency>
<groupId>ojdbc6</groupId>
<artifactId>ojdbc6</artifactId>
<version>6</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>