最近 Artifactory インスタンスでセキュリティを有効にしたため、いくつかの問題が発生しました。1つは残っており、少し奇妙に思えます:
Maven は HTTP HEAD を使用して、新しい SNAPSHOT がデプロイされているかどうかを確認します。ただし、セキュリティが有効になっている場合、最初の呼び出しは認証ヘッダーなしで行われるため、Artifactory から 401 応答が返されます。
その後、Maven は認証ヘッダーを使用して同じ呼び出しを実行することになっています。これは、maven-metadata.xmlファイルの場合です。
ただし、.pom および .jar ファイルの場合、以下のログに示すように、リクエストは再試行されません。
20150303104244|3|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml|HTTP/1.1|401|0
20150303104244|12|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml|HTTP/1.1|200|322
20150303104244|40|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml.sha1|HTTP/1.1|200|40
20150303104244|4|REQUEST|xxx.xxx.xxx.xxx|user|GET|/libs-snapshot-local/mycompany/common/common-config/1.0.4-SNAPSHOT/maven-metadata.xml.md5|HTTP/1.1|200|32
20150303104245|2|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|HEAD|/libs-snapshot-local/mycompany/myproject/myproject-interface/2.0.0-SNAPSHOT/myproject-interface-2.0.0-SNAPSHOT.jar|HTTP/1.1|401|0
20150303104245|2|REQUEST|xxx.xxx.xxx.xxx|non_authenticated_user|HEAD|/libs-snapshot-local/mycompany/myproject/myproject-interface/2.0.0-SNAPSHOT/myproject-interface-2.0.0-SNAPSHOT.jar|HTTP/1.1|401|0
説明したように、maven-metadata.xml ファイルのダウンロードはユーザー資格情報で再試行されますが、myproject-interface-2.0.0-SNAPSHOT.jarは再試行されません。
そのサーバーのプリエンティブ認証を有効にしようとしましたが、Maven の動作に変化が見られませんでした:
<server>
<id>snapshot</id>
<username>user</username>
<password>xxx</password>
<configuration>
<httpConfiguration>
<all>
<usePreemptive>true</usePreemptive>
<params>
<property>
<name>http.authentication.preemptive</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
これは、既存の SNAPSHOT の更新にのみ関係します。新しいアーティファクトのダウンロードは、認証ヘッダーを含む HTTP GET で行われるためです (少なくとも再試行が必要です)。これにより、SNAPSHOT アーティファクトを正しく使用できなくなります。
Maven 3.2.1 と Artifactory 3.4.2 を使用しています。