# Populating the Maven Repository

The next step is populating your Maven repository with the Oracle artifacts. The Oracle Maven Synhronization plug-in populates a local or shared Maven repository from an Oracle home. When you install a Fusion Middleware 12c product, the Maven archetypes, plug-ins, and POMs are installed with the product install. When you run the plug-in, it finds the Oracle artifacts and transfers them to a Maven repository.

## How to Use the Oracle Maven Synchronization Plug-In

To use the plug-in start by specifying the location of the Oracle home and the location of the Maven repository using either a file system path, or a URL. The plug-in checks for all Maven artifacts in the Oracle home, then ensures that the artifacts are installed in the specified Maven repository, and that the versions match. This ensures the version numbers and the files match at the binary level, and that all patched files are reflected accurately in the Maven repository.

The plug-in is located in your ORACLE_HOME directory path and consists of two files:

- "The Maven POM file that describes the plug-in, which is located at `ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync.12.1.3.pom`

- "The JAR file that contains the plug-in, which is located at `ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/oracle-maven-sync.12.1.3.jar`

To run the plug-in you first need to install it on your Maven repository. You can install it into your local repository on your computer, or you can deploy it into a remote shared internal repository.

To install the plug-in to a local repository using the command line:

1. In a command prompt, navigate to the location of your Maven plug-in jar located at `ORACLE_COMMON/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3`

2. Run the following command to install to the default repository:

   `mvn install:install-file -DpomFile=oracle-maven-sync.12.1.3.pom -Dfile=oracle-maven-sync.12.1.3.jar`

   Run the following command to install to a specified directory:

   `mvn install:install-file -DpomFile=oracle-maven-sync.12.1.3.pom -Dfile=oracle-maven-sync.12.1.3.jar -Dmaven.repo.local=<path to local repository>`

   Using the Oracle Maven Synchronization Plug-In Install Command

To install the plug-in to a shared internal repository using the command line:

1. In a command prompt, navigate to the location of your plug-in jar at `ORACLE_COMMON/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3`

2. Run the following command:
   `mvn deploy:deploy-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://servername/archiva/repositories/internal -DrepositoryId=internal`

   For information about the deploy command see the Maven documentation at, `http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html`

## Running the Oracle Maven Synchronization Plug-in

The Oracle Maven Synchronization plug-in supports two Maven goals:

- Help - prints out help information. Execute the help goal by running mvn `com.oracle.maven:oracle-maven-sync:help`

- Push - populates a repository. Goal semantics depend on how you define your plug-in parameters.

To populate your repository, run the plug-in using the push goal. The push goal requires you define your plug-in parameters. You can pouplate a local or a remote repository using the push goal.Push goal parameters are defined in Table: Push Goal Parameters and Descriptions. You can specify the parameters either in your command line or in your POM file.

Push Goal Parameters and Descriptions

Features | Description
--- | ---
`ServerID` | A pointer to the server entry in your Maven settings.xml file. This is required only if you intend to deploy to a remote repository. The settings.xml should provide the remote artifact repository deployment information, such as URL, user name, and password.
`oracleHome` | The path to the Oracle home that you wish to populate the Maven repository from.
`testingOnly` | This controls whether the plug-in attempts to publish the artifacts to the repository. If you test this to `true,` which is the default value, then the push goal will find all of your POM files and print out details of what it would have done if this is set to false. However, it does not publish any artifacts or make any change to the system.
`failOnError` | If you set this property to `false` and the plug-in fails to process a resource, it continues to process all resources. Failures are logged as warnings, but the process completes successfully. If you set this property to `true,` when it encounters the first problem the plug-in will immediately exit with an error.This is the default.

### Populating a Local Repository

If you are populating a local repository, specify `oracleHome and testingOnly=false`.

The localRepository element in your `settings.xml` file indicates the location of your local Maven repository. If you exclude the localRepository element in your in `settings.xml`, the default location is in the `${HOME}/.m2/`repository directory.

If you want to override the localRepository value, then you must specify the override location on the command line as a Maven option, for example,

`mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/path/to/oracleHome -Dmaven.repo.local=/alter/nate/pa`th

To specify the parameters in your POM file, you must add a plug-in entry similar to the following in your POM file, as shown in Table: Plug-in Parameters in Your POM File.

