16

Archivaを中央およびその他の外部リポジトリのMavenプロキシとして、またHudsonによってSVNから自動的に構築され、スナップショットリポジトリにインストールされるアーティファクトのスナップショットストレージとして使用しようとしています。

内部リポジトリとスナップショットリポジトリを一緒に使用するようにMavenクライアントを設定できません。log4j私のプロジェクトには、Archiva内部リポジトリから正しくダウンロードされるいくつかの外部依存関係(など)があります。また、私のプロジェクトには、アーティファクトがすでにビルドされてスナップショットリポジトリにインストールされている独自のプロジェクトへの依存関係があります。ただし、プロジェクトをビルドしようとすると、Mavenはスナップショットアーティファクトを見つけることができません。

私の構成ファイルには元々次の設定がありました:

<mirror>
  <id>company-internal</id>
  <name>Company's Archiva - Internal Repository</name>
  <url>http://www.mycompany.hu/archiva/repository/internal</url>
  <mirrorOf>*</mirrorOf>
</mirror>

そして、私は以下を追加しました:

<mirror>
 <id>company-snapshots</id>
 <name>Company Archiva - Snapshots Repository</name>
 <url>http://www.mycompany.hu/archiva/repository/snapshots</url>
 <mirrorOf>apache.snapshots</mirrorOf>
</mirror>

ただし、Mavenはビルド時にsnaphotリポジトリを検索しようとしません。私は何を間違えましたか?ちなみに、私は実際には<mirrorOf>要素の目的を理解していません。内部ミラー設定でこれを置き換えようとしましたcentralが、それでも問題は解決しません。

4

3 に答える 3

2

多くの試行錯誤を経て、Raghuram のものと非常によく似た構成にたどり着きました。しかし、archiva を使用して、まだ注目に値する可能性があることを 1 つまたは 2 つ見つけました。また、リポジトリに直接アクセスする代わりに、自分のプロジェクト ( <distributionManagement/>pom.xml で設定) がアクセスできるように構成内のミラーを使用しました。

これは私のmaven settings.xmlの関連部分です:

<!-- set up servers to point to mirror, for use in project pom -->
<servers>
  <server>
    <id>my.snapshots</id> <!-- use name of the mirror here -->
    <username>user</username>
    <password>pwd</password>
  </server>
</servers>

<!-- map mirror names to actual repositories -->
<mirrors>
  <!-- leave the default mirror in place -->
  <mirror>
    <id>archiva.default</id>
    <mirrorOf>*</mirrorOf>
    <url>http://server:port/archiva/repository/internal/</url>
  </mirror>
  <!-- enter my own -->
  <mirror>
    <id>my.snapshots</id>
    <mirrorOf>archiva.snapshots</mirrorOf>
    <url>http://server:port/archiva/repository/snapshots/</url>
  </mirror>
<mirrors>

<!-- activate the repo for artifact downloads by setting profile -->
<profiles>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <repositories>
    <repository> <!-- mirror will be used during runtime instead of this -->
      <id>archiva.snapshots</id> <!-- do not use mirror name here -->
      <url>http://server:port/archiva/repository/snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
</profile>

<mirrors>セクションとセクションでは異なる ID を指定する必要があることがわかった<profiles>ので、Raghuram と同じ名前を付けることは許可されていないようでした。

ここで、settings.xml が配置されたので<distributionManagement>、プロジェクトの pom.xml のセクションを変更することに着手しました。正確には、すべてのプロジェクトの親である pom でこの設定を変更しました。これには主に<distributionManagement>セクションが含まれ、それ以外はほとんど含まれていません。この親 pom 自体がアーカイブにデプロイされます。

これは、親 pom.xml の関連セクションです。

<distributionManagement>
  <repository>
    ...
  </repository>
  <snapshotRepository>
    <id>my.snapshots</id>
    <name>Archiva Managed Snapshot Repository</name>
    <url>http://server:port/archiva/repository/snapshots</url>
    <layout>default</layout>
  </snapshotRepository>
</distributionManagement>

この種の合理化されたものには、いくつかの利点があると思います。

  • 自分のアーティファクト (親 pom を含む) に依存するプロジェクトをビルドできるようになりました。これらのアーティファクトをローカル ビルド リポジトリに置く必要はありません (これをテストするためにローカル リポジトリを消去しました)。

  • ダウンロード ( <dependencies>pom.xml のセクション) とアップロード ( <distributionManagement>pom.xml のセクション) は、ミラーを介して処理されるようになりました。

于 2011-09-22T13:26:04.030 に答える
1

多くの試行錯誤を経て、私も上記の構成と非常によく似た構成にたどり着きましたが、以下の構成を行うまでうまくいきませんでした。したがって、ローカルホストで使用するのではなく、組織のリポジトリの助けを借りてmavenを使用している場合、回答を改善するために投稿しています。

この回答は、組織内で維持されている複数のリポジトリに対して複数のミラー構成が必要な場合の例です。これは例として役立ちます。

my.snapshots ユーザー pwd

<!-- map mirror names to actual repositories -->
<mirrors>
   <!-- enter my own -->
  <mirror>
    <id>my.snapshots</id>
    <mirrorOf>archiva.snapshots</mirrorOf> <!-- this name should be the same as configured for the below repository id.>
    <url>http://server:port/archiva/repository/snapshots/</url>
  </mirror>
  <!-- leave the default mirror in place -->
  <mirror>
    <id>archiva.default</id>
    <mirrorOf>central</mirrorOf> < !-- Instead of *, replace it with "central"-->
    <url>http://server:port/archiva/repository/internal/</url>
  </mirror>
<mirrors>

<!-- activate the repo for artifact downloads by setting profile -->
<profiles>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <repositories>
    <repository> <!-- mirror will be used during runtime instead of this -->
      <id>archiva.snapshots</id> <!-- do not use mirror name here -->
      <url>http://server:port/archiva/repository/snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
</profile>
于 2014-08-25T15:30:21.097 に答える