11/05/2022

pom.xml

Tabii ki daha çok başındayım ama ….

pom.xml dosyası maven ile derleme yaparken kullanılıyorç

<?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>org.example</groupId>
    <artifactId>GPACalculator</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>${exec-maven-plugin.version}</version>
                    <configuration>
                        <mainClass>GpaCalculator.GpaCalculator</mainClass>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Properties de ki kısım değişken ve şu şekilde kullanılıyorç



    <properties>
        <maven.compiler.source>17</maven.compiler.source>
       .
       .
       .
                    <version>${exec-maven-plugin.version}</version>
                   

pluginManagement –> hangi pluginleri hazırlayacakç

plugins –> hangileri kullanılacak.

Bu pluginler maven in işlemleri mesela

exec:java

en basit hello world ü derlemek için bile bunlara gerek var.

Bu örnek min pom dosyasi.

daha sonra kullanmak icin pom.xml in olduğu klasöre gidip.

mvn clean package exec:java

eğer problem yoksa

[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.example:GPACalculator >----------------------
[INFO] Building GPACalculator 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ GPACalculator ---
[INFO] Deleting /mnt/c/Users/can/IdeaProjects/GPACalculator/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ GPACalculator ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ GPACalculator ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /mnt/c/Users/can/IdeaProjects/GPACalculator/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ GPACalculator ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /mnt/c/Users/can/IdeaProjects/GPACalculator/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ GPACalculator ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ GPACalculator ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ GPACalculator ---
[INFO] Building jar: /mnt/c/Users/can/IdeaProjects/GPACalculator/target/GPACalculator-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ GPACalculator ---

Leave a Reply