# Maven Integration

Maven resolves artifacts using the configured remote repositories in settings.xml. To route Maven through the Lineaje Proxy, you redirect all repositories and mirror traffic to the Proxy's Maven endpoint. Proxy Maven URL:

```
// Enforce Mode: block all non-compliant builds 
https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven  

// Observe Mode: Report all non-compliant dependency downloads 
https://observe.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven 
```

<details>

<summary>Settings.xml Configuration</summary>

Place this file at the root of your repository (or reference it via the -s flag in the Maven command). It configures authentication, mirrors all Maven traffic through the Proxy, and activates a profile that sets the Proxy as the primary repository.

```xml
<?xml version="1.0" encoding="UTF-8"?> 
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
          https://maven.apache.org/xsd/settings-1.0.0.xsd"> 

  <!-- 1. Credentials for the Proxy endpoint --> 
  <servers> 
    <server> 
      <id>lineaje-fortknox</id> 
      <username>${env.ARTIFACTORY_CREDS_USR}</username> 
      <password>${env.ARTIFACTORY_CREDS_PSW}</password> 
      <configuration> 
        <httpConfiguration> 
          <all> 
            <usePreemptive>true</usePreemptive> 
          </all> 
        </httpConfiguration> 
      </configuration> 
    </server> 
  </servers> 

  <!-- 2. Mirror ALL Maven traffic through the Proxy --> 
  <mirrors> 
    <mirror> 
      <id>lineaje-fortknox</id> 
      <name>Lineaje FortKnox Proxy</name> 
      <url>https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url> 
      <mirrorOf>*</mirrorOf> 
    </mirror> 
  </mirrors> 
 
  <!-- 3. Active profile defining the Proxy as the repository --> 
  <profiles> 
    <profile> 
      <id>lineaje-fortknox-profile</id> 
      <repositories> 
        <repository> 
          <id>lineaje-fortknox</id> 
          <name>Lineaje FortKnox Proxy</name> 
          <url>https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven</url> 
          <releases>  <enabled>true</enabled>  </releases> 
          <snapshots><enabled>false</enabled></snapshots> 
        </repository> 
      </repositories> 
      <pluginRepositories> 
        <pluginRepository> 
          <id>central</id> 
          <url>https://repo.maven.apache.org/maven2</url> 
        </pluginRepository> 
      </pluginRepositories> 
    </profile> 
  </profiles> 
  
  <activeProfiles> 
    <activeProfile>lineaje-fortknox-profile</activeProfile> 
  </activeProfiles> 
  
</settings> 
```

{% hint style="info" %}
File: settings.xml. Commit to repository root alongside pom.xml.
{% endhint %}

</details>

<details>

<summary>Jenkinsfile Configuration Example</summary>

```groovy
pipeline { 
  agent any 
  environment { 
 ARTIFACTORY_CREDS = credentials(‘<ID>’) 
    ARTIFACTORY_URL = 'https://enforce.fortknox.v2.prod.veedna.com' + 
                      '/artifactory/api/pypi/gos-all-proxy-python/simple' 
  } 
stages { 
        stage('Build') { 
            steps { 
                script { 
                    // Set up the pip index URL with authentication 
                    // We encode the URL to include the credentials safely in the environment 
                    def pipIndexUrl = "https://${ARTIFACTORY_CREDS_USR}:${ARTIFACTORY_CREDS_PSW}@${ARTIFACTORY_URL}" 

                    withEnv(["PIP_INDEX_URL=${pipIndexUrl}"]) { 
                         // Optional: Create a virtual environment 
                        sh 'python3 -m venv venv' 
     // Install dependencies 
     // PIP_INDEX_URL env var is automatically picked up by pip 
                        sh './venv/bin/python -m pip install -vvv --no-cache-dir --index-url "${PIP_INDEX_URL}" --trusted-host enforce.fortknox.v2.prod.veedna.com -r requirements.txt' 

                        // Run the script 
                        sh './venv/bin/python main.py' 
                    } 
                } 
            } 
        } 
    } 
} 
```

</details>

<details>

<summary>Verifying Proxy Routing</summary>

With the -X (debug) flag enabled, Maven prints the repository URL for each resolved artifact. Confirm that all resolution lines reference the Proxy URL:

```
# Expected in build log: 
Downloaded from lineaje-fortknox: 
  https://enforce.fortknox.v2.prod.veedna.com/artifactory/gos-all-proxy-maven/ 
  org/json/json/20230227/json-20230227.jar 
```

To detect policy violations, search build logs for the string. To learn more, see [Detecting Policy Violations in Build Logs](broken://pages/Q10H9NLvhjgbZrQoxsqI).

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.veedna.com/gold-open-source-gos/gold-catalog/oss-packages/integrating-lineaje-gos-artifactory-proxy-into-your-ci-cd-pipeline/maven-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
