Ivy 和快照 (Nexus)

发布于 2024-09-04 18:08:17 字数 4985 浏览 3 评论 0原文

我正在使用 ant、ivy 和 Nexus 存储库管理器来构建和存储我的工件。我设法让一切正常工作:依赖关系解析和发布。直到我遇到问题......(当然!)。

我正在发布到 nexus 中的一个“发布”存储库,该存储库被锁定为“禁用重新部署”(即使您将设置更改为“允许重新部署”(在我看来,那里的 UI 真的很蹩脚)。你可以想象当我看到这个时我有多生气在我意识到发生这种情况之前,我的更改并未通过存储库进行更新。

无论如何,我现在必须切换所有内容以在关系中使用“快照”存储库。问题是这弄乱了我的发布。的事情,包括广泛的谷歌搜索,但没有得到任何结果。我得到的错误是一个错误的 PUT 请求,错误代码 400。

有谁能做到这一点,请给我指出我所缺少的内容。

非常感谢。 ,

阿拉斯泰尔

参考,这是我的配置:

请注意,我已删除了使快照正常工作的任何尝试,因为我不知道什么实际上(可能)有用,什么是完整的废话,因此这也是仅工作的设置。

仅供 ,请注意,我添加了 XXX-API ivy.xml 仅供参考,我什至无法发布 xxx-common(而且甚至没有依赖项)。

Ant 任务:

<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> 

几个 ivy 文件,用于了解内部依赖关系:

XXX-Common 项目:

<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 项目:

<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>

I'm using ant, ivy and nexus repo manager to build and store my artifacts. I managed to get everything working: dependency resolution and publishing. Until I hit a problem... (of course!).

I was publishing to a 'release' repo in nexus, which is locked to 'disable redeploy' (even if you change the setting to 'allow redeploy' (really lame UI there imo). You can imagine how pissed off I was getting when my changes weren't updating through the repo before I realised that this was happening.

Anyway, I now have to switch everything to use a 'Snapshot' repo in nexus. Problem is that this messes up my publish. I've tried a variety of things, including extensive googling, and haven't got anywhere whatsoever. The error I get is a bad PUT request, error code 400.

Can someone who has got this working please give me a pointer on what I'm missing.

Many thanks,

Alastair

fyi, here's my config:

Note that I have removed any attempts at getting snapshots to work as I didn't know what was actually (potentially) useful and what was complete guff. This is therefore the working release-only setup.

Also, please note that I've added the XXX-API ivy.xml for info only. I can't even get the xxx-common to publish (and that 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> 

Couple of ivy files to give an idea of internal dependencies:

XXX-Common 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

戏剧牡丹亭 2024-09-11 18:08:17

w00h00t。

(向全世界寻求帮助有一种宣泄作用。通常,即使没有回应,你也能更快地解决问题)。

不管怎样,对于感兴趣的人来说,它可以归结为以下几件事:

a) 在所有修订中添加 -SNAPSHOT。这涉及到分叉第二个 ivy.xml -> ivy.SNAPSHOT.xml 并在 ivy ant 任务中显式引用它。
b) 鉴于这是手动添加,我必须遍历整个构建文件树并为发布和快照流程提供并行路径。在我看来,这是蹩脚的。但是,正如我猜想我们极不可能发明任何其他类型的流,这可能不会膨胀,并且 2 个并行流将保留。
c) 我向 ivy 指定了各种提示来检查快照的更新。例如解析器上的 checkUpdated="true"changePattern=".*-SNAPSHOT"。另外

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

,如果能够与快照内容自动集成,那就太好了。 ivy 的一点点(可选的)聪明才智。让我们面对现实吧,像 nexus 这样的 Maven 存储库确实很有用,而且我当然使用 ivy 只是为了绕过 Maven 蹩脚的构建过程。我喜欢使用nexus。

反正。如果有人想对此进一步提问,请随意。

w00h00t.

(There's something cathartic about asking the world for help. Usually you fix the problem much faster, even without a response).

Anyway, for the interested it came down to a couple of things:

a) the addition of -SNAPSHOT to all revisions. This involved forking a second ivy.xml -> ivy.SNAPSHOT.xml and referencing that explicitly in the ivy ant tasks.
b) given that this is a manual addition I had to go through my entire tree of build files and provide parallel paths for release and snapshot flows. This, in my opinion, is lame. But, as I guess we're extremely unlikely to invent any other type of flow, this probably won't bloat, and 2 parallel flows is where it will stay.
c) I specified various hints to ivy to check for updates to the snapshots. e.g. checkUpdated="true" and changePattern=".*-SNAPSHOT" on the resolver. And the addition of

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

Still, it'd be nice if there had been automatic integration with snapshot stuff. A bit of (optional) cleverness on the part of ivy. Let's face it, maven repos like nexus ARE really useful and I'm certainly using ivy only to get round maven's crappy build process. I like using nexus.

Anyway. If anyone ever wants to question further on this, feel free.

丿*梦醉红颜 2024-09-11 18:08:17

我不确定这是否有助于解决拥有 2 套配置的问题,但至少 build.xml 会更简单一些。

您可以在 ivy.xml 中的 info 元素上将 revision 属性定义为 ${project.revision}。

然后,您可以省略 build.xml 中 ivy 元素上的 revision="${project.revision}" 属性。

例如,请参阅我对另一个问题的回答:
https://stackoverflow.com/a/8853823/1148030

I'm not sure if this would help with the problem of having 2 sets of configurations, but at least the build.xml would be a little bit simpler.

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

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

See my answer on this another question for example:
https://stackoverflow.com/a/8853823/1148030

束缚m 2024-09-11 18:08:17

应该注意的是,唯一必要的步骤是在发布到 Nexus 时将“-SNAPSHOT”包含到修订版中。答案中列出的其他步骤是可选/改进。要下拉已发布的项目,您还需要将“-SNAPSHOT”添加到修订版本中。

It should be noted, the only necessary step is to include the '-SNAPSHOT' to revision when publishing to Nexus. The other steps listed in the answer are optional/improvements. To pull the published item down, you need to add '-SNAPSHOT' to the revision as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文