Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
TYCHO-279 HTTP proxy support
Browse files Browse the repository at this point in the history
configure the eclipse proxy service of the
embedded equinox according to the proxies
section of maven's settings.xml.
Take care to discard persistent proxy settings after maven session has
ended because the eclipse proxy service always persists
its configuration in a .prefs file which would then affect
subsequent builds. Remove native fragments for
org.eclipse.core.net from tycho-p2-runtime as they interfere
with settting the proxy settings by getting proxy settings
directly from the OS which is no longer needed now.
Added integration test which starts an HTTP server as well
as a proxy server to serve a p2 repo via a proxy (with
and w/o proxy authentication).
Resolve conflicting versions of jetty-embedded in ITs: use
version 6.1.12.
  • Loading branch information
jsievers committed Jul 14, 2010
1 parent b106919 commit 61e6a3c
Show file tree
Hide file tree
Showing 23 changed files with 934 additions and 25 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Expand Up @@ -131,6 +131,11 @@
<artifactId>maven-compat</artifactId>
<version>${maven-version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${maven-version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
4 changes: 4 additions & 0 deletions tycho-equinox/pom.xml
Expand Up @@ -28,6 +28,10 @@
<artifactId>org.eclipse.osgi</artifactId>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -2,7 +2,9 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.codehaus.plexus.component.annotations.Component;
Expand Down Expand Up @@ -33,6 +35,8 @@ public class DefaultEquinoxEmbedder

private String[] nonFrameworkArgs;

private List<Runnable> afterStartCallbacks = new ArrayList<Runnable>();

public synchronized void start()
throws Exception
{
Expand Down Expand Up @@ -85,11 +89,8 @@ protected void doStart()
// EclipseStarter is not helping here

EclipseStarter.setInitialProperties( properties );

EclipseStarter.startup( nonFrameworkArgs != null ? nonFrameworkArgs : new String[0], null );

frameworkContext = EclipseStarter.getSystemBundleContext();

PackageAdmin packageAdmin = null;
ServiceReference packageAdminRef = frameworkContext.getServiceReference( PackageAdmin.class.getName() );
if ( packageAdminRef != null )
Expand All @@ -108,7 +109,7 @@ protected void doStart()
{
try
{
bundle.start();
bundle.start( );
}
catch ( BundleException e )
{
Expand All @@ -118,6 +119,10 @@ protected void doStart()
}

frameworkContext.ungetService( packageAdminRef );
for ( Runnable callback : afterStartCallbacks )
{
callback.run();
}
}

public File getRuntimeLocation()
Expand Down Expand Up @@ -189,4 +194,10 @@ public void setNonFrameworkArgs( String[] args )
{
nonFrameworkArgs = args;
}

public void registerAfterStartCallback( Runnable callback )
{
this.afterStartCallbacks.add( callback );
}

}
Expand Up @@ -6,8 +6,15 @@ public interface EquinoxEmbedder
{

public <T> T getService( Class<T> clazz );


/**
* Register a callback which will be notified when all bundles are started.
*/
public void registerAfterStartCallback( Runnable callback);

public File getRuntimeLocation();

public void setNonFrameworkArgs( String[] strings );


}
4 changes: 2 additions & 2 deletions tycho-its/pom.xml
Expand Up @@ -117,8 +117,8 @@
<!-- update site tests -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>embedded</artifactId>
<version>6.0.0rc2</version>
<artifactId>jetty-embedded</artifactId>
<version>6.1.12</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
Expand Down
@@ -0,0 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bundle
Bundle-SymbolicName: bundle
Bundle-Version: 0.0.1.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: tycho279.bundle
4 changes: 4 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/bundle/build.properties
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
13 changes: 13 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/bundle/pom.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.tycho.its</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>bundle</artifactId>
<packaging>eclipse-plugin</packaging>
</project>
40 changes: 40 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/pom.xml
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.sonatype.tycho.its</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>bundle</module>
</modules>

<repositories>
<repository>
<id>test</id>
<layout>p2</layout>
<url>${p2.repo}</url>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.sonatype.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.sonatype.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
</configuration>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/repo/artifacts.xml
@@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<repository name='file:/c:/tmp/test279/repo - artifacts' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
<properties size='2'>
<property name='p2.timestamp' value='1278495494171'/>
<property name='p2.compressed' value='false'/>
</properties>
<mappings size='3'>
<rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
<rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
<rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
</mappings>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='tycho279.bundle' version='1.0.0.201007071134'>
<properties size='3'>
<property name='artifact.size' value='368'/>
<property name='download.size' value='368'/>
<property name='download.md5' value='41a4da2745bc458d0cb6a7d86bd8a0e3'/>
</properties>
</artifact>
</artifacts>
</repository>
32 changes: 32 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/repo/content.xml
@@ -0,0 +1,32 @@
<?xml version='1.0' encoding='UTF-8'?>
<?metadataRepository version='1.1.0'?>
<repository name='file:/c:/tmp/test279/repo - metadata' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
<properties size='2'>
<property name='p2.timestamp' value='1278495494203'/>
<property name='p2.compressed' value='false'/>
</properties>
<units size='1'>
<unit id='tycho279.bundle' version='1.0.0.201007071134' singleton='false'>
<update id='tycho279.bundle' range='[0.0.0,1.0.0.201007071134)' severity='0'/>
<properties size='1'>
<property name='org.eclipse.equinox.p2.name' value='tycho279.bundle'/>
</properties>
<provides size='3'>
<provided namespace='org.eclipse.equinox.p2.iu' name='tycho279.bundle' version='1.0.0.201007071134'/>
<provided namespace='osgi.bundle' name='tycho279.bundle' version='1.0.0.201007071134'/>
<provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
</provides>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='tycho279.bundle' version='1.0.0.201007071134'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='1'>
<instruction key='manifest'>
Bundle-ManifestVersion: 2&#xA;Bundle-RequiredExecutionEnvironment: J2SE-1.5&#xA;Bundle-SymbolicName: tycho279.bundle&#xA;Bundle-Name: tycho279.bundle&#xA;Manifest-Version: 1.0&#xA;Bundle-Version: 1.0.0.201007071134&#xA;
</instruction>
</instructions>
</touchpointData>
</unit>
</units>
</repository>
Binary file not shown.
19 changes: 19 additions & 0 deletions tycho-its/projects/TYCHO279HttpProxy/settings.xml
@@ -0,0 +1,19 @@
<?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 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<proxies>
<proxy>
<id>http</id>
<active>true</active>
<protocol>http</protocol>
<host>localhost</host>
<port>WILL_BE_REPLACED</port>
<!-- it seems localhost is a nonProxyHost by default, next line will
cause also localhost to be proxied. This is needed for the test because both
http server and proxy server are running on localhost -->
<nonProxyHosts>DUMMY_NON_EXISTING_HOST</nonProxyHosts>
</proxy>
</proxies>
</settings>

0 comments on commit 61e6a3c

Please sign in to comment.