You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mt...@apache.org on 2020/07/12 17:58:29 UTC

[maven-site] branch master updated: Exercising "Getting Started" gives BUILD FAILURE plus example output issues

This is an automated email from the ASF dual-hosted git repository.

mthmulders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site.git


The following commit(s) were added to refs/heads/master by this push:
     new bfdc0b2  Exercising "Getting Started" gives BUILD FAILURE plus example output issues
bfdc0b2 is described below

commit bfdc0b27a8d5e6d2d12c2862d93afeda26abc28c
Author: David Pead <da...@gmail.com>
AuthorDate: Sun Jul 12 11:09:17 2020 +0100

    Exercising "Getting Started" gives BUILD FAILURE plus example output issues
    
    o Change example archetype to stipulate version, remove line numbers, retain batch mode
    o change pom example to mirror version change, update element descriptions
    o update test and install example output, remove jar reference
    o remove xml tag
    o change local-repository to <local-repository>
    o change missed /dir> to <dir>
    o Closes #416.
---
 content/apt/guides/getting-started/index.apt | 237 ++++++++++++++-------------
 1 file changed, 126 insertions(+), 111 deletions(-)

diff --git a/content/apt/guides/getting-started/index.apt b/content/apt/guides/getting-started/index.apt
index 4d3cfdb..06468df 100644
--- a/content/apt/guides/getting-started/index.apt
+++ b/content/apt/guides/getting-started/index.apt
@@ -111,29 +111,33 @@ Sections
  On to creating your first project! In order to create the simplest of Maven projects, execute the following from
  the command line:
 
-+-----+
-mvn -B archetype:generate \
-  -DarchetypeGroupId=org.apache.maven.archetypes \
-  -DgroupId=com.mycompany.app \
-  -DartifactId=my-app
-+-----+
+-----
+mvn -B archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
+-----
 
  Once you have executed this command, you will notice a few things have happened. First, you will notice that
  a directory named <<<my-app>>> has been created for the new project, and this directory contains a file named
  <<<pom.xml>>> that should look like this:
 
 +-----+
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
+
   <groupId>com.mycompany.app</groupId>
   <artifactId>my-app</artifactId>
-  <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
-  <name>Maven Quick Start Archetype</name>
-  <url>http://maven.apache.org</url>
+
+  <name>my-app</name>
+  <!-- FIXME change it to the project's website -->
+  <url>http://www.example.com</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>1.7</maven.compiler.source>
+    <maven.compiler.target>1.7</maven.compiler.target>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>junit</groupId>
@@ -142,6 +146,12 @@ mvn -B archetype:generate \
       <scope>test</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
+       ... lots of helpful plugins
+    </pluginManagement>
+  </build>
 </project>
 +-----+
 
@@ -170,13 +180,6 @@ mvn -B archetype:generate \
     the artifactId as part of their final name. A typical artifact produced by Maven would have the form
     \<artifactId\>-\<version\>.\<extension\> (for example, <<<myapp-1.0.jar>>>).
 
-  * <<packaging>> This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.).
-    This not only means if the artifact
-    produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. (The
-    lifecycle is a topic we will deal with further on in the guide. For now, just keep in mind that the indicated packaging of a project
-    can play a part in customizing the build lifecycle.) The default value for the <<<packaging>>> element is JAR
-    so you do not have to specify this for most projects.
-
   * <<version>> This element indicates the version of the artifact generated by the project. Maven goes a long way
     to help you with version management and you will often see the <<<SNAPSHOT>>> designator in a version, which
     indicates that a project is in a state of development. We will discuss the use of
@@ -188,8 +191,11 @@ mvn -B archetype:generate \
   * <<url>> This element indicates where the project's site can be found. This is often used in Maven's
     generated documentation.
 
-  * <<description>> This element provides a basic description of your project. This is often used in
-    Maven's generated documentation.
+  * <<properties>> This element contains value placeholders accessible anywhere within a POM.
+
+  * <<dependencies>> This element's children list {{{/pom.html#dependencies}dependencies}}. The cornerstone of the POM.
+
+  * <<build>> This element handles things like declaring your project's directory structure and managing plugins.
 
   []
 
@@ -240,27 +246,25 @@ mvn compile
  Upon executing this command you should see output like the following:
 
 -----