Plug-in Parameters in Your POM File

    <plugin>
    <groupID>com.oracle.maven</groupID>
    <artifaceID>oracle-maven-sync</artifactID>
    <version>12.1.3</version>
    <configuration>/home/<name>/Oracle/Middleware</oracleHome>
    </configuration>
    </plugin>

To populate a local repository:

1. Open the command prompt and navigate to the following directory in your OEPE install: `{install}/plugins/oracle.eclipse.tools.adf/maven/ADF Basic Application Archetype.`

2. Run the following command if you HAVE NOT defined the parameters in your POM file:

   `mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/path/to/oracleHome-Doracle-maven-sync.testingOnly=false`

   Run the following command if you HAVE defined the plug-in parameters in your POM file:

   `mvn com.oracle.maven:oracle-maven-sync:push`

### Populating a Remote Repository

If you are populating a remote repository, specify `serverId` and `oracleHome` on the command line or in the plug-in configuration. You must also have a repository configuration in your `settings.xml` that matches the server Id you provide to the plug-in. If authentication is required for deployment, you must also add a server entry to your Maven `settings.xml,`.for example:

`mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=/path/to/oracleHome -Doracle-maven-sync.serverId=internal`

In your `settings.xml` file, you must define the target repository in a profile, and activate that profile using the activeProfiles tag as shown in the Example: Maven setting.xml with Authentification Details.

Specify an encrypted password in the server section. For details on how to encrypt the server passwords, see the Apache website at, `http://maven.apache.org/guides/mini/guide-encryption.html#How_to_encrypt_server_passwords`

Maven setting.xml with Authentification Details

    <profiles>
     <profile>
     <id>default</id>
     <repositories>
      <repository>
       <releases>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
    <checksumPolicy>warn</checksumPolicy>
     </releases>
    <snapshots>
     <enabled>true</enabled>
     <updatePolicy>never</updatePolicy>
       <checksumPolicy>fail</checksumPolicy>
    </snapshots>
     <id>internal</id>
     <name>Team Internal Repository</name>
    <url>http://some.host/maven/repo/internal</url>
    <layout>default</layout>
    </repository>
    </repositories>
    </profile>
    </profiles>
    ...
    <server>
    <id>internal</id>
     <username>deployer</username>
    <password>welcome1</password>
       <password>welcome1</password>
      </server>
    ...
    <activeProfiles>
      <activeProfile>default</activeProfile>
    </activeProfiles>

To specify the parameters in your POM, add a plug-in entry similar to Example: POM File Parameters.

POM File Parameters

    <plugin>
    <groupId>com.oracle.maven</groupId>
     <artifactId>oracle-maven-sync</artifactId>
     <version>12.1.3</version>
      <configuration>
      <serverId>internal</serverId>
    <oracleHome>/path/to/oracleHome</oracleHome>
     <testOnly>false</testOnly>
     </configuration>
    </plugin>

To populate a remote repository:

1. Open the command prompt and navigate to the following directory in your Maven install: `{install}/plugins/oracle.eclipse.tools.adf/maven/ADF Basic Application Archetype.`

2. Run the following command:

   `mvn com.oracle.maven:oracle-maven-sync:push`

### What Happens When You Run a Push Goal to Populate a Repository?

When you run the push goal, the following actions are completed:

- Checks the Oracle home you have provided and makes a list of all of the Maven artifacts inside that Oracle home. This is done by looking for POM files in the `ORACLE_HOME/oracle_common/plugins/maven` dependencies directory and its subdirectories, recursively and in the `ORACLE_HOME/PRODUCT_HOME/plugins/maven` directory and its subdirectories recursively for each `PRODUCT_HOME` that exists in the `ORACLE_HOME`.

- Checks if the JAR file referred to by each POM file is available in the Oracle home.

- Calculates a SHA1 checksum for the JAR file.

- Attempts to publish the JAR, POM, and SHA1 files to the repository that you have provided.

The following types of Maven artifacts are installed into your repository:

- Maven dependencies provided by Oracle, which includes the following:

  - Client API classes

  - Compilation, packaging, and deployment utilities, for example, appc and wlst

  - Component JARs that must be embedded in the application

  - Client-side runtime classes, for example, t3 and JAX-WS client runtimes

- Maven plug-ins provided by Oracle that handle compilation, packaging, and deployment

- Maven archetypes provided by Oracle that provide project templates