nhatminhle / cofoja

Contracts for Java
GNU Lesser General Public License v3.0
151 stars 18 forks source link

Provide a Maven Artifact #2

Closed nhatminhle closed 7 years ago

nhatminhle commented 10 years ago

From michael....@gmail.com on February 07, 2011 11:46:13

Please consider providing Maven artifacts so that mvn driven projects can consume your great work.

Original issue: http://code.google.com/p/cofoja/issues/detail?id=11

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on February 07, 2011 19:10:36

It seems Maven is pretty popular with the Java community these days, so this seems like something we should definitely do.

Now, the issue with this is that I've tried for a couple of hours to write a POM file that would delegate the build to Ant and still deploy properly, and I found it incredibly hard to do something I thought would be straightforward. Either we settle with a "jar" packaging and Maven insists on running its silly default goals which get into the way of Ant, or we use a "pom" packaging and the JAR file has to be deployed as a separate artifact. Only, the "proper" way to deploy externally compiled files is to use deploy:deploy-file, and it seems to be a known misfeature that deploy-file requires a URL parameter and does not honor distributionManagement, which is just stupid.

Since neither David nor Andreas knows any better about Maven than I do, and they have even less time than me, unless somebody with appropriate knowledge steps forward to help with the task, it is unlikely that we'll get around to getting shining Maven support anytime soon. Besides, given how inflexible the Maven build model seems to be, it wouldn't surprise me if we were never to get full Maven support for all the features found in the Ant build file (circular bootstrapping, proper testing with the Java agent, etc.) at all.

That being said, for the time being, we can settle for a simple POM file that duplicates the job of the most basic Ant rules (see attached file) but should get you going if you just want to install a copy of Cofoja in your local Maven repository: just drop the POM file at the root of the source tree and type 'mvn install' and you should be able to depend on com.google.java.contract:cofoja:jar afterwards. I've seen other projects do that (e.g. Guava), so we might as well, but this is completely suboptimal.

@David, @Andreas, what do you think? Should we just commit the simple POM file? The added maintenance cost of updating both rule sets is probably negligible; it's just a bit ugly...

Status: Accepted
Cc: andreasl...@google.com davidmor...@google.com

Attachment: pom.xml

nhatminhle commented 10 years ago

From andreasl...@google.com on February 08, 2011 03:08:10

A simple POM is a good start, IMO. Maybe there is a Maven expert in the community who could help us get proper support. This might be a good start for developers who are interested in getting involved. Maybe we should put up a TODO list somewhere on the wiki to advertise the tasks.

Andreas

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on February 08, 2011 04:46:06

OK, then let's go for the simple POM file. Here's an updated simple POM file with proper Manifest entries and also it now inherits from com.google:google-5 Maven configuration: this gets us the repository information necessary for distribution into the official Google open source Maven repository, however I do not know how we could get permission to push into that repo, probably a googly thing. @David or @Andreas, can you ask around internally? Once that done, Cofoja snapshots should be available at the same place you can grab other Google Maven projects, which should be good.

And a TODO/roadmap would be a good thing indeed. I don't have much experience with community management and stuff, so I have no idea which form it should take, though. Anyway, let's discuss that somewhere else (mailing list?).

Status: Started

Attachment: pom.xml

nhatminhle commented 10 years ago

From daniel.y...@gmail.com on February 08, 2011 08:26:13

It's necessary to disable the maven jar plugin execution:

org.apache.maven.plugins maven-jar-plugin maven-jar-plugin-execution none

This way maven will not build the jar using its plugin and via ant everything will work fine.

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on February 09, 2011 03:30:15

I've seen that trick elsewhere before but I can't seem to reproduce it; while I can reconfigure the default targets (i.e. default-jar in this case), I can't rebind them in the Maven version (2.2.1/NetBSD-pkgsrc) I use, hence I can't disable them. I've also found mentions of people implying that complex build scripts that require meddling with the default model should not be handled by Maven, so maybe it's not the right way to go, anyway.

Labels: -Type-Defect Type-Enhancement

nhatminhle commented 10 years ago

From jean.eas...@gmail.com on February 15, 2011 19:53:46

Hi,

not an expert in Maven but have been working a few years with it. I've just rapidly gone through the Ant build.xml, haven't seen anything strikingly problematic to move it to a Maven config. At least to make the equivalent of the main dist target. Just unsure about the directive and where you find provider com.google.java.contract.core.apt.AnnotationProcessor.

