3 Kasım 2022 Perşembe

build-helper plugin

add-source goal
Herhangi bir kod üretici plugin tarafından üretilen kodları source olarak projeye ekler.

Örnek
Şöyle yaparız
<plugin>
  <groupId>org.apache.avro</groupId>
  <artifactId>avro-maven-plugin</artifactId>
  <version>${avro.version}</version>
  <executions>
    <execution>
  <phase>generate-sources</phase>
  <goals>
    <goal>schema</goal>
  </goals>
  <configuration>
    <sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-sources/java</outputDirectory>
  </configuration>
    </execution>
  </executions>
</plugin>

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.3.0</version>
  <executions>
    <execution>
  <id>add-source</id>
  <phase>generate-sources</phase>
  <goals>
    <goal>add-source</goal>
  </goals>
  <configuration>
    <sources>
      <source>${project.build.directory}/generated-sources/java/</source>
    </sources>
  </configuration>
    </execution>
  </executions>
</plugin>
attach-artifact goal
Örnek - shaded
shade yapılan projeyi bir başka modülde kullanabilmeyi sağlar
Örnek
github örneği burada
shade için şöyle yaparız
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>3.3.0</version>
  <configuration>
    <relocations>
      <relocation>
        <pattern>org.apache</pattern>
      <shadedPattern>three.nine.org.apache</shadedPattern>
    </relocation>
  </relocations>
  <createDependencyReducedPom>false</createDependencyReducedPom>
  </configuration>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Daha sonra yine aynı projede şöyle yaparız
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.3.0</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            <file>${project.build.directory}/${project.build.finalName}.jar</file>
            <type>jar</type>
            <classifier>shaded</classifier>
          </artifact>
        </artifacts>
      </configuration>
     </execution>
  </executions>
</plugin>
parse-version go
parse-version goal
version plugin tarafından üretilen ve pom dosyasına yazılan versiyon numarasını kullanır.

Örnek
Şöyle yaparız
<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>build-helper-maven-plugin</artifactId>
   <version>3.1.0</version>
   <executions>
      <execution>
         <id>parse-version</id>
         <goals>
            <goal>parse-version</goal>
         </goals>
      </execution>
   </executions>
</plugin>

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>versions-maven-plugin</artifactId>
   <version>2.8.1</version>
</plugin>

Hiç yorum yok:

Yorum Gönder

Local Snapshot Kullanmak

Örnek Şöyle yaparız <repository> <id>snapshot-repository</id> <name>Maven2 Snapshot Repository</name> &l...