Last active
October 26, 2024 07:45
-
-
Save codahale/2019732 to your computer and use it in GitHub Desktop.
Take this and save it as pom.xml in your project directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>my-project</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<dependencies> | |
<!-- none yet --> | |
</dependencies> | |
<properties> | |
<!-- use UTF-8 for everything --> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |
</properties> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<!-- compile for Java 1.7 --> | |
<configuration> | |
<source>1.7</source> | |
<target>1.7</target> | |
<encoding>UTF-8</encoding> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This is maybe a dumb question, but if I want to use java-8 can I just bump the version in the configuration block to 1.8?
@estsauver
Yes, but keep in mind that by targeting Java 8, others who may wish to run your compiler output but only have version 1.7 of the JDK installed will not be able to do so without recompilation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. Is there a way we can pass things like groupId, artifactId as arguments and make it even more generic? Java source and target versions can be made generic too.