To make a complete Maven config that could reproduce ALL target, a dedicated Maven plugin would probably be required. But it'd be worth it I guess, considering how popular Maven has become. That would allow people to integrate use of Cojofa in their exiting build config.

I'd be ready to try to get a proper pom.xml that could build the expected artifact and deploy them, provided nobody else is working on it - don't want to waste time.

Please bear in mind that a slight refactoring will be needed to match Maven default directory structure (it's possible to bend the established rules, but much easier to follow them). Mainly: src -> src/main/java test -> src/test/java

Just let me know Jean

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on February 16, 2011 02:01:27

Hi,

Thanks for offering to help!

The pom.xml file you can see on this thread ( https://code.google.com/p/cofoja/issues/detail?id=11#c3 ) is the latest work on Maven integration that has been done so far. For a more complete build.xml file, though, you'll want to have a look at the patch in issue 13 first: https://code.google.com/p/cofoja/issues/detail?id=13#c2 The pom.xml on this thread builds and deploys the equivalent of the dist target (and it does not change the directory layout). But can we really not just delegate the build to Ant? I mean, reproducing everything as Maven rules will require us to maintain both build configurations, so that's going to be twice as much as is currently needed. In that case, wouldn't having Maven only build/deploy the "user" targets be a better choice?

Though I do agree that we should have a plugin for Cofoja & its tools in Maven (and probably for Ant too, but I can take care of that).

In any case, please have a look at the existing pom.xml and if you'd like to work on improving it, could you post a summary of the planned changes so we know what you're working on?

nhatminhle commented 10 years ago

From jean.eas...@gmail.com on February 16, 2011 19:32:17

Hi Nhat Minh,

as I understand, so far the pom.xml already works for bare compile and JAR producing. Fair enough. I have attached a slightly upgraded version of the pom (indenting, formatting, fixed to latest version, encoding definition, trick to get it work on Os X), see if you like it. But this is mainly cosmetic change.

I also believe you don't want to maintain 2 build systems. But using Maven and delegating to Ant - even is that could work - will at some point interfere with the Maven way, and ultimately - soon enough - limit what you can do with Maven. And you'll probably agree that it really sounds like a trick, not something proper, and that's not what you want.

In the end, if you don't want to give up on Ant - you certainly don't want to give up on Maven as it's going to be needed for many to integrate in their build - I think it's better to keep the two build systems.

Delegate the Maven work to someone and keep the Ant work for yourself.

IMHO Maven has a lot to offer and it's lifecycle just make sense for your project as well. It should help soon enough to make the switch to it, especially for releasing and producing a tooling system - meaning plugin - that people can easily integrate in their builds.

Attachment: pom.xml

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on February 17, 2011 03:43:26

The problem of Maven is that currently we don't have a complete Maven build script, whereas the Ant script pretty much does what we need it to do (and I know how to write Ant plugins and stuff like that). The team is not against moving to Maven in the future if we can get full support. But until we do, I guess we need to make do with two build systems.

About the Maven lifecycle model, there are a few things that I'm afraid won't play well: Cofoja needs to run the compilation process multiple times and then do the packaging before it can run the tests, and I've read it's against the Maven model to do that. AFAIK, the javaagent thing requires a JAR file, so we must package before we run the tests.

As for the patch, thanks for the added tricks (for Mac OS) but could you please not reindent files? I don't really care about the exact number of spaces but since the existing build.xml already uses 2 spaces, please keep it to that. Otherwise, I guess we should import the simple pom.xml now as a start. @David, @Andreas?

nhatminhle commented 10 years ago

From andreasl...@google.com on February 17, 2011 04:15:21

LGTM!

nhatminhle commented 10 years ago

From smassey1...@gmail.com on April 14, 2011 16:07:12

See chex4j build and deploy. Basically maven is a bit of a beast for a javagent. Getting deployed to central is a bit of effort.

nhatminhle commented 10 years ago

From tadp...@gmail.com on June 18, 2011 21:29:08

I really like the concepts behind Cofoja. I want to you it in my projects but my projects use Maven. I've written a few Maven plugins. So, I can write us a plugin to use Cofoja.

Let me know.

nhatminhle commented 10 years ago

From davidmor...@google.com on June 20, 2011 10:04:51

Sounds great! If it something other people can use, we're definitely interesting. I don't think anyone is working on this right now.

nhatminhle commented 10 years ago

From davidmor...@google.com on June 20, 2011 10:05:11

Ehm, I meant, "interested".

nhatminhle commented 10 years ago

From tadp...@gmail.com on June 24, 2011 07:41:27

David do you have any advice or recommendations for as I get started on this plugin?

nhatminhle commented 10 years ago

From davidmor...@google.com on June 24, 2011 09:12:31

I really don't know anything about Maven, so I'm afraid, not much to say!

nhatminhle commented 10 years ago

From tadp...@gmail.com on June 24, 2011 09:16:04

Ok, thanks

I might need some guidance with Cofoja.

nhatminhle commented 10 years ago

From davidmor...@google.com on June 24, 2011 09:22:41

Of course -- any questions or anything is unclear, please let us know. Thanks!

nhatminhle commented 10 years ago

From cezaryba...@gmail.com on October 05, 2011 14:33:26

Was there any progress on this one? If not I would very much like to help.

Please let me know.

Cheers, Cezary Bartoszuk cezarybartoszuk@gmail.com

nhatminhle commented 10 years ago

From davidmor...@google.com on October 06, 2011 01:44:33

Hi Cezary,

No, no progress that I'm aware of -- we'd be very glad of the help!

Cheers

David

nhatminhle commented 10 years ago

From cezaryba...@gmail.com on June 13, 2012 10:24:39

Hi!

Sorry for not responding for so long. Recently I was thinking about maven plugin for CoFoJa but since Maven is getting deprecated in favor of some more modern build tools like Buildr, Gradle, sbt or Leiningen - maybe it would be better to check out how these can run CoFoJa. It turns out that the setup is really simple with Gradle. I posted a quick howto with example build.gradle on: http://commitmessages.blogspot.com/ Cheers, Cezary

nhatminhle commented 10 years ago

From dave26...@gmail.com on June 13, 2012 12:17:24

Makes a lot of sense. Thanks for the article!

I know it's not related to the main body of the article, but thanks for pointing out that IntelliJ can support languages in strings. I'm a big fan of IntelliJ but had not figured that out.

nhatminhle commented 10 years ago

From lev...@gmail.com on June 13, 2012 17:46:36

Cezary,

Maven is under active development reference: http://jira.codehaus.org/browse/MNG#selectedTab=com.atlassian.jira.plugin.system.project%3Asummary-panel If you want a plugin for gradle, please create a seperate issue.

nhatminhle commented 10 years ago

From gabe.bau...@gmail.com on May 07, 2013 16:42:14

I would be happy to assist with the Mavenization of cofoja. Is there any update on the situation? It's a real pity that this library isn't part of the upstream Maven repositories.

nhatminhle commented 10 years ago

From nhat.min...@gmail.com on May 11, 2013 10:39:52

Hi Gabe,

Nothing has happened on this front. I'm pretty much the only one still (somewhat) working on Cofoja and I have no plans to learn Maven, let alone bring Cofoja to it, right now.

Cc: -andreasl...@google.com -davidmor...@google.com

nhatminhle commented 10 years ago

From anton.pa...@fastdev.se on May 16, 2013 14:05:14

Hi, Gabe. I've tried to move it to Maven, but Ant's strange executors stop me, cause necessary to know the whole Cofoja's architecture from every angle. But I am still interested in this library.

nhatminhle commented 10 years ago

From reg.goog...@future-invent.de on June 21, 2013 07:07:13

Hi Anton,

got any further with this task?

Cheers, Michael

yildiz-online commented 8 years ago

Hi all, for those interested, and if it is ok for you nhatminhle i've created a repo here on github for 1.3

<repository>
  <id>maven-cofoja-repo</id>
  <url>http://maven-cofoja.github.io/maven</url>
</repository>

<dependency>
  <groupId>com.google.java.contract</groupId>
  <artifactId>cofoja</artifactId>
  <version>1.3</version>
</dependency>
ghost commented 8 years ago
                                                                                  Finally! Good to see :-)                                                                                                                                                                                                                                                                                                                                         Sent from my BlackBerry 10 smartphone.                                                                                                                                                                                                                From: Grégory Van den BorreSent: Freitag, 29. Juli 2016 18:39To: nhatminhle/cofojaReply To: nhatminhle/cofojaSubject: Re: [nhatminhle/cofoja] Provide a Maven Artifact (#2)Hi all, for those interested, and if it is ok for you nhatminhle i've created a repo here on github for 1.3
maven-cofoja-repo http://maven-cofoja.github.io/maven com.google.java.contract cofoja 1.3

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.

nhatminhle commented 7 years ago

Cofoja is now on Maven Central. See #44