-
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.
Create tycho-repository-plugin to generate standard OSGi repositories
- Loading branch information
Showing
17 changed files
with
444 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Publish bundles as an OSGi Repository to maven repository | ||
|
||
This Demo shows how to publish a set of bundles as an OSGi Repository and deploy it to a maven repository (simulated by a folder here), | ||
with this approach it is possible to deploy a whole project consumable by OSGi and maven users with only using the maven repository as the backing store. | ||
|
||
This example uses a single bundle build with bnd-maven-plugin, but actually any jar project that produces a bundle (including Tycho ones) would work! | ||
|
||
As a result of building the project with `mvn clean deploy -DaltDeploymentRepository=snapshot-repo::default::file:maven-repository` you can inspect the following items: | ||
|
||
- find the produced site in `site/target/repository` | ||
- see the deployed artifacts in the file base maven repository under `maven-repository` | ||
|
||
**Currently there is no support in Eclipse/Tycho for consuming such repository!** |
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 @@ | ||
/org/ |
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,39 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.tycho.demo</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0</version> | ||
</parent> | ||
<artifactId>my-bundle</artifactId> | ||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.annotation.bundle</artifactId> | ||
<version>2.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>biz.aQute.bnd</groupId> | ||
<artifactId>bnd-maven-plugin</artifactId> | ||
<version>6.4.0</version> | ||
<extensions>true</extensions> | ||
<executions> | ||
<execution> | ||
<id>jar</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
6 changes: 6 additions & 0 deletions
6
demo/osgi-repository/my-bundle/src/main/java/hello/world/GreetingService.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,6 @@ | ||
package hello.world; | ||
|
||
public interface GreetingService { | ||
|
||
void sayHello(); | ||
} |
3 changes: 3 additions & 0 deletions
3
demo/osgi-repository/my-bundle/src/main/java/hello/world/package-info.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,3 @@ | ||
@org.osgi.annotation.bundle.Export | ||
@org.osgi.annotation.versioning.Version("1.0") | ||
package hello.world; |
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,15 @@ | ||
<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>org.eclipse.tycho.demo</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>repository</module> | ||
<module>my-bundle</module> | ||
</modules> | ||
<properties> | ||
<tycho-version>5.0.0-SNAPSHOT</tycho-version> | ||
</properties> | ||
|
||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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> | ||
<parent> | ||
<groupId>org.eclipse.tycho.demo</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0</version> | ||
</parent> | ||
<artifactId>repository</artifactId> | ||
<packaging>repository</packaging> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-repository-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<!-- Extensions must be enabled for this mojo to work reliable and for using the custom package type--> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</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
31 changes: 31 additions & 0 deletions
31
tycho-api/src/main/java/org/eclipse/tycho/MavenArtifactNamespace.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,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho; | ||
|
||
public class MavenArtifactNamespace { | ||
|
||
/** | ||
* Namespace name for maven artifact capabilities and requirements. | ||
*/ | ||
public static final String MAVEN_ARTIFACT_NAMESPACE = "apache.maven.artifact"; | ||
|
||
/** | ||
* The capability attribute identifying the group id. | ||
*/ | ||
public static final String CAPABILITY_GROUP_ATTRIBUTE = "group"; | ||
|
||
/** | ||
* The capability attribute identifying the {@code Version} of the artifact. | ||
*/ | ||
public static final String CAPABILITY_VERSION_ATTRIBUTE = "version"; | ||
} |
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,8 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore | ||
org.eclipse.jdt.core.compiler.release=disabled | ||
org.eclipse.jdt.core.compiler.source=17 |
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,71 @@ | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho</artifactId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>tycho-repository-plugin</artifactId> | ||
<name>Tycho Repository Plugin</name> | ||
<description>Mojos dedicated to creating OSGi Repositories</description> | ||
<packaging>maven-plugin</packaging> | ||
<prerequisites> | ||
<maven>${minimal-maven-version}</maven> | ||
</prerequisites> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>biz.aQute.bnd</groupId> | ||
<artifactId>biz.aQute.bndlib</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.service.repository</artifactId> | ||
<version>1.1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.util.function</artifactId> | ||
<version>1.2.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.osgi</groupId> | ||
<artifactId>org.osgi.util.promise</artifactId> | ||
<version>1.3.0</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-component-metadata</artifactId> | ||
<configuration> | ||
<staticMetadataDirectory>${project.build.directory}/filtered/META-INF/plexus/</staticMetadataDirectory> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<targetPath>${project.build.directory}/filtered</targetPath> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
53 changes: 53 additions & 0 deletions
53
...n/src/main/java/org/eclipse/tycho/repository/plugin/PackageMavenLifecycleParticipant.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,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Christoph Läubrich 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: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.repository.plugin; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.maven.AbstractMavenLifecycleParticipant; | ||
import org.apache.maven.MavenExecutionException; | ||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.model.Dependency; | ||
import org.apache.maven.model.Plugin; | ||
import org.apache.maven.project.MavenProject; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
@Component(role = AbstractMavenLifecycleParticipant.class) | ||
public class PackageMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { | ||
|
||
@Override | ||
public void afterProjectsRead(MavenSession session) throws MavenExecutionException { | ||
List<MavenProject> projects = session.getProjects(); | ||
for (MavenProject project : projects) { | ||
if ("repository".equals(project.getPackaging()) && project.getPlugin("org.eclipse.tycho:tycho-repository-plugin") != null) { | ||
addInterestingProjects(project, projects); | ||
} | ||
} | ||
} | ||
|
||
private void addInterestingProjects(MavenProject project, List<MavenProject> projects) { | ||
for (MavenProject other : projects) { | ||
if (other == project) { | ||
continue; | ||
} | ||
if (PackageMavenRepositoryMojo.isInteresting(other)) { | ||
Dependency dependency = new Dependency(); | ||
dependency.setGroupId(other.getGroupId()); | ||
dependency.setArtifactId(other.getArtifactId()); | ||
dependency.setVersion(other.getVersion()); | ||
project.getModel().addDependency(dependency); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.