-[INFO] ----------------------------------------------------------------------------
-[INFO] Building Maven Quick Start Archetype
-[INFO]    task-segment: [compile]
-[INFO] ----------------------------------------------------------------------------
-[INFO] artifact org.apache.maven.plugins:maven-resources-plugin: \
-  checking for updates from central
-...
-[INFO] artifact org.apache.maven.plugins:maven-compiler-plugin: \
-  checking for updates from central
-...
-[INFO] [resources:resources]
-...
-[INFO] [compiler:compile]
-Compiling 1 source file to <dir>/my-app/target/classes
-[INFO] ----------------------------------------------------------------------------
-[INFO] BUILD SUCCESSFUL
-[INFO] ----------------------------------------------------------------------------
-[INFO] Total time: 3 minutes 54 seconds
-[INFO] Finished at: Fri Sep 23 15:48:34 GMT-05:00 2005
-[INFO] Final Memory: 2M/6M
-[INFO] ----------------------------------------------------------------------------
+[INFO] Scanning for projects...
+[INFO] 
+[INFO] ----------------------< com.mycompany.app:my-app >----------------------
+[INFO] Building my-app 1.0-SNAPSHOT
+[INFO] --------------------------------[ jar ]---------------------------------
+[INFO] 
+[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ my-app ---
+[INFO] Using 'UTF-8' encoding to copy filtered resources.
+[INFO] skip non existing resourceDirectory <dir>/my-app/src/main/resources
+[INFO] 
+[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
+[INFO] Changes detected - recompiling the module!
+[INFO] Compiling 1 source file to <dir>/my-app/target/classes
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time:  0.899 s
+[INFO] Finished at: 2020-07-12T11:31:54+01:00
+[INFO] ------------------------------------------------------------------------
 -----
 
  The first time you execute this (or any other) command, Maven will need to download all the plugins and related
@@ -292,39 +296,45 @@ mvn test
  Upon executing this command you should see output like the following:
 
 ----
-[INFO] ----------------------------------------------------------------------------
-[INFO] Building Maven Quick Start Archetype
-[INFO]    task-segment: [test]
-[INFO] ----------------------------------------------------------------------------
-[INFO] artifact org.apache.maven.plugins:maven-surefire-plugin: \
-  checking for updates from central
-...
-[INFO] [resources:resources]
-[INFO] [compiler:compile]
+[INFO] Scanning for projects...
+[INFO] 
+[INFO] ----------------------< com.mycompany.app:my-app >----------------------
+[INFO] Building my-app 1.0-SNAPSHOT
+[INFO] --------------------------------[ jar ]---------------------------------
+[INFO] 
+[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ my-app ---
+[INFO] Using 'UTF-8' encoding to copy filtered resources.
+[INFO] skip non existing resourceDirectory <dir>/my-app/src/main/resources
+[INFO] 
+[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
 [INFO] Nothing to compile - all classes are up to date
-[INFO] [resources:testResources]
-[INFO] [compiler:testCompile]
-Compiling 1 source file to C:\Test\Maven2\test\my-app\target\test-classes
-...
-[INFO] [surefire:test]
-[INFO] Setting reports dir: C:\Test\Maven2\test\my-app\target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-[surefire] Running com.mycompany.app.AppTest
-[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0 sec
-
-Results :
-[surefire] Tests run: 1, Failures: 0, Errors: 0
-
-[INFO] ----------------------------------------------------------------------------
-[INFO] BUILD SUCCESSFUL
-[INFO] ----------------------------------------------------------------------------
-[INFO] Total time: 15 seconds
-[INFO] Finished at: Thu Oct 06 08:12:17 MDT 2005
-[INFO] Final Memory: 2M/8M
-[INFO] ----------------------------------------------------------------------------
+[INFO] 
+[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ my-app ---
+[INFO] Using 'UTF-8' encoding to copy filtered resources.
+[INFO] skip non existing resourceDirectory <dir>/my-app/src/test/resources
+[INFO] 
+[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ my-app ---
+[INFO] Changes detected - recompiling the module!
+[INFO] Compiling 1 source file to <dir>/my-app/target/test-classes
+[INFO] 
+[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ my-app ---
+[INFO] 
+[INFO] -------------------------------------------------------
+[INFO]  T E S T S
+[INFO] -------------------------------------------------------
+[INFO] Running com.mycompany.app.AppTest
+[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s - in com.mycompany.app.AppTest
+[INFO] 
+[INFO] Results:
+[INFO] 
+[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+[INFO] 
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time:  1.881 s
+[INFO] Finished at: 2020-07-12T12:00:33+01:00
+[INFO] ------------------------------------------------------------------------
 ----
 
  Some things to notice about the output:
@@ -354,8 +364,6 @@ Results :
 mvn package
 +----+
 
- If you take a look at the POM for your project you will notice the <<<packaging>>> element is set to <<<jar>>>.
- This is how Maven knows to produce a JAR file from the above command (we'll talk more about this later).
  You can now take a look in the <<<$\{basedir\}/target>>> directory and you will see the generated JAR file.
 
  Now you'll want to install the artifact you've generated (the JAR file) in your local repository
@@ -370,40 +378,47 @@ mvn install
  Upon executing this command you should see the following output:
 
 ----
-[INFO] ----------------------------------------------------------------------------
-[INFO] Building Maven Quick Start Archetype
-[INFO]    task-segment: [install]
-[INFO] ----------------------------------------------------------------------------
-[INFO] [resources:resources]
-[INFO] [compiler:compile]
-Compiling 1 source file to <dir>/my-app/target/classes
-[INFO] [resources:testResources]
-[INFO] [compiler:testCompile]
-Compiling 1 source file to <dir>/my-app/target/test-classes
-[INFO] [surefire:test]
-[INFO] Setting reports dir: <dir>/my-app/target/surefire-reports
-
--------------------------------------------------------
- T E S T S
--------------------------------------------------------
-[surefire] Running com.mycompany.app.AppTest
-[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.001 sec
-
-Results :
-[surefire] Tests run: 1, Failures: 0, Errors: 0
-
-[INFO] [jar:jar]
+[INFO] Scanning for projects...
+[INFO] 
+[INFO] ----------------------< com.mycompany.app:my-app >----------------------
+[INFO] Building my-app 1.0-SNAPSHOT
+[INFO] --------------------------------[ jar ]---------------------------------
+[INFO] 
+[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ my-app ---
+...
+[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ my-app ---
+[INFO] Nothing to compile - all classes are up to date
+[INFO] 
+[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ my-app ---
+...
+[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ my-app ---
+[INFO] Nothing to compile - all classes are up to date
+[INFO] 
+[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ my-app ---
+[INFO] 
+[INFO] -------------------------------------------------------
+[INFO]  T E S T S
+[INFO] -------------------------------------------------------
+[INFO] Running com.mycompany.app.AppTest
+[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s - in com.mycompany.app.AppTest
+[INFO] 
+[INFO] Results:
+[INFO] 
+[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+[INFO] 
+[INFO] 
+[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ my-app ---
 [INFO] Building jar: <dir>/my-app/target/my-app-1.0-SNAPSHOT.jar
-[INFO] [install:install]
-[INFO] Installing <dir>/my-app/target/my-app-1.0-SNAPSHOT.jar to \
-   <local-repository>/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
-[INFO] ----------------------------------------------------------------------------
-[INFO] BUILD SUCCESSFUL
-[INFO] ----------------------------------------------------------------------------
-[INFO] Total time: 5 seconds
-[INFO] Finished at: Tue Oct 04 13:20:32 GMT-05:00 2005
-[INFO] Final Memory: 3M/8M
-[INFO] ----------------------------------------------------------------------------
+[INFO] 
+[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ my-app ---
+[INFO] Installing <dir>/my-app/target/my-app-1.0-SNAPSHOT.jar to <local-repository>/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.jar
+[INFO] Installing <dir>/my-app/pom.xml to <local-repository>/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.pom
+[INFO] ------------------------------------------------------------------------
+[INFO] BUILD SUCCESS
+[INFO] ------------------------------------------------------------------------
+[INFO] Total time:  1.678 s
+[INFO] Finished at: 2020-07-12T12:04:45+01:00
+[INFO] ------------------------------------------------------------------------
 ----
 
  Note that the surefire plugin (which executes the test) looks for tests contained in files with a particular naming convention. By default
@@ -1245,4 +1260,4 @@ $ jar tvf my-webapp/target/my-webapp-1.0-SNAPSHOT.war
 
   The final step was to include a parent definition.
   This ensures that the POM can always be located even if the project
-  is distributed separately from its parent by looking it up in the repository.
\ No newline at end of file
+  is distributed separately from its parent by looking it up in the repository.