Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

A maven build question

 
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a copy of my company's project locally on my hard drive and yesterday, the code built successfully.
However, this morning with 'the same source code' (except a few minor changes) the build failed due to some test failures.

This happens from time to time, I believe some 'in-house' jars that the tests require occaisonally 'get broken' by other developers,
and this causes these intermittent build failures.

If I now run mvn clean install from my machine, I'll get a failed build.

However, I still have a copy of yesterday's .m2 local repository. And if I use it and build 'offline', I'll get a build success!

My question is this:
Is this 'successful build' an accurate result?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean with an "accurate result"?

Obviously something has changed in some library, which wasn't broken in yesterday's version. The person who made a change that broke the build should fix the problem, either by fixing the bug that causes the test to fail, or by updating the test, if the cause is not a bug but a deliberate change in behaviour.

Ideally people should not commit code that breaks the build. A developer should at least run the unit tests on his or her local machine and make sure there are no failures before committing code to the version control system. In some companies I've worked for, breaking the build meant you had to buy lunch for your colleagues.
 
Billy Sclater
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What exactly do you mean with an "accurate result"?


Today, I've made some minor changes which were not in yesterday's code. But... I'm using yesterday's local repo (offline) when I build.
Does this matter? Is it possible, that my changes won't be picked up? (Forgive me if my question is a bit newbie-ish! I'm quite new to maven!).



 
Saloon Keeper
Posts: 22664
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the core tenets of Maven is that dependencies are reliable.

This is enforced by having Maven artefacts tagged with not only product identifiers, but specfic version numbers. This ensures consistent behavior from the artefact.

A lot of people get sloppy and don't specify version numbers in their pom dependency stanzas or use "grab bag" versioning (as in "give me the latest".)

For certain types of projects, this may be desirable or essential. Especially if you are a shop that does nightly snapshot builds. However, if you're doing that, it's appropriate to ensure that the snapshots are reliable. And in fact, it's a Best Practice to include as many tests in the build process as you can manage so that a snapshot won't get committed unless it's clean.

For the rest of the dependencies, including in-house artefacts that are standards and not part of the developing project, you should be using absolute versions, however.
 
Billy Sclater
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A lot of people get sloppy and don't specify version numbers in their pom dependency stanzas or use "grab bag" versioning (as in "give me the latest".)


Currently version numbers aren't used in my company (to my understanding) or rather everything is stamped with the same version number!!
But I get your point.

From what you are saying, it sounds like if version numbers are used correctly.
Then if 'version 2' of a certain artifact is broken, then you can just choose 'version 1' instead. (Assuming 'version 1' is compatible with your source code.)
Is that right?
 
Tim Holloway
Saloon Keeper
Posts: 22664
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close.

More commonly, you'd simply stake the build on "version 1.0" as a standard. Later, when version 2.0 (or 1.1 or whatever) was certified as clean, you could go back into the pom, update the requested version, test it, and if all went well, make that the new pom, now pulling 2.0. Maven keeps all generations (unless you forcibly delete them), so old builds still work even if you don't have time to update them for newer dependencies.

Maven isn't intended to publish broken modules. Those would normally be local to whatever development team was working on that particular module and only when it was reasonably clean would that team do a "mvn deploy" to publish it site-wide.

Snapshot builds are the exception, especially if you are doing nightly snapshots. But even then other teams shouldn't be referencing snapshot builds unless they were unable to use a stable build for some reason (for example, because they were another part of a big, fast-moving project).
 
Billy Sclater
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like heaven! I hope we move to using versions (in my company) soon(:
 
Tim Holloway
Saloon Keeper
Posts: 22664
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like some people need a class in Maven-based project management.
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic