2016-04-01 15 views
1

Ich bin neu in Maven und habe ein Problem, wo ich versuche, das SCM-Plugin Ziel von checkout zu Update basierend darauf, ob die Quelle bereits ausgecheckt ist automatisch zu ändern.Wie löst man das SCM-Plugin von Maven aus, um Ziele basierend auf dem vorhandenen Verzeichnis automatisch zu wechseln?

Kann mir jemand ein Codebeispiel zeigen, damit das funktioniert? Diese ist die Plugin-Konfiguration:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-scm-plugin</artifactId> 
    <version>1.9.4</version> 
     <executions> 
      <execution> 
       <phase>generate-sources</phase> 
       <goals> 
        <goal>checkout</goal> 
       </goals> 
       <configuration> 
        <connectionType>developerConnection</connectionType> 
        <scmVersion>master</scmVersion> 
        <scmVersionType>branch</scmVersionType> 
        <checkoutDirectory>${project.basedir}/src</checkoutDirectory> 
        <workingDirectory>${project.basedir}/src</workingDirectory> 
       </configuration> 
      </execution> 
     </executions> 
</plugin> 

Antwort

0

Änderung goal:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-scm-plugin</artifactId> 
    <version>1.9.4</version> 
     <executions> 
      <execution> 
       <phase>generate-sources</phase> 
       <goals> 
        <goal>update</goal> 
       </goals> 
       <configuration> 
        <connectionType>developerConnection</connectionType> 
        <scmVersion>master</scmVersion> 
        <scmVersionType>branch</scmVersionType> 
        <checkoutDirectory>${project.basedir}/src</checkoutDirectory> 
        <workingDirectory>${project.basedir}/src</workingDirectory> 
       </configuration> 
      </execution> 
     </executions> 
</plugin> 

Referenz
https://maven.apache.org/scm/maven-scm-plugin/
https://maven.apache.org/scm/maven-scm-plugin/update-mojo.html

+0

Thanks Haben, nicht aktualisieren, wenn das Projekt nicht Bootstrap verwendet Kasse. Wie wird automatisch zwischen Kasse und Update gewechselt, abhängig davon, ob der Checkout abgeschlossen ist? Ich habe die Frage geklärt. – garyM

+0

Dieser Link ist vielleicht hilfreich für Sie: https://maven.apache.org/scm/maven-scm-plugin/examples/bootstrapping-with-pom.html –

+0

Danke, ich wollte automatisch wechseln. Ich habe die Frage bearbeitet, um zu klären, – garyM

0

Um das Ziel der SCM-Plugin zu ändern wurde inspiriert von Đỗ Như Vý (oben).

Ansatz war zu

  1. Legen Sie das Ziel in einer Eigenschaft namens scm.goal auf einen Standardwert gesetzt dh aktualisieren.
  2. Verwenden Sie ein Profil (Bootstrap), um den Wert der Eigenschaft scm.goal von 'update' in 'checkout' zu ändern.
  3. Aktivieren Sie das Bootstrap-Profil basierend auf der fehlenden .gitignore-Datei.
  4. Platzieren Sie die Eigenschaft scm.goal im SCM-Plugin Zielelement.

Code:

<properties> 
     <scm.dest.path>${project.basedir}/src</scm.dest.path> 
     <scm.goal>update</scm.goal> 
    </properties> 

    <profiles> 
     <profile> 
      <id>bootstrap</id> 
      <activation> 
       <file> 
        <missing>./src/.gitignore</missing> 
       </file> 
      </activation> 
      <properties> 
       <scm.goal>checkout</scm.goal> 
      </properties> 
     </profile> 
    </profiles> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-scm-plugin</artifactId> 
       <version>1.9.4</version> 
       <executions> 
        <execution> 
         <phase>generate-sources</phase> 
         <goals> 
          <goal>${scm.goal}</goal> 
         </goals> 
         <configuration> 
          <connectionType>developerConnection</connectionType> 
          <scmVersion>master</scmVersion> 
          <scmVersionType>branch</scmVersionType> 
          <checkoutDirectory>${scm.dest.path}</checkoutDirectory> 
          <workingDirectory>${scm.dest.path}</workingDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
...