Pros and Snapshots (Nexus)

I use ant, ivy and nexus repo manager to create and store my artifacts. I managed to get everything to work: resolving dependencies and publishing. Until I get into the problem ... (of course!).

I published the "release" repository to nexus, which is locked for "disable redeploy" (even if you changed the setting to "allow redeploy" (really, the lame user interface is imo there). You can imagine how angry I was when my changes were not updated through the repo before I realized this was happening.

Anyway, now I need to switch everything to use the Snapshot repository in nexus. The problem is that it messed up my post. I tried a lot of things, including an extensive Google search, and was nowhere to be found. The error I get is a bad PUT request, error code 400.

Can someone who got this job give me a pointer to what I am missing.

Many thanks,

Alastair

fyi, here is my configuration:

Note that I deleted all attempts to get snapshots for work, as I did not know what was actually (potentially) useful and what was complete guff. This, therefore, is a production-only setup.

Also, note that I added the ivy.xml XXX-API for information only. I can't even publish xxx-common for publishing (and it doesn't even have dependencies).

Ant Task:

<target name="publish" depends="init-publish"> <property name="project.generated.ivy.file" value="${project.artifact.dir}/ivy.xml"/> <property name="project.pom.file" value="${project.artifact.dir}/${project.handle}.pom"/> <echo message="Artifact dir: ${project.artifact.dir}"/> <ivy:deliver deliverpattern="${project.generated.ivy.file}" organisation="${project.organisation}" module="${project.artifact}" status="integration" revision="${project.revision}" pubrevision="${project.revision}" /> <ivy:resolve /> <ivy:makepom ivyfile="${project.generated.ivy.file}" pomfile="${project.pom.file}"/> <ivy:publish resolver="${ivy.omnicache.publisher}" module="${project.artifact}" organisation="${project.organisation}" revision="${project.revision}" pubrevision="${project.revision}" pubdate="now" overwrite="true" publishivy="true" status="integration" artifactspattern="${project.artifact.dir}/[artifact]-[revision](-[classifier]).[ext]" /> </target> 

A couple of ivy files to give an idea of โ€‹โ€‹internal dependencies:

XXX-General project:

 <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"> <info organisation="com.myorg.xxx" module="xxx_common" status="integration" revision="1.0"> </info> <publications> <artifact name="xxx_common" type="jar" ext="jar"/> <artifact name="xxx_common" type="pom" ext="pom"/> </publications> <dependencies> </dependencies> </ivy-module> 

XXX-API Project:

 <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"> <info organisation="com.myorg.xxx" module="xxx_api" status="integration" revision="1.0"> </info> <publications> <artifact name="xxx_api" type="jar" ext="jar"/> <artifact name="xxx_api" type="pom" ext="pom"/> </publications> <dependencies> <dependency org="com.myorg.xxx" name="xxx_common" rev="1.0" transitive="true" /> </dependencies> </ivy-module> 

IVY Settings.xml:

 <ivysettings> <properties file="${ivy.project.dir}/project.properties" /> <settings defaultResolver="chain" defaultConflictManager="all" /> <credentials host="${ivy.credentials.host}" realm="Sonatype Nexus Repository Manager" username="${ivy.credentials.username}" passwd="${ivy.credentials.passwd}" /> <caches> <cache name="ivy.cache" basedir="${ivy.cache.dir}" /> </caches> <resolvers> <ibiblio name="xxx_publisher" m2compatible="true" root="${ivy.xxx.publish.url}" /> <chain name="chain"> <url name="xxx"> <ivy pattern="${ivy.xxx.repo.url}/com/myorg/xxx/[module]/[revision]/ivy-[revision].xml" /> <artifact pattern="${ivy.xxx.repo.url}/com/myorg/xxx/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <ibiblio name="xxx" m2compatible="true" root="${ivy.xxx.repo.url}"/> <ibiblio name="public" m2compatible="true" root="${ivy.master.repo.url}" /> <url name="com.springsource.repository.bundles.release"> <ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> <url name="com.springsource.repository.bundles.external"> <ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> <artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" /> </url> </chain> </resolvers> </ivysettings> 
+4
source share
3 answers

w00h00t.

(There is something strange about asking the world for help. Usually you fix the problem much faster, even without an answer).

In any case, for those interested, this boiled down to several things:

a) adding -SNAPSHOT to all revisions. This included deploying the second ivy.xml -> ivy.SNAPSHOT.xml and referencing it explicitly in ivy ant tasks. b) given that this is a manual addition, I had to go through the entire tree of assembly files and provide parallel paths for release streams and snapshots. This, in my opinion, is lame. But, as I believe, we are unlikely to invent any other type of flow, this is probably not inflated, but 2 parallel flows where it will remain. c) I have provided various tips to ivy for checking snapshot updates. for example checkUpdated="true" and changePattern=".*-SNAPSHOT" on the converter. And adding

 <modules org="myorg" name=*" resolveMode="dynamic" /> 

However, it would be nice if there was automatic integration with snapshot materials. A little (optional) skill from ivy. Let's face it, maven repos, like nexus, are really useful, and I certainly use ivy to get around the maven crappy build process. I like to use nexus.

Anyway. If anyone wants to talk further about this, feel free to.

+3
source

I'm not sure if this helps solve the problem with two sets of configurations, but at least build.xml will be a little easier.

You can define the revision attribute in the info element in ivy.xml as $ {project.revision}.

You can then omit the revision = "$ {project.revision}" attributes on the ivy elements in the build.xml file.

See my answer to this other question, for example: fooobar.com/questions/212368 / ...

+1
source

It should be noted that the only necessary step is to include "-SNAPSHOT" in the editorial office when publishing in Nexus. Other steps listed in the answer are optional / improvements. To pull out a published item, you also need to add '-SNAPSHOT' to the revision.

0
source

Source: https://habr.com/ru/post/1312064/


All Articles