-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject content of settings.xml into artifact repositories.
For artifact repositories which have been specified in the target platform definition, Tycho creates a minimal instance, containing only an id and url, which is then injected back into the Maven model. In order to support e.g. authenticating against a private repository, it is necessary to also inject the user credentials, provided via the local settings.xml, into this instance. Otherwise accessing the referenced artifacts fails with a 401 - Unauthorized.
- Loading branch information
Showing
16 changed files
with
231 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tycho-its/projects/target.maven.httpAuthentication/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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>tycho-its-project</groupId> | ||
<artifactId>target.maven.httpAuthentication</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<tycho-version>3.0.0-SNAPSHOT</tycho-version> | ||
</properties> | ||
|
||
<modules> | ||
<module>target.test</module> | ||
<module>test.bundle</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>target-platform-configuration</artifactId> | ||
<version>${tycho-version}</version> | ||
<configuration> | ||
<target> | ||
<artifact> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>target-definition</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</artifact> | ||
</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
9 changes: 9 additions & 0 deletions
9
tycho-its/projects/target.maven.httpAuthentication/settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<settings> | ||
<servers> | ||
<server> | ||
<id>test-server</id> | ||
<username>test-user</username> | ||
<password>test-password</password> | ||
</server> | ||
</servers> | ||
</settings> |
23 changes: 23 additions & 0 deletions
23
tycho-its/projects/target.maven.httpAuthentication/target.test/platform.target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?pde version="3.5"?> | ||
<target name="platform"> | ||
<locations> | ||
|
||
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="DSA 3pps" missingManifest="generate" type="Maven"> | ||
<dependencies> | ||
<dependency> | ||
<groupId>test</groupId> | ||
<artifactId>bundle</artifactId> | ||
<version>1.0.0</version> | ||
<type>jar</type> | ||
</dependency> | ||
</dependencies> | ||
<repositories> | ||
<repository> | ||
<id>test-server</id> | ||
<url>https://nexusext.app.corp.dsa.de/repository/sfp-alp-eal-group-releases/</url> | ||
</repository> | ||
</repositories> | ||
</location> | ||
</locations> | ||
</target> |
14 changes: 14 additions & 0 deletions
14
tycho-its/projects/target.maven.httpAuthentication/target.test/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 https://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>target-definition</artifactId> | ||
<packaging>eclipse-target-definition</packaging> | ||
|
||
<parent> | ||
<groupId>tycho-its-project</groupId> | ||
<artifactId>target.maven.httpAuthentication</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
</project> |
7 changes: 7 additions & 0 deletions
7
tycho-its/projects/target.maven.httpAuthentication/test.bundle/.classpath
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
9 changes: 9 additions & 0 deletions
9
...projects/target.maven.httpAuthentication/test.bundle/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 | ||
org.eclipse.jdt.core.compiler.compliance=11 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=11 |
7 changes: 7 additions & 0 deletions
7
tycho-its/projects/target.maven.httpAuthentication/test.bundle/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Bundle Plug-in | ||
Bundle-SymbolicName: test.bundle | ||
Bundle-Version: 0.0.1.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Require-Bundle: bundle |
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/target.maven.httpAuthentication/test.bundle/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
14 changes: 14 additions & 0 deletions
14
tycho-its/projects/target.maven.httpAuthentication/test.bundle/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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> | ||
|
||
<artifactId>test.bundle</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
<parent> | ||
<groupId>tycho-its-project</groupId> | ||
<artifactId>target.maven.httpAuthentication</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
</project> |
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
tycho-its/repositories/m2/test/bundle/1.0.0/bundle-1.0.0.pom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>test</groupId> | ||
<artifactId>bundle</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>eclipse-plugin</packaging> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>2.7.0</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
60 changes: 60 additions & 0 deletions
60
tycho-its/src/test/java/org/eclipse/tycho/test/target/PasswordProtectedM2RepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Sonatype Inc. and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Patrick Ziegler - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.test.target; | ||
|
||
import java.io.File; | ||
import java.util.Properties; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.eclipse.tycho.test.util.HttpServer; | ||
import org.eclipse.tycho.test.util.ResourceUtil; | ||
import org.eclipse.tycho.test.util.TargetDefinitionUtil; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class PasswordProtectedM2RepositoryTest extends AbstractTychoIntegrationTest { | ||
|
||
private HttpServer server; | ||
private String m2RepoUrl; | ||
|
||
@Before | ||
public void startServer() throws Exception { | ||
server = HttpServer.startServer("test-user", "test-password"); | ||
m2RepoUrl = server.addServer("foo", ResourceUtil.resolveTestResource("repositories/m2")); | ||
} | ||
|
||
@After | ||
public void stopServer() throws Exception { | ||
server.stop(); | ||
} | ||
|
||
@Test | ||
public void testTargetDefinition() throws Exception { | ||
Verifier verifier = createVerifier("settings.xml"); | ||
File platformBundle = new File(verifier.getBasedir(), "target.test"); | ||
File platformFile = new File(platformBundle, "platform.target"); | ||
TargetDefinitionUtil.setRepositoryURLs(platformFile, m2RepoUrl); | ||
verifier.executeGoal("package"); | ||
verifier.verifyErrorFreeLog(); | ||
} | ||
|
||
private Verifier createVerifier(String settingsFile) throws Exception { | ||
Verifier verifier = getVerifier("target.maven.httpAuthentication", false, | ||
new File("projects/target.maven.httpAuthentication/" + settingsFile)); | ||
Properties systemProperties = verifier.getSystemProperties(); | ||
systemProperties.setProperty("m2.repo", m2RepoUrl); | ||
return verifier; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters