Skip to content

Commit

Permalink
Adding simple P2 resolver. Changing version to 1.2.0-SNAPSHOT. Switch…
Browse files Browse the repository at this point in the history
…ing to tycho 0.21.0
  • Loading branch information
tombujok committed Nov 24, 2014
1 parent 6bacd83 commit e8b91ad
Show file tree
Hide file tree
Showing 36 changed files with 478 additions and 61 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ Here's the pom.xml:
<groupId>org.reficio.rcp</groupId>
<artifactId>example-p2-site</artifactId>
<packaging>pom</packaging>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down Expand Up @@ -531,8 +531,8 @@ Sample configuration snippet with the additional options:
### How can I hack around?
* GitHub -> https://github.com/reficio/p2-maven-plugin
* Jenkins -> https://reficio.ci.cloudbees.com/view/p2-maven-plugin/
* Site -> http://projects.reficio.org/p2-maven-plugin/1.1.1/manual.html
* Coverage -> http://projects.reficio.org/p2-maven-plugin/1.1.1/clover/index.html
* Site -> http://projects.reficio.org/p2-maven-plugin/1.2.0-SNAPSHOT/manual.html
* Coverage -> http://projects.reficio.org/p2-maven-plugin/1.2.0-SNAPSHOT/clover/index.html

### Reporting bugs
Please describe the issue thoroughly. Please include a minimal pom.xml file that can be used to reproduce the problem.
Expand Down
2 changes: 1 addition & 1 deletion examples/excludes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down
2 changes: 1 addition & 1 deletion examples/override/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down
78 changes: 78 additions & 0 deletions examples/p2/pom.xml
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>



2 changes: 1 addition & 1 deletion examples/phase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<!-- PHASE EXAMPLE -->
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down
5 changes: 3 additions & 2 deletions examples/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ set -e
echo "Running the example projects:"
echo -ne "excludes\t"; mvn -f excludes/pom.xml p2:site > run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "override\t"; mvn -f override/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "phase \t"; mvn -f phase/pom.xml compile >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "p2\t"; mvn -f p2/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "phase \t"; mvn -f phase/pom.xml compile >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "quickstart\t"; mvn -f quickstart/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "source \t"; mvn -f source/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "source \t"; mvn -f source/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
echo -ne "transitive\t"; mvn -f transitive/pom.xml p2:site >> run.log && echo "[OK]" || echo "[FAILED]"
2 changes: 1 addition & 1 deletion examples/source/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down
2 changes: 1 addition & 1 deletion examples/transitive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>default-cli</id>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.1.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>p2-maven-plugin</name>
<url>http://projects.reficio.org/${project.artifactId}/${project.version}</url>
<description>Maven plugin for the automation of jars wrapping and p2 site generation</description>
Expand Down
7 changes: 4 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ current_version=$1
release_version=$2
new_version=$3

find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s/<version>$current_version<\/version>/<version>$release_version<\/version>/g" {} \;
find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s/projects.reficio.org\/p2-maven-plugin\/$current_version/projects.reficio.org\/p2-maven-plugin\/$release_version/g" {} \;
find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s#<version>$current_version</version>#<version>$release_version</version>#g" {} \;
find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s#projects.reficio.org/p2-maven-plugin/$current_version#projects.reficio.org/p2-maven-plugin/$release_version#g" {} \;
git commit -a -m "$release_version release"
git tag -a v$release_version -a -m "$release_version release"

find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s/<version>$release_version<\/version>/<version>$new_version<\/version>/g" {} \;
find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s#<version>$release_version</version>#<version>$new_version</version>#g" {} \;
find . \( -name "pom.xml" -or -name "README.md" \) -not -path "*/src/it/*" -not -path "*/target/*" -not -path "*svn*" -not -path "*git*" -exec sed -i "" "s#projects.reficio.org/p2-maven-plugin/$release_version#projects.reficio.org/p2-maven-plugin/$new_version#g" {} \;
git commit -a -m "Preparing $new_version iteration"

git push
Expand Down
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) {
}
}
}
}

}

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
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.reficio.p2.resolver.impl
package org.reficio.p2.resolver.maven.impl

import org.reficio.p2.resolver.impl.facade.AetherEclipseFacade
import org.reficio.p2.resolver.impl.facade.AetherFacade
import org.reficio.p2.resolver.impl.facade.AetherSonatypeFacade
import org.reficio.p2.resolver.maven.impl.facade.AetherEclipseFacade
import org.reficio.p2.resolver.maven.impl.facade.AetherFacade
import org.reficio.p2.resolver.maven.impl.facade.AetherSonatypeFacade

/**
* @author Tom Bujok (tom.bujok@gmail.com)<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.reficio.p2.resolver.impl
package org.reficio.p2.resolver.maven.impl

import org.apache.commons.lang.StringUtils
import org.reficio.p2.logger.Logger
import org.reficio.p2.resolver.*
import org.reficio.p2.resolver.impl.facade.AetherFacade
import org.reficio.p2.resolver.maven.impl.facade.AetherFacade
import org.reficio.p2.resolver.maven.Artifact
import org.reficio.p2.resolver.maven.ArtifactResolutionRequest
import org.reficio.p2.resolver.maven.ArtifactResolutionResult
import org.reficio.p2.resolver.maven.ArtifactResolver
import org.reficio.p2.resolver.maven.ResolvedArtifact

/**
* @author Tom Bujok (tom.bujok@gmail.com)<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.reficio.p2.resolver.impl.facade
package org.reficio.p2.resolver.maven.impl.facade

import org.eclipse.aether.artifact.Artifact as AetherArtifact
import org.eclipse.aether.artifact.DefaultArtifact
Expand All @@ -29,7 +29,7 @@ import org.eclipse.aether.resolution.DependencyRequest
import org.eclipse.aether.util.artifact.SubArtifact
import org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter
import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator
import org.reficio.p2.resolver.Artifact
import org.reficio.p2.resolver.maven.Artifact

/**
* @author Tom Bujok (tom.bujok@gmail.com)<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.reficio.p2.resolver.impl.facade
package org.reficio.p2.resolver.maven.impl.facade

import org.reficio.p2.resolver.Artifact
import org.reficio.p2.resolver.maven.Artifact

/**
* @author Tom Bujok (tom.bujok@gmail.com)<br>
Expand Down
Loading

0 comments on commit e8b91ad

Please sign in to comment.