You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Francois MAROT <fr...@gmail.com> on 2017/11/30 20:49:12 UTC

Best way to deploy a specific file and declare its dependencies

Hello all,

I have a need to explain to a third party how to deploy a jar on my
repository (Archiva). But
- this jar is not generated by Maven (it contains DLLs to be loaded through
JNA)
- I'd like the third party to be able to declare dependencies of this jar
(some zip containing some DLLs). So that by declaring a dependency on this
jar I will also get it's dependencies
- the goal is for me to make the third party totally independant and able to
update his artifact or it's dependencies without my supervision

I came with the following pom that he may use runnning:
mvn install -Drevision=1.0.0-WIN64-SNAPSHOT
-DfileToDeploy=some-jar_master.jar

Question is, is there anything simpler ? :)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	

	<groupId>com.oleamedical.io</groupId>
	<artifactId>test-breast</artifactId>
	<version>${revision}</version>

	<packaging>jar</packaging>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<revision>TO-OVERRIDE-ON-COMMAND-LINE</revision>
		<fileToDeploy>TO-OVERRIDE-ON-COMMAND-LINE</fileToDeploy>
	</properties>

	<dependencies>
	
        
		<dependency>
			<groupId>thirdparties.intel</groupId>
			<artifactId>redist-cpp</artifactId>
			<version>2017.5.267</version>
			<classifier>natives-win</classifier>
			<scope>runtime</scope>
			<type>zip</type>
		</dependency>

	</dependencies>

	<build>

		<plugins>
			<plugin>
				
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.8</version>
				<executions>
					<execution>
						<phase>package</phase>
						<configuration>
							<target>
								<copy file="${fileToDeploy}"
tofile="${project.build.directory}/${project.build.finalName}.jar"
overwrite="true" />
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>flatten-maven-plugin</artifactId>
				<version>1.0.1</version>
				<configuration>
					<updatePomFile>true</updatePomFile>
				</configuration>
				<executions>
					<execution>
						<id>flatten</id>
						<phase>process-resources</phase>
						<goals>
							<goal>flatten</goal>
						</goals>
					</execution>
					<execution>
						<id>flatten.clean</id>
						<phase>clean</phase>
						<goals>
							<goal>clean</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>

</project>



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best way to deploy a specific file and declare its dependencies

Posted by Anders Hammar <an...@hammar.net>.
I would recommend the deploy:deploy-file as it is a common way of doing
this. Having to update the pom file manually (the version you're talking
about) is a very small job.

/Anders

On Fri, Dec 1, 2017 at 9:31 AM, Francois MAROT <fr...@gmail.com>
wrote:

> Thanks for the reply Olivier, but I don't think I can "attach" . Let me
> explain:
>
> Basically, I want to deploy someJar.jar and at the same time declare a
> dependency:    someJar.jar --> redist-cpp.zip
>
> redist-cpp.zip is already stored in Archiva.
> someJar.jar is not produced by Maven.
>
> If I "attach" someJar.jar, then I have to attach it to a dummy empty main
> artifact that would serve no purpose other than to let someJar.jar being
> deployed alongside.
> Moreover, I think (not sure) that the dependencies of the main artifact are
> not dependencies of the attached artifacts. So I would not achieve my goal.
>
> I can not "attach" redist-cpp.zip because itis already stored on Archiva.
>
> I could maybe have used  mvn deploy:deploy-file
> <https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html>
> and use option "-DpomFile=" to point to a pom where I would define the
> dependency to redist-cpp.zip.
> Problem is that I would not be able to pass the version of my artifact on
> the command-line (see  Maven CI Friendly stuff
> <https://maven.apache.org/maven-ci-friendly.html>  ), I would have to
> change
> it in the pom on each deploy.
>
>
>
>
>
> --
> Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Best way to deploy a specific file and declare its dependencies

Posted by Francois MAROT <fr...@gmail.com>.
Thanks for the reply Olivier, but I don't think I can "attach" . Let me
explain:

Basically, I want to deploy someJar.jar and at the same time declare a
dependency:    someJar.jar --> redist-cpp.zip

redist-cpp.zip is already stored in Archiva.
someJar.jar is not produced by Maven.

If I "attach" someJar.jar, then I have to attach it to a dummy empty main
artifact that would serve no purpose other than to let someJar.jar being
deployed alongside.
Moreover, I think (not sure) that the dependencies of the main artifact are
not dependencies of the attached artifacts. So I would not achieve my goal.

I can not "attach" redist-cpp.zip because itis already stored on Archiva.

I could maybe have used  mvn deploy:deploy-file
<https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html>  
and use option "-DpomFile=" to point to a pom where I would define the
dependency to redist-cpp.zip.
Problem is that I would not be able to pass the version of my artifact on
the command-line (see  Maven CI Friendly stuff
<https://maven.apache.org/maven-ci-friendly.html>  ), I would have to change
it in the pom on each deploy.





--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Best way to deploy a specific file and declare its dependencies

Posted by Olivier Lamy <ol...@apache.org>.
Hi
Why not attaching the produced artifact?
See
http://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html

HTH
Olivier

On 1 December 2017 at 07:49, Francois MAROT <fr...@gmail.com>
wrote:

> Hello all,
>
> I have a need to explain to a third party how to deploy a jar on my
> repository (Archiva). But
> - this jar is not generated by Maven (it contains DLLs to be loaded through
> JNA)
> - I'd like the third party to be able to declare dependencies of this jar
> (some zip containing some DLLs). So that by declaring a dependency on this
> jar I will also get it's dependencies
> - the goal is for me to make the third party totally independant and able
> to
> update his artifact or it's dependencies without my supervision
>
> I came with the following pom that he may use runnning:
> mvn install -Drevision=1.0.0-WIN64-SNAPSHOT
> -DfileToDeploy=some-jar_master.jar
>
> Question is, is there anything simpler ? :)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://maven.apache.org/POM/4.0.0"
>         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>         <modelVersion>4.0.0</modelVersion>
>
>
>
>         <groupId>com.oleamedical.io</groupId>
>         <artifactId>test-breast</artifactId>
>         <version>${revision}</version>
>
>         <packaging>jar</packaging>
>
>         <properties>
>                 <project.build.sourceEncoding>UTF-8</project.build.
> sourceEncoding>
>                 <revision>TO-OVERRIDE-ON-COMMAND-LINE</revision>
>                 <fileToDeploy>TO-OVERRIDE-ON-COMMAND-LINE</fileToDeploy>
>         </properties>
>
>         <dependencies>
>
>
>                 <dependency>
>                         <groupId>thirdparties.intel</groupId>
>                         <artifactId>redist-cpp</artifactId>
>                         <version>2017.5.267</version>
>                         <classifier>natives-win</classifier>
>                         <scope>runtime</scope>
>                         <type>zip</type>
>                 </dependency>
>
>         </dependencies>
>
>         <build>
>
>                 <plugins>
>                         <plugin>
>
>                                 <artifactId>maven-antrun-
> plugin</artifactId>
>                                 <version>1.8</version>
>                                 <executions>
>                                         <execution>
>                                                 <phase>package</phase>
>                                                 <configuration>
>                                                         <target>
>                                                                 <copy
> file="${fileToDeploy}"
> tofile="${project.build.directory}/${project.build.finalName}.jar"
> overwrite="true" />
>                                                         </target>
>                                                 </configuration>
>                                                 <goals>
>                                                         <goal>run</goal>
>                                                 </goals>
>                                         </execution>
>                                 </executions>
>                         </plugin>
>
>                         <plugin>
>
>                                 <groupId>org.codehaus.mojo</groupId>
>                                 <artifactId>flatten-maven-
> plugin</artifactId>
>                                 <version>1.0.1</version>
>                                 <configuration>
>                                         <updatePomFile>true</
> updatePomFile>
>                                 </configuration>
>                                 <executions>
>                                         <execution>
>                                                 <id>flatten</id>
>                                                 <phase>process-resources</
> phase>
>                                                 <goals>
>
> <goal>flatten</goal>
>                                                 </goals>
>                                         </execution>
>                                         <execution>
>                                                 <id>flatten.clean</id>
>                                                 <phase>clean</phase>
>                                                 <goals>
>                                                         <goal>clean</goal>
>                                                 </goals>
>                                         </execution>
>                                 </executions>
>                         </plugin>
>
>                 </plugins>
>         </build>
>
> </project>
>
>
>
> --
> Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Olivier Lamy
http://twitter.com/olamy | http://linkedin.com/in/olamy