I am attempting to replace our internal Ivy repository with Artifactory and converting everything to Maven. The current repository is hosted on one of our servers in subversion and I am trying to get away from this. My biggest question has to do with the markdown of the ivy.xml and how it relates to pom.xml. I used the ant task makepom to convert but it seems to exclude the configurations and the publications section in the ivy.xml file. To be honest, I am new to ivy and maven and can't seem to find anything that explains this is maven terms. The particular file in question looks like this
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../../../xsl/ivy-doc.xsl"?>
<ivy-module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="../../../../xsd/ivy.xsd">
<info organisation="net.java.dev.jna" module="jna" revision="3.4.0" status="release" publication="20111210120000">
<license name="GNU Lesser General Public License, version 2.1 or later" url="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html"/>
<ivyauthor xmlns:ivyde="http://ant.apache.org/ivy/ivyde/ns/" name="Ivy RoundUp Repository" url="https://github.com/archiecobbs/ivyroundup/blob/master/src/modules/net.java.dev.jna/jna/3.4.0/"/>
<repository xmlns:ivyde="http://ant.apache.org/ivy/ivyde/ns/" pattern="https://raw.githubusercontent.com/archiecobbs/ivyroundup/master/repo/modules/[organisation]/[module]/[revision]/ivy.xml" ivys="true" url="https://github.com/archiecobbs/ivyroundup" name="ivyroundup"/>
<description homepage="https://github.com/java-native-access/jna">
</info>
<configurations>
<conf name="core" description="JNA core library"/>
<conf name="platform" description="JNA platform library"/>
<conf name="default" extends="core,platform" description="JNA core + platform library"/>
</configurations>
<publications>
<artifact name="jna" ext="pom" type="pom"/>
<artifact conf="core" name="jna"/>
<artifact conf="core" name="jna-source" type="source" ext="zip"/>
<artifact conf="core" name="jna-javadoc" type="javadoc" ext="zip"/>
<artifact conf="platform" name="platform"/>
<artifact conf="platform" name="platform-source" type="source" ext="zip"/>
<artifact conf="platform" name="platform-javadoc" type="javadoc" ext="zip"/>
</publications>
The pom file I have created looks like so
<?xml version="1.0" encoding="UTF-8"?>
<!--
Apache Maven 2 POM generated by Apache Ivy
http://ant.apache.org/ivy/
Apache Ivy version: 2.4.0 20141213170938
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<packaging>jar</packaging>
<version>3.4.0</version>
<url>https://github.com/java-native-access/jna</url>
</project>
I've omitted some of the code connecting to our server. Trying to publish with maven publishes an empty jar file, I want to just publish the existing 3rd party jar. Any ways, if I could get some more clarification on migrating that publications block over to the pom file, that would be great.
Related
I have a module that was published on my own repository. Its ivy.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="myorg" module="mymodule" revision="1.5" status="integration" publication="20161222140109"/>
<configurations>
<conf name="compile" visibility="public"/>
</configurations>
<publications>
<artifact name="myartifact" type="zip" ext="zip" conf="compile"/>
</publications>
<dependencies/>
</ivy-module>
In another gradle project, I use this dependency:
configurations {
compile
}
dependencies {
compile 'myorg:mymodule:1.5'
}
What I expected was, that gradle would use the "compile"-configuration in my gradle script to download the "compile"-configuration of the ivy dependency.
What actually happens is that I get an error because Gradle searches for a "default" ivy-configuration.
I know how I can add the configuration info to the dependency with configuration: 'compile' (see this question) but I would not like to do that manually if there is a more elegant way.
Question: Was I wrong by believing that Gradle uses the configurationName in the dependency declaration to search for the matching ivy-configuration? And do I really have to configure each ivy-configuration manually if I don't use default?
I'm trying to understanding and using ivy with archiva, but i have this strange thing that i can't explain,
Build.xml
...some xml code
<target name="resolveArchiva" description="--> go take the jar">
<ivy:settings file="./archivaIvySetting.xml" >
<credentials host="my host to Archiva" realm="my repository's name"
username="user" passwd="passwd"/>
</ ivy:settings>
<ivy:retrieve />
</target>
some other code....
Ivy.xml
<ivy-module version="2.0">
<info organisation="archiva" module="my-repo"/>
<dependencies>
<dependency org="annogen" name="annogen" rev="0.1.0"/>
<dependency org="commons-lang" name="commons-lang" rev="2.1" />
</dependencies>
</ivy-module>
arvchivaIvySetting.xml
<ivysettings>
<settings defaultResolver="archiva" />
<resolvers>
<ibiblio name="archiva" m2compatible="true" root="repositories/internal/"/>
</resolvers>
</ivysettings>
the problem it's that in my repo there is an artifact for annogen but it's not present the common-lang artifact, despite that, the build says that it find the artifacts for both the dependencies, and that's true because i find both .jar in my lib project. How is it possible? it's clear that my setting doesn't point to the archiva rep but to the maven ones but how can i change it?
Hi I want to make empty project (without source), which to use my jar helloWorldPlugin and to manipulate with the ivy descriptor so I made build.gradle in an empty project dir with content:
apply plugin: 'java'
apply plugin: 'ivy-publish'
publishing {
publications {
myPublication(IvyPublication) {
from components.java
}
repositories {
ivy {
url "$project.rootDir/build/publish"
}
}
}
When I execute
gradle publishmyPublicationPublicationToIvyRepository
I get xml descriptor
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0">
<info organisation="org.moo" module="ivypublish" revision="9.0-m1-SNAPSHOT" status="integration" publication="20130710180056"/>
<configurations>
<conf name="default" visibility="public" extends="runtime"/>
<conf name="runtime" visibility="public"/>
</configurations>
<publications>
<artifact name="ivypublish" type="jar" ext="jar" conf="runtime"/>
</publications>
<dependencies>
<dependency org="org.moo" name="helloWorldPlugin" rev="9.2-m1-SNAPSHOT" conf="runtime->default" revConstraint="latest.milestone"/>
</dependencies>
</ivy-module>
1.But I don't have all java plugins configurations like test, compile etc. why?
2.If I don't write from components.java in the xml file there is only tag and other tags like dependencies, conf are empty. WHy?
3.How to make Gradle to write all java plugin configurations in the ivy descriptor?
A little late here but I believe this may be missing a configurations section in the myPublication. e.g.
configurations {
unitTests { extend 'runtime' }
}
and then an associated artifact and task definition for the unit test configuration
It's it possible with Maven to share common controllers, jsp's and other resources to the web module.
Structure
web1 (packaging jar)
--main
--java
--controller
MyControllerToShared with #Controller annotation
--resources
--webapp
--scripts
javascripts files
--styles
css files
--WEB-INF
--views
jsp to share
pom.xml
web2 (packaging war)
Classic web app structure with dependency of web1.jar
My web2 app works but no mapping found for HTTP request with URI define in web1 module. I use annotation #Controller and #RequestMapping. I defined in the servlet.xml:
<context:component-scan base-package="controller" />
<mvc:annotation-driven/>
How can I share controllers and resources between different web modules?
At the end, I need to have 3 web app with commons stuffs (error handler, jsp's errors, styles, js, ...).
Why don't you just create an extra project with all the shared resources? You can reuse that in all your web apps, just include the shared file in your pom.xml as a dependency.
You can start with an additional project with the shared resources:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>nl.connexys</groupId>
<artifactId>shared</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Shared resources</name>
</project>
In your webapp project you can then use that project as a dependency:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>nl.connexys</groupId>
<artifactId>webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Webservice endpoints</name>
<dependencies>
<dependency>
<groupId>nl.connexys</groupId>
<artifactId>shared</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
But this is all very basic Maven stuff. I think the examples should point you in the right direction.
Take a look at this answer:
https://stackoverflow.com/a/14143954/600007
, and the refernce for that: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
It will work for jsp-s, js-s, etc...
I am trying to understand how to manage this situation, suppose I have a 3rd party library (best-lib) that consists of three jars (a.jar, b.jar, c.jar) and I will be uploading those jars to a personal Artifactory server, the (best-lib) has two versions 1.0 and 2.0.
What I would like to have in my ivy.xml file is one single dependency to retrieve all those jars at once for example:
<dependencies>
<dependency org="mycompany" name="best-lib" rev="1.0" />
</dependencies>
And this dependency should add all three jars (a, b, and c) of version 1.0.
The question is:
Is this possible?
How can I upload the three jars to artifactory to achieve this behaviour?
Is it possible to upload those jars all at once?
Artifactory alternative solutions are also acceptable (e.g. Nexus or Archivia).
Note: I am not building best-lib I just have its jars, and best-lib is not a library that can be downloaded from a public maven2 repository.
Thanks.
When publishing the "best-lib" module, use an ivy.xml file that lists the 3 jars published by the module:
<ivy-module version="2.0">
<info organisation="mycompany" module="best-lib"/>
<publications>
<artifact name="a" type="jar"/>
<artifact name="b" type="jar"/>
<artifact name="c" type="jar"/>
</publications>
..
..
When you create a dependency against this module, ivy will understand that there are 3 jars in this module.
For an example of how to publish an ivy module see:
Issues using ivy:publish task
Update
If the 3 jars are already in your repository you could publish a stand-alone ivy modules that references the other 3 as dependencies:
<ivy-module version="2.0">
<info organisation="mycompany" module="best-lib" rev="1.0"/>
<dependences>
<dependency org="mycompany" name="a" rev="1.0" />
<dependency org="mycompany" name="b" rev="1.0" />
<dependency org="mycompany" name="c" rev="1.0" />
</dependencies>
Finally, you may need to tell us what format your Artifactory repository uses.... I have been assuming it's an ivy repo. If it's Maven then the concepts are the same but obviously server-side we'd be talking about pom.xml files, instead of ivy.xml (Ivy supports Maven repositories).