-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding simple P2 resolver. Changing version to 1.2.0-SNAPSHOT. Switch…
…ing to tycho 0.21.0
- Loading branch information
Showing
36 changed files
with
478 additions
and
61 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.reficio.rcp</groupId> | ||
<artifactId>example-p2-site</artifactId> | ||
<packaging>pom</packaging> | ||
<version>1.0.0</version> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.reficio</groupId> | ||
<artifactId>p2-maven-plugin</artifactId> | ||
<version>1.2.0-SNAPSHOT</version> | ||
<executions> | ||
<execution> | ||
<id>default-cli</id> | ||
|
||
<configuration> | ||
<artifacts> | ||
<artifact> | ||
<id>commons-lang:commons-lang:2.4</id> | ||
</artifact> | ||
<artifact> | ||
<id>commons-lang:commons-lang:2.5</id> | ||
</artifact> | ||
<artifact> | ||
<id>commons-lang:commons-lang:2.6</id> | ||
</artifact> | ||
</artifacts> | ||
<p2> | ||
<artifact> | ||
<id>org.junit:4.11.0.v201303080030</id> | ||
</artifact> | ||
</p2> | ||
</configuration> | ||
|
||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.mortbay.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>8.1.5.v20120716</version> | ||
<configuration> | ||
<scanIntervalSeconds>10</scanIntervalSeconds> | ||
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory> | ||
<webApp> | ||
<contextPath>/site</contextPath> | ||
</webApp> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>reficio</id> | ||
<url>http://repo.reficio.org/maven/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<repositories> | ||
<repository> | ||
<id>kepler</id> | ||
<url>http://download.eclipse.org/tools/orbit/downloads/drops/R20130517111416/repository/</url> | ||
<layout>p2</layout> | ||
</repository> | ||
</repositories> | ||
|
||
</project> | ||
|
||
|
||
|
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
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
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
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
84 changes: 84 additions & 0 deletions
84
src/main/groovy/org/reficio/p2/resolver/eclipse/impl/DefaultEclipseResolver.groovy
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,84 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.reficio.p2.resolver.eclipse.impl | ||
|
||
import org.apache.commons.io.FilenameUtils | ||
import org.reficio.p2.logger.Logger | ||
import org.reficio.p2.resolver.eclipse.EclipseResolutionRequest | ||
import org.reficio.p2.resolver.eclipse.EclipseResolutionResponse | ||
import org.reficio.p2.resolver.eclipse.EclipseResolver | ||
|
||
class DefaultEclipseResolver implements EclipseResolver { | ||
|
||
final File target | ||
final List<?> repositories | ||
|
||
def DefaultEclipseResolver(List<?> repositories, File target) { | ||
this.target = target | ||
this.repositories = new ArrayList<?>(repositories) | ||
} | ||
|
||
@Override | ||
EclipseResolutionResponse resolve(EclipseResolutionRequest request) { | ||
List<File> result = [] | ||
result << resolveBundle(request) | ||
if (request.source) { | ||
result << resolveSource(request) | ||
} | ||
return new EclipseResolutionResponse(result) | ||
} | ||
|
||
File resolveBundle(EclipseResolutionRequest request) { | ||
String name = request.id + "_" + request.version + ".jar" | ||
File result = download(name, target) | ||
if (!result) { | ||
throw new RuntimeException("Cannot resolve [$name] from any given repository") | ||
} | ||
} | ||
|
||
File resolveSource(EclipseResolutionRequest request) { | ||
String name = request.id + ".source" + "_" + request.version + ".jar" | ||
File result = download(name, target) | ||
if (!result) { | ||
Logger.getLog().warn("Cannot resolve source [$name] from any given repository") | ||
} | ||
} | ||
|
||
File download(String name, File destination) { | ||
File file = new File(destination, name) | ||
for (def repository : repositories) { | ||
if (repository.type == "p2") { | ||
String url = repository.url + "/plugins/" + name | ||
Logger.getLog().info("\tDownloading: " + url) | ||
try { | ||
use(FileBinaryCategory) | ||
{ | ||
file << url.toURL() | ||
} | ||
if (file.exists()) { | ||
return file | ||
} | ||
} catch (Exception ex) { | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
31 changes: 31 additions & 0 deletions
31
src/main/groovy/org/reficio/p2/resolver/eclipse/impl/FileBinaryCategory.groovy
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,31 @@ | ||
/** | ||
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved. | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.reficio.p2.resolver.eclipse.impl | ||
|
||
class FileBinaryCategory { | ||
def static leftShift(File file, URL url) { | ||
url.withInputStream { is -> | ||
file.withOutputStream { os -> | ||
def bs = new BufferedOutputStream(os) | ||
bs << is | ||
} | ||
} | ||
} | ||
} | ||
|
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
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
Oops, something went wrong.