Why commonly Java Repository/Library is stored using Maven? - java

Currently I'm learning the details about Gradle. I'm just curious, there is central repository like MavenCentral, and there are many repositories stored in there. It seems there are no 'GradleCentral', do all Java Library is usually using Maven as a build tools? If yes, why does this happen? Is it because of Maven is the better choice to create a Java library?

It's not just Maven Central that is available to host libraries. There are tons of public and private options out there but by far Maven Central is the most popular and safe option. For closed source development projects, libraries are hosted on nexus and other similar solutions and I've seen open source projects hosting on others as well.
As for the popularity of Maven, It is an official Apache project thus enjoys more authenticity over other similar build solutions and others show compatibility towards Maven as well.

Related

Does maven central expects Source URL to be shared? [duplicate]

This question already has an answer here:
Is it mandatory to provide SCM Url for getting project ID in maven central
(1 answer)
Closed 2 years ago.
I need few clarifications regarding releasing the artifacts in maven central. I could see in the requirements that for SCM information project URL need to be added, which means whether we supposed to share the source via SCM. Since my understanding as maven central is public repo and so they expect source need to be shared or we can share our github link (which may point to source related demos).
Since working in an organization we are not interested in share as open source. It is will be commercial project, whether we can release the artifacts in maven central with SCM Url pointing to source demos . Can anybody share your valuable suggestions?
Note: Artifact to be hosted is for commercial purposes.
Maven Central requires you to share the source. From your own link:
Supply Javadoc and Sources
Projects with packaging other than pom have to supply JAR files that contain Javadoc and sources.
While there's no technical requirement that your SCM is world-readable, there's no point in trying to hide it.
Artifact to be hosted is for commercial purposes.
That's not what Maven Central is for. If you have a commercially-licensed, closed-source library and want to provide Maven integration, then set up your own private repository for your customers. You'll also need to invest in some heavy obfuscation if you don't want people trivially decompiling or modifying it though.

registering custom maven archetype

How can I register my own Maven archetype, co that other people (in the whole world or just in my local company) might use it?
In Python, there is PyPI, a global registry where you create packages, upload them, upgrade, ... and you've got a user there which you use to authorize your self.
In node.js, there is npm, which works exactly the same. There is also bower, which is similar (though it relies on git branches).
Anyway, this tutorial describes that I can install an archetype locally. But how can I make it public, so that other people may download it? How is it integrated with IDEs (Eclipse, NetBeans, etc.)?
Publish your archetype (or any other artifact) to the Central Repository via Sonatype OSS Repository Hosting.

Where to check out SLF4J Simple?

I'm trying to check out slf4j-simple-1.6.2 from a trusted repository (preferably, SLF4J's official repo) and pull it down into an Eclipse project. I'm doing this because I need to tweak SLF4J Simple's code so that it binds to my own logging implementation.
I'm hoping there is a way to do this without having to use Maven, because I've never used Maven before and feel much more comfortable running Ant builds.
Nevertheless, I've searched SLF4J's site high and low and cannot find any trusted links to their repository.
Even once I get the project imported into Eclipse, I still need to figure out how to get it building with Ant.
Could someone please help me:
Find the repo
Confirm whether an Ant build is possible
Thanks in advance!
The zip download here also contains the sources.
The official source code repository is hosted on GitHub. However, I believe you are doing it the wrong way.
The idea of SLF4J is to have a dependency on slf4j-api and let the developer to add exactly one binding. Instead of tweaking original bindings just write your own one. Of course you can use simple binding a starting point, but modifying existing open source libraries and maintaining patched versions is a lot of work.
As you said, slf4j is present in the official Maven repository.
So basically, you have 2 simple solutions without using Maven:
Download the JAR / sources / javadocs from this Maven repository, and copy them in your own project directory.
Use Ivy. This is an extension of Ant to give a better dependencies management. It can connect to Maven repositories. So you will be able to retrieve your slf4j dependency without having to use Maven.

Advice on a good Java build tool, well integrated with eclipse

