Как создать новый тип упаковки для Maven?

Объединить с предложением where для меня:

merge into table1
using table2
on (table1.id = table2.id)
when matched then update set table1.startdate = table2.start_date
where table1.startdate > table2.start_date;

Вам нужно предложение WHERE, потому что столбцы, на которые ссылается в предложении ON, не могут быть обновлены.

30
задан talk to frank 15 September 2009 в 15:00
поделиться

1 ответ

Чтобы сделать, как вы описали, создайте Проект Maven с упаковкой jar (как указано здесь , так как определений mojo не будет). В подпапке src / main / resources / META-INF / plexus создайте файл components.xml со следующим содержимым (если вы хотите, чтобы тип упаковки был «my-custom-type», измените его на «foobar», если вы wish).

<component-set>
  <components>
    <component>
      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
      <role-hint>my-custom-type</role-hint>
      <implementation>
        org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
      </implementation>
      <configuration>
    <phases>
      <!--use the basic jar lifecycle bindings, add additional 
          executions in here if you want anything extra to be run-->          
      <process-resources>
        org.apache.maven.plugins:maven-resources-plugin:resources
      </process-resources>
      <package>
        org.apache.maven.plugins:maven-jar-plugin:jar
      </package>
      <install>
        org.apache.maven.plugins:maven-install-plugin:install
      </install>
      <deploy>
        org.apache.maven.plugins:maven-deploy-plugin:deploy
      </deploy>
    </phases>
      </configuration>
    </component>
    <component>
      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
      <role-hint>my-custom-type</role-hint>
      <implementation>
        org.apache.maven.artifact.handler.DefaultArtifactHandler
      </implementation>
      <configuration>
        <!--the extension used by Maven in the repository-->
        <extension>foobar</extension>
        <!--the type used when specifying dependencies etc.-->
        <type>my-custom-type</type>
        <!--the packaging used when declaring an implementation of 
          the packaging-->
        <packaging>my-custom-type</packaging>
      </configuration>
    </component>
  </components>
</component-set>

Затем в помпе, который должен иметь нестандартную упаковку, объявить требуемый тип в элементе упаковки, и убедитесь, что вы указали плагин, чтобы можно было внести индивидуальную упаковку. Объявление true сообщает Maven, что плагин вносит в Maven упаковку и / или обработчики типов.

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>name.seller.rich</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>my-custom-type</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>name.seller.rich.maven.plugins</groupId>
        <artifactId>maven-foobar-plugin</artifactId>
        <version>0.0.1</version>
        <!--declare that this plugin contributes the component extensions-->
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build> 
</project>

Когда проект упакован, это будет jar с расширением .jar, но когда он будет установлен / deployed, Maven доставит файл в репозиторий с расширением ".foobar", как указано в components.xml

44
ответ дан 27 November 2019 в 22:27
поделиться
Другие вопросы по тегам:

Похожие вопросы: