Step 2: Use Maven to create a new Aspire distribution
For more detailed documentation for creating new distributions, see Using the Maven Distribution Archetype
Now that Maven is installed, you can create a new Aspire distribution easilyy. Our recommendations are to:
- Open a DOS command window. (See Step 1 for instructions.)
- Use cd to change the directory to a place where you want to store the new Aspire distributions.
- Execute the command shown below.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
mvn archetype:generate -DarchetypeGroupId=com.accenture.aspire -DarchetypeArtifactId=aspire-distribution-archetype -DarchetypeVersion=4.0 -DrepositoryId=stPublic |
The command should be executed exactly as is. Do not modify the parameters; they specify where to locate the instructions for how to build a new Aspire Distribution.
Note: Sometimes the mvn command will fail to locate the Search Technologies repository. (It should be specified in your new settings.xml file.) If this is a problem, add the following argument to the mvn command from above:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
-DarchetypeRepository=https://repository.accenture.com/artifactory/public |
After executing the command, Maven will download a bunch of different JAR files. Most of these are various Maven plug-ins that Maven requires. These plug-ins are downloaded automatically from the "master maven repository in the sky", namely http://repo.maven.apache.org.
Finally, after Maven is ready to go, you will be prompted for the following information:
- groupId - This is the name of the organizational unit to which your distribution belongs. It's usually the same as your organization's domain, but in reverse order (for example, "com.accenture.aspire"). If the distribution belongs to a customer, you should use that customer's groupId.
- The purpose of the groupId is to distinguish this distribution from all other maven distributions built by other organizations throughout the world (just in case somebody somewhere wants to re-use your distribution someday).
- artifactId - This is the name for your distribution. Technically, it should be unique name across all distributions (or any other maven project) within the organization specified by groupId. Again, it's purpose is to uniquely identify your distribution within your organization.
- version - This will be the version number for this distribution.
- I usually use "0.1-SNAPSHOT".
- I say "0.1" to not be presumptuous. In other words, projects that are just starting out should start at 0.1, until they get tested and used at least a little bit.
- The "-SNAPSHOT" is a Maven standard which means that this is a project which is currently in development. It can be removed once the project is officially "released".
- mavenPassword - This will be the Maven password you got when you registered.
- mavenUsername - This will be the Maven username which you got when you registered.
- mongoDBServer: - (localhost:27017) This will be the url to the mongoDB Server.
After you enter the final information and press Enter, you are prompted to confirm the entered information. Enter Y and Enter again.
Example output:
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
>mvn archetype:generate -DarchetypeGroupId=com.accenture.aspire -DarchetypeArtifactId=aspire-distribution-archetype -DarchetypeVersion=4.0 -DrepositoryId=stPublic
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) > generate-sources @ standalone-pom >>>
.
.
.
Define value for property 'groupId': : com.accenture
Define value for property 'artifactId': : aspire-demo
Define value for property 'version': 1.0-SNAPSHOT: : 0.1-SNAPSHOT
[INFO] Using property: package = pom
[INFO] Using property: aspireAdminPort = 50505
Define value for property 'mavenPassword': : xxx
Define value for property 'mavenUser': : [email protected]
Confirm properties configuration:
groupId: com.accenture
artifactId: aspire-demo
version: 0.1-SNAPSHOT
package: pom
aspireAdminPort: 50505
defaultMongo: localhost:27017
mavenPassword: xxx
mavenUser: [email protected]
mongoDBServer: localhost:27017
Y: : y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: aspire-distribution-archetype:4.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.accenture
[INFO] Parameter: artifactId, Value: aspire-demo
[INFO] Parameter: version, Value: 0.1-SNAPSHOT
[INFO] Parameter: package, Value: pom
[INFO] Parameter: packageInPathFormat, Value: pom
[INFO] Parameter: mongoDBServer, Value: localhost:27017
[INFO] Parameter: aspireAdminPort, Value: 50505
[INFO] Parameter: groupId, Value: com.accenture
[INFO] Parameter: version, Value: 0.1-SNAPSHOT
[INFO] Parameter: defaultMongo, Value: localhost:27017
[INFO] Parameter: package, Value: pom
[INFO] Parameter: mavenUser, Value: [email protected]
[INFO] Parameter: mavenPassword, Value: xxx
[INFO] Parameter: artifactId, Value: aspire-demo
[INFO] project created from Archetype in dir: C:\Users\AspireDemo\aspire-demo
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:19 min
[INFO] Finished at: 2016-02-22T00:29:09-06:00
[INFO] Final Memory: 14M/172M
[INFO] ------------------------------------------------------------------------
|
Step 3: Build the distribution
So now you can run Aspire, right? Well, actually, there's one more step.
The purpose of the Maven archetype (the previous step) was to build a Maven distribution project. Essentially, this is a template distribution. Now let's use Maven to build the distribution itself.
The sequence goes like this:
Code Block |
---|
|
Aspire Distribution Archetype --mvn--> Aspire Distribution Project --mvn--> Aspire Distribution |
Why is it so complicated?
Well, Aspire is meant for industrial-strength production installations. It is not a toy system. This means:
- There needs to be a solid, repeatable method for building deployments.
- The same distribution will likely need to be built for multiple environments:
- Development
- Quality Assurance
- Staging
- Production
The Maven Distribution Project amply fulfills these needs. It provides a template for building copies of your distribution. Maven "profiles" can be used to customize the template for different environments, specifying different server addresses and database names for the Development environment vs the Staging environment, for example.
Build the Aspire distribution
Okay, so let's actually build our Aspire distribution. Fortunately, this is very easy.
- Change your working directory into your Maven distribution project. This is the same as what you entered for the artifactId.
- In the command window, run: mvn clean package
Again, since this is your first time running "mvn package", Maven will download a bunch of plug-ins, which it needs. But after that's done, it will build the Aspire distribution and you're ready to go.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
> cd aspire-demo
>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Aspire Distribution Project 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repository.searchtechnologies.com/artifactory/public/com/accenture/aspire/aspire-bootloader/4.0/maven-metadata.xml
.
.
.
[INFO] Reading assembly descriptor: distribution.xml
[WARNING] Cannot include project artifact: com.accenture-demo:jar:0.1-SNAPSHOT; it doesn't have an associated file or directory.
[WARNING] Cannot include project artifact: com.accenture-demo:jar:0.1-SNAPSHOT; it doesn't have an associated file or directory.
[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o 'com.accenture:aspire-demo:jar:0.1-SNAPSHOT'
[WARNING] Cannot include project artifact: com.accenture-demo:jar:0.1-SNAPSHOT; it doesn't have an associated file or directory.
[WARNING] Cannot include project artifact: com.accenture-demo:jar:0.1-SNAPSHOT; it doesn't have an associated file or directory.
[INFO] Copying files to C:\Users\AspireDemo\aspire-demo\target\aspire-demo-0.1-SNAPSHOT-distribution
[WARNING] Assembly file: C:\Users\AspireDemo\aspire-demo\target\aspire-demo-0.1-SNAPSHOT-distribution is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.855 s
[INFO] Finished at: 2016-02-22T00:37:05-06:00
[INFO] Final Memory: 14M/168M
[INFO] ------------------------------------------------------------------------ |
Anchor |
---|
| Messages that appear when building the distribution |
---|
| Messages that appear when building the distribution |
---|
|
Messages that appear when building the distribution (optionally)
There are a number of warning message you may see when building the distribution. Don't let this worry you. Basically, if you see the following message, everything worked.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------ |
There's an explanation for warnings you may see
This warning refers to the fact we don’t "hard code" the encoding for the ASCII files we use. This shouldn’t cause any issues as long as you’re not working in a language that uses extended character sets.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent! |
We changed the build process so that you could include dependencies in the pom file to cause “application bundles” to be copied from Maven in to the target bundles/aspire directory at build time. This allows Aspire to use those application bundles on hosts that do not have internet access. You've always been able to do that with component bundles. The message below tells you that you have no dependencies with the group id com.accenture.appbundles.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'com.accenture.appbundles:*' |
Some versions of Maven's mvn command produce an unwanted file and copy it to the target bundles/aspire directory . This warning indicates that your version did not (as this line warns you the file is not being excluded when things are being copied to the target directory).
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o 'com.accenture:aspire-demo:jar:0.3-SNAPSHOT' |
This warning refers to the fact that the build is copying to a directory and cannot produce something that can be placed back in a Maven repository.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[WARNING] Assembly file: /Users/st/aspire-test-3/aspire-demo/target/aspire-demo-0.3-SNAPSHOT-distribution is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment. |
mvn install
You can't run this command to build a distribution, so make sure you use mvn package (as detailed above) instead. If you use install, the build will fail and you'll see the following message.
Code Block |
---|
language | text |
---|
theme | FadeToGrey |
---|
|
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-install) on project test-project: The packaging for this project did not assign a file to the build artifact -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException |
What do we have?
The following diagram shows the directory structure you have created within your Maven distribution project so far: