![](/img/trans.png)
[英]How use username and password in artifactory-maven-plugin from settings.xml?
[英]How can I tell wagon-maven-plugin to use a username and password from my settings.xml?
我正在使用名為maven-enunciate-plugin的插件生成rest api的(非javadoc)文檔。 現在我想將它上傳到我的javadoc存儲庫。 我正在使用wagon-maven-plugin 。
問題是,我無法弄清楚如何告訴wagon插件在本網站的settings.xml中使用用戶名/密碼。 如果您使用maven-site-plugin ,它似乎知道如何通過定義distributionManagement
標記來實現這一點,但我沒有使用maven-site-plugin插件,因為我在沒有它的情況下生成文檔。
這是我的pom來展示我嘗試過的東西:
<profile>
<id>generate-rest-doc</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.27</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
<configuration>
<docsDir>${project.build.directory}/docs</docsDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<executions>
<execution>
<id>upload-javadoc</id>
<phase>package</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.build.directory}/docs</fromDir>
<includes>*</includes>
<url>scp://MY-REPO/var/www/html/projects/rest-war</url>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<site>
<id>javadoc</id>
<url>scp://MY-REPO/var/www/html/projects/-rest-war</url>
</site>
</distributionManagement>
</profile>
....
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
</build>
在搜索這個問題的解決方案時遇到了這篇博文: http : //blog.darrenscott.com/2010/08/05/uploading-files-using-scp-and-the-maven-wagon-plugin/您需要在configuration
使用serverId
屬性。 希望這有助於某人。
我想出了一個解決方法。 我沒有直接使用wagon-maven-plugin,而是使用maven-site-plugin。 我明確使用部署目標指向maven-enunciate-plugin生成的目錄。
所以上面我注釋了wagon插件並在enunciate插件下面添加了這個:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>upload-javadoc</id>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<inputDirectory>${project.build.directory}/docs</inputDirectory>
</configuration>
</execution>
</executions>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.