tekumara
tekumara

Reputation: 8807

Maven deploy to relative directory path

I can deploy to an absolute directory:

<distributionManagement>
    <repository>
        <id>absolute directory</id>
        <url>file:///home/tukushan/workspace/omcutil/repo</url>
    </repository>
</distributionManagement>

But how do I deploy to a directory relative to my project's directory?

Upvotes: 12

Views: 16593

Answers (3)

Jason
Jason

Reputation: 606

This is a very old thread, but so are the answers.

@tekumara's answer works fine, but only for maven version <= 2

this works for 3+

mvn deploy -DaltDeploymentRepository=local::file:./target/staging-deploy

ref: https://maven.apache.org/plugins/maven-deploy-plugin/examples/deploy-network-issues.html#deploying-to-a-local-directory

note - this also explains and solves the "ArtifactDeployerException: Failed to retrieve remote metadata.." error mentioned below.

Upvotes: 0

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77931

I don't think it can be done. File URLs require a mount point on the server, for example:

file://hostname/path/to/file

So, for a file on the local filesystem simply omits the "hostname" component (Explaining the 3 leading slashes):

file:///path/to/file

A relative path on the other hand assumes a starting position in the remote filesystem... Something that is impossible to support if one wants a URL to be unambiguous.

Upvotes: 0

tekumara
tekumara

Reputation: 8807

A relative directory can be specified when using the -DaltDeploymentRepository parameter, e.g.:

mvn deploy -DaltDeploymentRepository=snapshot-repo::default::file:../../my-local-snapshots-dir

The file URL is relative to the directory in which mvn is run.

See here for more info on the altDeploymentRepository parameter.

Upvotes: 20

Related Questions