Skip to content

Instantly share code, notes, and snippets.

@ko2ic
Created May 25, 2014 09:31
Show Gist options
  • Save ko2ic/79f90c874ac2c9fc8d24 to your computer and use it in GitHub Desktop.
Save ko2ic/79f90c874ac2c9fc8d24 to your computer and use it in GitHub Desktop.
mavenですべての設定ファイルを自動生成させる方法 - http://qiita.com/ko2ic/items/39be03afbc6c38c409ea
<properties>
<root.basedir>${project.parent.basedir}</root.basedir>
</properties>
<profiles>
<profile>
<id>conf</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>set-custom-property</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.properties.setProperty('main.basedir',
project.parent.basedir.toString())
</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<!-- fileに${project.parent.basedir}を記述しても展開してくれない。maven-antrun-pluginがサポートしていないっぽい。親のpom.xmlに記述しても展開されないようで駄目でした -->
<property name="rootDir" location="${root.basedir}" />
<copy file="${main.basedir}/config/checkstyle-config.xml" tofile="${eclipse.workspace}/.metadata/.plugins/net.sf.eclipsecs.core/checkstyle-config.xml" overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.jdt.ui.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs"
overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.ui.editors.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs"
overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.wst.xml.core.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs"
overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.jst.jsp.core.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jst.jsp.core.prefs"
overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.wst.css.core.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.css.core.prefs"
overwrite="true" />
<copy file="${main.basedir}/config/org.eclipse.wst.html.core.prefs" tofile="${eclipse.workspace}/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.html.core.prefs"
overwrite="true" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<modules>
<module>project1</module>
<module>project2</module>
<module>project3</module>
</modules>
<properties>
<root.basedir>${project.basedir}</root.basedir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>conf</id>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<target>1.7</target>
<source>1.7</source>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<additionalBuildcommands>
<buildcommand>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</buildcommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>com.atlassw.tools.eclipse.checkstyle.CheckstyleNature</projectnature>
</additionalProjectnatures>
<additionalConfig>
<file>
<name>.checkstyle</name>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true">
<fileset name="all" enabled="true" check-config-name="sa-checkstyle" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
<filter name="NonSrcDirs" enabled="true"/>
</fileset-config>
]]>
</content>
</file>
<file>
<name>.settings/org.eclipse.core.resources.prefs</name>
<content>
<![CDATA[eclipse.preferences.version=1${line.separator}encoding/<project>=${project.build.sourceEncoding}${line.separator}]]>
</content>
</file>
</additionalConfig>
<workspace>${eclipse.workspace}</workspace>
<workspaceCodeStylesURL>https://raw.githubusercontent.com/ko2ic/java-config/master/codeformatter-7.xml</workspaceCodeStylesURL>
<workspaceActiveCodeStyleProfileName>Ko2ic Formatter</workspaceActiveCodeStyleProfileName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment