source ve target Tagleri
Açıklaması şöyle
Sometimes when you may need to compile a certain project to a different version than what you are currently using. The javac can accept such command using -source and -target. The Compiler Plugin can also be configured to provide these options during compilation.
Yani java derleyicisine geçilecek -source ve -target parametrelerini 2 şekilde tanımlayabiliyoruz.
1. Global Properties olarak
2. Plugin konfigürasyon parametreleri olarak
Global Properties
Örnek
Java 9 ile şöyle yaparız
<properties> <maven.compiler.release>11</maven.compiler.release> </properties>
SpringBoot ile istersek, şöyle yaparız
<properties> <java.version>21</java.version> </properties>
Açıklaması şöyle
<java.version> is not referenced in the Maven documentation. It is a Spring Boot specificity.
Bu eski yöntem. Şöyle yaparız
<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties>
Plugin Configuration
Örnek - release tag
Şöyle yaparız
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <release>12</release> </configuration> </plugin>
Örnek - source + target tag
Bu eski yöntem. Şöyle yaparız
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin>
annotationProcessorPaths Tag
Örnek
Şöyle yaparız
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <source>19</source> <target>19</target> <encoding>UTF-8</encoding> <compilerArgs> <!-- Configure manifold plugin--> <arg>-Xplugin:Manifold</arg> </compilerArgs> <!-- Add the processor path for the plugin --> <annotationProcessorPaths> <path> <groupId>systems.manifold</groupId> <artifactId>manifold-json</artifactId> <version>${manifold.version}</version> </path> </annotationProcessorPaths> </configuration> </plugin>
Hiç yorum yok:
Yorum Gönder