I need to set a http header "Content-Type: application/json" when uploading my test data with wagon:upload. I am setting the server as described in: Advanced Configuration of the HttpClient HTTP Wagon
Here is my wagon configuration in the pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<serverId>wagon-upload-test-data</serverId>
<url>http://localhost:8000/</url>
<fromDir>${project.basedir}/src/test/resources/testdata/</fromDir>
</configuration>
<executions>
<execution>
<id>upload-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
</plugin>
And here is the maven settings configuration of the servers:
<settings>
...
<servers>
<server>
<id>wagon-upload-test-data</id>
<configuration>
<!-- also tried with and without global configuration -->
<httpHeaders>
<httpHeader>
<name>Content-Type</name>
<value>application/json</value>
</httpHeader>
</httpHeaders>
<httpConfiguration>
<all> <!-- also tried with put -->
<useDefaultHeaders>false</useDefaultHeaders> <!-- tried with true -->
<headers>
<header>
<name>Content-Type</name>
<value>application/json</value>
</header>
<header>
<name>Accept</name>
<value>*/*</value>
</header>
</headers>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
</settings>
When I call the plugin, it executes fine, my test data is being put on the server, but the server settings seem to be ignored - here is the HTTP PUT request that I always get on my test server:
cache-control: no-cache
cache-store: no-store
pragma: no-cache
expires: 0
accept-encoding: gzip
content-length: 132
host: localhost:8000
connection: Keep-Alive
user-agent: Apache-HttpClient/4.3.5 (java 1.5)
x-php-ob-level: 0
{
"users": [{
"username" : "dummyMachine",
"score" : 3456
}, {
"username" : "dumminister",
"score" : 4125
}]
}
In order to make sure that the correct maven settings file was used, I also ran wagon:upload with the -X tag, here are some logs:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T18:41:47+02:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_92, vendor: Oracle Corporation
...
Reading global settings from /usr/local/Cellar/maven/3.3.9/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/martindobrev/.m2/settings.xml
---> COMMENT: THE SETTINGS FILE USED IS THE CORRECT ONE !!!
...
...
[DEBUG] Goal: org.codehaus.mojo:wagon-maven-plugin:1.0:upload (default-cli)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<excludes>${wagon.excludes}</excludes>
<followSymLink default-value="false">${wagon.followSymLink}</followSymLink>
<fromDir default-value="${project.basedir}">/PATH_TO_M/src/test/resources/testdata/</fromDir>
<includes>${wagon.includes}</includes>
<optimize default-value="false">${wagon.optimize}</optimize>
<project default-value="${project}"/>
<serverId default-value="serverId">wagon-upload-test-data</serverId>
<settings default-value="${settings}"/>
<skip default-value="false">${wagon.skip}</skip>
<toDir default-value="">${wagon.toDir}</toDir>
<url>http://localhost:8000/</url>
<useDefaultExcludes default-value="true">${wagon.useDefaultExcludes}</useDefaultExcludes>
</configuration>
What am I doing wrong? Can someone please help me fix this problem!!!
ADDITIONAL INFO: 13.10.2016
I tried different versions of maven and wagon-upload - nothing seems to work. Here is a simple project on github to test the problem