23
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MavenでJava8のプロジェクトを作る

Posted at

pl.org.miki:java8-quickstart-archetypeを使う

$ mvn archetype:generate -DinteractiveMode=false \
                         -DarchetypeGroupId=pl.org.miki \
                         -DarchetypeArtifactId=java8-quickstart-archetype \
                         -DgroupId=com.example \
                         -DartifactId=hello \
                         -Dversion=1.0-SNAPSHOT \
                         -Dpackage=com.example \
                         -Dpackaging=jar

maven-quickstart-archetypeと違ってApp.javaとAppTest.javaは生成されない

$ tree
.
├── pom.xml
└── src
    ├── main
    │   └── java
    │       └── com
    │           └── example
    └── test
        └── java
            └── com
                └── example

9 directories, 1 file

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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>hello</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>jar</packaging>

 
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>1.8</java.version>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>${java.version}</source>
					<target>${java.version}</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.11</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>

maven-compiler-pluginによって-source 1.8がコンパイラに渡され、
ラムダ式などが書けるようになった。

23
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?