I am working in a small team (3 persons) on several modules (about 10 currently). The compilation, integration and management of build versions is becoming more and more tedious.
I am looking for a good build / integration tool to replace / complete Ant.
Here is the description of our current development environment :
- Several modules depending on each over and on third party JARs
- Some may export JARS, some export WARS, some export standalone, runnable JARS (with Fat-Jar)
- Javadoc for all of them
- We work with eclipse
- Custom Ant script for each module. Many redundant information between the eclipse configuration and Ant scripts. For example, for the standalone Fat-JAR, we have listed all the recursive dependencies, whereas ideally, it could clearly be imported from the eclipse configuration.
- The source code is versioned using SVN
Here is what I would like a perfect integration tool to do for me :
Automatize the releases and versioning of modules. Ideally, the integration tool should detect if a new version is needed. For example, if I want to release a project A that depends on a project B, and if I have made small changes on the project B locally, then the integration tool should first release a new version of B as well and make A based on it.
Integrate strongly with eclipse, so that it could get the dependencies between modules and third party libs from its configuration. BTW, I would like to continue to configure build path with eclipse without updating some other ".xml" stuff. I saw that Gradle can generate eclipse project files from its configuration, but the counterpart would be great.
Enable a "live" and transparent development on local projects. I mean that I often make small changes on the core / common projects while developing the main / "leaf" projects. I would like to have my changes on core projects immediately available to leaf projects without the need of publishing (even locally) the JARs of my core projects.
Store all versions of the releases of my module on an external server. The simplest (shares folder / Webdav) would be the best. A nice web page with list of modules and delivered artifacts would be great too.
I have looked around for many things. From Ant4eclipse (to integrate the Eclipse configuration into my Ant script), to the Maven / Ivy / Gradle tools.
I am a bit confused.
Here is what I have understood so far:
- Maven is a great / big tool, but is somewhat rigid and obliges you to bend to its structure and concepts. It is based on description rather than on scripting. If you go out of the path, you have to develop you own plugins.
- Ivy is less powerful than maven, it handles less stuff but is more flexible.
- Gradle is in-between. It is general purpose. It enables scripting as well as "convention based" configuration. It integrates Ant and extends it.
So at this point I am looking for actual testimonials from real users.
What tools do you use ? How ? Do you have the same needs as me ?
Does it ease your life or get into the way ?
Are there sample some use cases, or workspace skeletons out there that I could use as a starting point to see what these tools are capable of ?
Sorry for the length of this message.
And thanks in advance for you advice.
Kind regards,
Raphael
Automatize the releases and versioning of modules (...)
The concepts of versioning and repository are built-in with Maven and they could fit here.
Maven supports SNAPSHOT dependencies. When using a snapshot, Maven will periodically try to download the latest available snapshot from a repository when you run a build. SNAPSHOT are typically used when a project is under active development.
Maven 2 also supports version ranges (I do not really recommend them but that's another story) which allow for example to configure A to depend on version [4.0,) of B (any version greater than or equal to 4.0). If you build and release a new version of B, A would use it.
Integrate strongly with eclipse
The m2eclipse plugin provides bi-directional synchronization with Eclipse.
Enable a "live" and transparent development on local projects.
The m2eclipse plugin supports "workspace resolution": if project A depend on project B and if project B is in the workspace, you can configure A to depend on B sources and not on B.jar (that's the default mode if I'm not wrong). So a change on B sources would be directly visible, without the need to build B.jar.
Store all versions of the releases of my module on an external server.
As mentioned earlier, this is actually a central concept of Maven (you don't even have the choice) and deploying through file:// or dav:// are both supported.
To sum up, Maven is (probably) not the only candidate but I'm sure it would fit:
Your project isn't that exotic or complex, there is nothing scaring from your description (some refactoring of the structure will probably be required but this shouldn't be a big deal).
Maven also brings a workflow based on best practices.
m2eclipse provides strong integration with the IDE.
But Maven has some learning curve.
CI tools? To me, there's only one: the Hudson CI.
I've setup a software development environment for Java once, with the components:
eclipse IDE
mercurial
bugzilla
maven
Nexus
Hudson CI
and some apache, mysql, php, perl, python, .. for integration.
The hudson was not integrated with eclipse and that was on purpose, because I wanted to build on a separate server. for all the other tools I had a perfect cross integration (like: mylyn on eclipse to talk with bugzilla, m2eclipse for using maven eclipse, a lot of plugins for hudson, ...)
We've been starting to integrate Gradle into our build process, and I can add to the answers posted already that Gradle would also work. Your assumptions are mostly correct, gradle is more off the cuff, but is powerful and allows for scripting and such within the build itself. It seems that most things maven can do, gradle does as well.
Now for your individual points:
Versioning: gradle supports dependency maps, versioning, and if you add in a CI server, you can trigger automated/dependent builds. For example, almost all of our 'deliverables' are .wars, but we have several code libs (.jars) and one executable .jar in development. One configuration is to make the the wars and the "fat-jar" dependent on the shared code libs. Then, when the shared libs are updated, bump the versions on the shared libs, test the consuming projects, then use Hudson's ability to fire dependent projects to redeploy those. There are other ways, but that seems to work best for us, for now.
Integrate strongly with eclipse: You're right, gradle can generate the eclipse files. We tend to only use the eclipseCp (to update .classpath) task once we get going, as only classpath needs changed. It's kind of quirky (grabs your default JRE, so make sure it's right, doesn't add exported="true" if you need it), but gets you 99% of the way there.
Enable a "live" and transparent development on local projects: This is one I'm not sure about. I've only hacked around gradle in this case; by removing the artifact in the consuming project and marked the shared project as such in eclipse, then reverted afterwards.
Store all versions of the releases of my module on an external server: simple and many approaches are supported, similar to Maven.
As far as examples, the docs for gradle are good, as well as the example projects that come with the full zip. They'll get you up and running fairly quickly.
Have a look at Ant Ivy. http://ant.apache.org/ivy/
There are no silver bullets, but in my experience Maven is a great project management tool. Personally, I like to use a comibnation of subversion (for version control), maven (for project/build management) and hudson (for continuous build/integration).
I find the convention brought by maven is really useful for context switching, and great for dependency management. It can be frustrating if jars aren't in the repositories, but you can install them locally and when you're ready you can host your own private repository which mirrors other places. I have had a good experience using sonar.nexus by http://www.sonatype.com/ . They also provide an excellenmt free book to get you started.
It might seem like overkill now, but setting up a good build / test / integrate / release environment now, will pay dividends later. It's is always harder to retro-fit, and it's something you can replicate easily.
Lastly, I happen to prefer Netbeans integration for maven, but that's just me :)
Some of your topics are part of deployment and release management.
You could check out a product like: Xebia DeployIt
(with an personal edition which is free)

What apps have nifty maven poms and are good as examples of maven capabilites

I'm looking for applications that have "rich" maven pom(s) and can show lot of maven capabilities(plugins). These applications are needed as showcase examples - how fast and how many this can be done with maven and appropriate set of plugins.
There are no constraint to technology or application type - it must be opensorce and easy to build. I'm not looking for best one but thouse which are worth to look and build. In yours examples please add comments, what cool features that projects's maven build offer.
Obviously, these poms will be also inspiration to improve my own/others projects poms.
I personally found that Richfaces Photo Album Example was worth to look. In this project (Java EE webapp) there are functional test with cargo and selenium, use of scm plugin (export form svn), generation and deployment of ear to jboss server.
Why not examples from maven books? The should be real projects to convince to maven boss/stakeholders/workmates.
Why I can't get first one project build by maven? Because usually projects (not all) are only built by maven, and contain no additional reports or plugins.
I find Maven's bootstrap build funny: build Maven to build Maven. Note that it is possible to build Maven with Maven already installed but I'm not sure this build shows a wide features set usage.
From this point of view, JBoss AS might already be a better example, but not the "best" (if this has a sense). Actually, I like XWiki's build (Vincent Massol is working there). Or Exo Platform's one (Arnaud Heritier is working there).
I'm pretty sure XWiki and Exo Platform are good examples as their respective build manager have a deep knowledge of Maven (as more or less active maven committers): these build are full of best practices, show the right way to do things, have a clean modules organization, etc. In other words, they are representative of the "state of the art" with Maven.

Categories