2011年7月10日日曜日

mavenで遊んでみた

いままでちゃんと使ってこなかったことを後悔するくらいmavenって便利かも。

mvnで依存関係解決すると、eclipseで-sources.jarとか-javadoc.jarもちゃんと解決してくれるのってすごく便利。

mvn packageとかmvn deployしたら、-sources.jarと-javadoc.jarも一緒に更新してくれるようにできるのって便利。

今日は、こんなpom.xmlを作って満足してるところ。

<project>
  ...

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>local.file.system</id>
      <url>file:///c:/Users/Kei/Devel/Java/MavenRepos/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <distributionManagement>
    <repository>
      <id>deploy-repository</id>
      <name>deployRepository</name>
      <url>file:///c:/Users/Kei/Devel/Java/MavenRepos/</url>
    </repository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <configuration>
          <excludeResources>true</excludeResources>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
          </execution>
        </executions>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <author>true</author>
          <source>1.6</source>
          <locale>en</locale>
          <!-- <locale>ja</locale> -->
          <showPackage>true</showPackage>
          <showPrivate>true</showPrivate>
          <encoding>utf-8</encoding>
          <charset>utf-8</charset>
          <decoding>utf-8</decoding>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

androidのプロジェクトもmavenでビルドできたらいいのに。
android library projectの参照解決がしっかりできなくちゃダメ。
もしかして、それもできるのかな?知らないだけ?