Software Engineering and Architecture Dependency Management
Henrik Bærbak Christensen Motivation Software Reuse The holy grail in software engineering for decades… Lot of hard work and research, and relatively little success Shaw: It is not the functionality, it is the packaging Until… The big open source organizations and the companies that does not earn their money from selling software began publishing libraries Apache, Eclipse, Goggle, Amazon, … CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Example I want to make a ”Hello World” web service ala Exercise: How much coding would that take given only raw Java language? CS@AU Henrik Bærbak Christensen
Reusing Web Frameworks One web framework is ‘Spark’ which allows pretty compact code… All nice and well… But… You need the Spark library Which depends on a lot of other reusable libraries… Core dependency: Eclipse Jetty, open source web server To clean ivy cache: c:\users\(user)\.ivy2 CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen The Dependencies 17 Libraries! Tedious and error prone to Fetch all libraries in proper version Very long classpath in Java CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen The Solution Dependency Management Tool to resolve the transitive closure of dependencies Locate and download library, recursively locate and download any dependencies Resolve conflicts A version 1 depends on B version 1 and C version 3 B version 1 depends on D version 2 C version 3 depends on D version 3 Tool will eject D version 2 and only provide D version 3 A Dependency Description Stating which libraries we need And – repositories of libraries Maven repository ‘mvnrepository.com’ is a major player! CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen SWEA Context Gradle is a modern build management tool and it has already built-in dependency management !!! Earlier SWEA/dSoftArk used Ant which does not… And then had to use a plug-in tool, Ivy, to help out CS@AU Henrik Bærbak Christensen
The Process Goal: I want Spark-java library in my project Open mvnrepository.com and search for the library ‘sparkjava’ Take care: Apache has a project with the same name CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen The Process Select the project, version, and click the ‘gradle’ pane Now you can copy the gradle declaration… Which is the text that goes into your dependency description CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen The Process … and paste it into your build.gradle CS@AU Henrik Bærbak Christensen
Demo Gradle will: * Check if the .jar is in local cache * If not, download it from mvnrepository * Recurse on any dependencies * Set the CLASSPATH correctly CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen JCenter / BinTray An alternative (which Gradle defaults to) to Maven Repository is JCenter. Is free to upload to And, less cumbersome than MvnRepository MiniDraw is hosted there CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen DM in SWEA We will in SWEA only pull dependencies And you will always be given the build.gradle files Pushing to a repository is out-of-scope for our course Security you know Need to create credentials, secret tokens for pushing, and stuff... CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Summary Declarative approach State what you need, not how to get it A DSL (domain specific language) for defining dependencies A dependency description Tool (Gradle ) to resolve Public repositories with numerous libraries Possible to create own repos’ and publish team/organization specific libraries as well… CS@AU Henrik Bærbak Christensen