rpm classifier & publishing

478 views
Skip to first unread message

Eric Bowman

unread,
Sep 17, 2012, 9:15:07 PM9/17/12
to simple-b...@googlegroups.com
Hi,

I'm trying to figure out how to publish an rpm to Nexus using 0.12.0.

The "Defining Custom Artifacts" section at https://github.com/harrah/xsbt/wiki/Artifacts doesn't seem to work; calling addArtifact doesn't seem to have any effect; it's not obvious which is the right version of that method to call, though -- at settings time we don't really know the productId (do we?)

I ended up with code like this, and the package command does what I want (builds the jar, then builds an rpm):

  val packageRpm = TaskKey[File]("package-rpm", "package an rpm")

  lazy val defaultArtifactTasks
: Seq[TaskKey[File]] =
   
(packageRpm in Compile) +: Classpaths.defaultArtifactTasks
 
import Classpaths.{artifactDefs, packaged}

  lazy val rpmSettings
: Seq[Setting[_]] =  Seq(
      packageRpm
<<= RpmKeys.rpmTask,
     
Keys.`package` <<= packageRpm,
      publishTo
<<= yumPublishTo,
      publishArtifact
in packageRpm := true,
      artifactClassifier
in packageRpm := Some("rpm"),
      artifacts
<<= artifactDefs(defaultArtifactTasks),
      packagedArtifacts
<<= packaged(defaultArtifactTasks)
 
)


But, artifacts and packageArtifacts don't end up with what I want; they only hold the jar, src & doc artifacts:

foo > project foo-server
foo
-server > package-rpm
[info] Packaging /foo/core/target/foo-core-0.0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] Packaging /foo/server/target/foo-server-0.0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] Built rpm /foo/server/target/dist/foo-server-0.0.1-SNAPSHOT-1.noarch.rpm
[success] Total time: 4 s, completed Sep 18, 2012 2:04:20 AM
foo
-server > artifacts
[info] List(Artifact(foo-server,jar,jar,None,List(compile),None,Map()), Artifact(foo-server,src,jar,Some(sources),List(sources),None,Map()), Artifact(foo-server,doc,jar,Some(javadoc),List(docs),None,Map()))
foo
-server > packaged-artifacts
[info] Packaging /foo/core/target/foo-core-0.0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] Generating Scala API documentation for main sources to /foo/server/target/api...
[info] Packaging /foo/server/target/foo-server-0.0.1-SNAPSHOT.jar ...
[info] Done packaging.
model contains
51 documentable templates
[info] Scala API documentation generation successful.
[info] Packaging /foo/server/target/foo-server-0.0.1-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[success] Total time: 4 s, completed Sep 18, 2012 2:08:44 AM


Any idea what I'm doing wrong?  These settings are the last ones set, so it doesn't seem like they're getting trampled.

I was able to confirm that my artifact tasks are making it into Classpaths.packaged and Classpaths.artifactDefs, but it's like they don't survive that, though I can't figure out why. I'm struggling to understand what those methods do.

Any help much appreciated -- I feel like I must be missing something essential.

Thanks,
Eric



Josh Suereth

unread,
Sep 17, 2012, 9:56:09 PM9/17/12
to simple-b...@googlegroups.com

Hey, the native packager plugin has publishing settings you can use to rpm:publish.

See the build of http://github.com/sbt/sbt-launcher-package for an example, and ask if you need any help!

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/W84dnn87TTsJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Eric Bowman

unread,
Sep 18, 2012, 3:39:09 AM9/18/12
to simple-b...@googlegroups.com
On Tuesday, September 18, 2012 2:56:13 AM UTC+1, jsuereth wrote:

Hey, the native packager plugin has publishing settings you can use to rpm:publish.

See the build of http://github.com/sbt/sbt-launcher-package for an example, and ask if you need any help!


Cool, thanks. I'll check it out. 

Eric Bowman

unread,
Sep 18, 2012, 3:45:29 AM9/18/12
to simple-b...@googlegroups.com
You probably meant https://github.com/sbt/sbt-native-packager, right? :)

Eric Bowman

unread,
Sep 18, 2012, 4:21:56 AM9/18/12
to simple-b...@googlegroups.com
Ok, this was a big help, but doesn't do quite what I want, but it's close. So I'm wondering whether it's hard to get it to do what I want, or whether I should just try to work around it.  I ended up just copying makeDeploymentSettings, and doing something like the below. This was a big step forward after a day of spinning my wheels. :)

  lazy val rpmSettings: Seq[Setting[_]] =  Seq(
      packageRpm
<<= RpmKeys.rpmTask,
     
Keys.`package` <<= packageRpm,

     
Keys.publishLocal <<= publishLocal in (Rpm),
      publishTo
<<= GiltRpm.yumPublishTo,

      publishArtifact
in packageRpm := true,

      artifactClassifier
in packageRpm := Some("rpm")) ++ makeDeploymentSettings(Rpm, packageRpm, "rpm")



1. rpm:publish and rpm:publish-local work now, but I can't figure out how to get it so they happen when I just run publish or publish-local.  I tried publishLocal <<= publishLocal in (Rpm), but that didn't work.
2. There's no "rpm" config showing up in my ivy file. Not too sure if I care, but it seems odd.
3. I'd prefer the RPM end up in our Nexus + Yum Repo Plugin with the same name as I've given it.

For example, foo-0.0.1-SNAPSHOT-1.noarch.rpm gets published as svc-freefall.rpm

I reckon it's fighting against the ivy current to change its name, but it makes life easier on the consume side (unless the Nexus Yum plugin is able to do some magic here ... I'm not sure if it can or not ... seems unlikely, especially without a config in the ivy file).

Thanks for all the help!

cheers,
Eric

Josh Suereth

unread,
Sep 18, 2012, 7:26:46 AM9/18/12
to simple-b...@googlegroups.com


On Sep 18, 2012 3:45 AM, "Eric Bowman" <ebo...@gilt.com> wrote:
>
> You probably meant https://github.com/sbt/sbt-native-packager, right? :)
>

Not for the example :-)

>
> On Tuesday, September 18, 2012 8:39:09 AM UTC+1, Eric Bowman wrote:
>>
>> On Tuesday, September 18, 2012 2:56:13 AM UTC+1, jsuereth wrote:
>>>
>>> Hey, the native packager plugin has publishing settings you can use to rpm:publish.
>>>
>>> See the build of http://github.com/sbt/sbt-launcher-package for an example, and ask if you need any help!
>>
>>
>> Cool, thanks. I'll check it out. 
>

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/DePxZ92y8xEJ.

Josh Suereth

unread,
Sep 18, 2012, 7:31:11 AM9/18/12
to simple-b...@googlegroups.com

Any chance I can see more of the build?

My publishing limits to artifact name specifically so sbt.msi, sbt.rpm, etc. are all available in a versioned directory.

If you look at the publishing setting code for sbt native packager, it should give you a hint at how to define your own ivy repository layout and adjust the artifact name/version to give you what you want!

Basically, the artifact + publishedArtifact settings have to line up.   If you want the rpm published from root config, modify these setting there rather than "in Rpm"

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/kXFtlWviHIgJ.

Eric Bowman

unread,
Sep 18, 2012, 8:38:55 AM9/18/12
to simple-b...@googlegroups.com


On Tuesday, September 18, 2012 12:26:50 PM UTC+1, jsuereth wrote:


On Sep 18, 2012 3:45 AM, "Eric Bowman" <ebo...@gilt.com> wrote:
>
> You probably meant https://github.com/sbt/sbt-native-packager, right? :)
>

Not for the example :-)


I see. We're building RPM using redline, not rpmbuild, so sbt-native-packager was a lot more interesting. :) 

Josh Suereth

unread,
Sep 18, 2012, 10:16:12 PM9/18/12
to simple-b...@googlegroups.com

Does there need to be special support for redline?   Let me know, I accept pull requests :-)

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/X4pNFD78CoYJ.

Eric Bowman

unread,
Sep 19, 2012, 3:33:28 AM9/19/12
to simple-b...@googlegroups.com
Yeah, that might just work. Some parts are a little specialized but I'd love if this were supported by the plugin. Once it's working I'll definitely see can I add it

Cheers,
Eric

--
Eric Bowman
Reply all
Reply to author
Forward
0 new messages