It's All About the POM3:41 with Chris Ramacciotti
In Maven, an entire project's configuration can be encapsulated in the file named pom.xml. POM stands for "Project Object Model". This video discusses the high-level details of what most POMs will contain.
Now, that we're gonna be peeking into files and write any a bit of code, 0:00 it's time to switch to an IDE. 0:03 I'll use IntelliJ IDEA, okay, excellent. 0:04 I'll open this project panel and 0:09 then, I will open palm.xml, there it is. 0:12 As I said in the last video, POM stands for Project Object Model. 0:18 And this file represents a one stop configuration for the entire project. 0:22 As you can see, it's an XML representation of the Maven project. 0:27 The root node of a POM will be this project element 0:32 followed by the model version element. 0:34 Which for anything using Maven 2.0 or higher, 0:37 the model version will be 4.0.0, okay? 0:41 Next following this model version is a group of four elements that define what 0:44 are called the Maven coordinates. 0:49 That's the group ID, artifact ID, package, and version. 0:51 If you've used other dependency management tools, 0:55 you've have to reference these coordinates to use a third party library. 0:58 These categorize and identify the archive that this POM 1:01 will produce on a repository like Maven central. 1:04 Let me show you an example of what I mean. 1:07 If we need a third party library, that helps us examine file metadata, 1:09 like file types and the dates that they were created. 1:13 We might use the Apache Tika library. 1:16 Now, I can go to search.maven.org and search for Apache Tika. 1:18 And if I scroll down a bit towards the bottom of the page, I see tika-core. 1:27 And upon clicking on it, I will see the group ID, 1:32 the artifact ID and that version right there. 1:36 And even all the way over to the right, I see this jar, okay, back to IntelliJ. 1:39 This group ID here is a unique identifier for a business or organization. 1:46 Usually, in a form similar to Java package naming, in our case, com.teamtreehouse. 1:51 The artifact ID, is an identifier unique within the group. 1:57 And helps pinpoint the exact project within combat team treehouse. 2:02 In our case, it is file-spy skipping to the version and 2:06 this one is fairly self-explanatory. 2:09 What version of file-spy will the created artifact represent? 2:12 A quick note on SNAPSHOT, whenever you see that on an archive, 2:16 that means that this project is a work in progress. 2:21 It is not a final release, yet. 2:24 Now, speaking of that artifact, if we backtrack to the packaging element, 2:27 we'll see that ours specifies jar. 2:32 And this packaging element specifies the kind of archive created by this build. 2:34 When put together, the artifact ID, version, and packaging 2:38 elements all combined, will represent the name of the generated archive. 2:43 We will see later on that our archive will be named file-spy-1.0- snapshot.jar. 2:48 Okay, these next two elements, a name and 2:57 url give the project a nice reader friendly name. 3:01 As well as a url for the Maven project itself. 3:05 And following that, we see this dependencies element. 3:09 In this element, 3:13 we'll specify all the external libraries that this project depends on. 3:14 There is one in there by default and that is this junit library. 3:18 We'd want this library if we were writing unit tests. 3:23 Which in a distributed Java application, we definitely want to do. 3:25 Okay, let's take a break here before returning to these dependencies in 3:29 the next video where we'll start coding our application. 3:32 And in doing so, 3:35 we'll lean on a third party library that will add to our POM file. 3:36
You need to sign up for Treehouse in order to download course files.Sign up