Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OSGi Bundle deploy by setting symbolicName from manifest #140

Merged
merged 3 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cics-bundle-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>com.ibm.cics</groupId>
<artifactId>cics-bundle-common</artifactId>
<version>0.0.2</version>
<version>1.0.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
<dependencies>
<dependency>
<groupId>com.ibm.cics.test-no-transitive</groupId>
<artifactId>jar2</artifactId>
<artifactId>war2</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>

Expand Down
24 changes: 0 additions & 24 deletions cics-bundle-maven-plugin/src/it/test-no-transitive/jar1/pom.xml

This file was deleted.

4 changes: 2 additions & 2 deletions cics-bundle-maven-plugin/src/it/test-no-transitive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<packaging>pom</packaging>

<modules>
<module>jar1</module>
<module>jar2</module>
<module>war1</module>
<module>war2</module>
<module>bundle</module>
</modules>

Expand Down
50 changes: 50 additions & 0 deletions cics-bundle-maven-plugin/src/it/test-no-transitive/war1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
#%L
CICS Bundle Maven Plugin
%%
Copyright (C) 2019 IBM Corp.
%%
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0
#L%
-->
<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>
<parent>
<groupId>com.ibm.cics.test-no-transitive</groupId>
<artifactId>test-no-transitive</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>war1</artifactId>
<packaging>war</packaging>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,41 @@
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>jar2</artifactId>
<artifactId>war2</artifactId>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>com.ibm.cics.test-no-transitive</groupId>
<artifactId>jar1</artifactId>
<artifactId>war1</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ private void addExplicitBundleParts(BundlePublisher bundlePublisher, ArrayList<A
}
}

private void addBundleResourceForArtifact(BundlePublisher bundlePublisher, Artifact artifact,
BundlePartBinding binding) throws MojoExecutionException {
private void addBundleResourceForArtifact(BundlePublisher bundlePublisher, Artifact artifact, BundlePartBinding binding) throws MojoExecutionException {
try {
bundlePublisher.addResource(binding.toBundlePart(artifact, this));
binding.setResolvedArtifact(artifact);
bundlePublisher.addResource(binding.toBundlePart(this));
logBundlePartAdded(artifact, binding);
} catch (PublishException e) {
throw new MojoExecutionException("Error adding bundle resource for artifact " + artifact.toString() + ": " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.File;
import java.nio.file.Path;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
Expand Down Expand Up @@ -65,11 +66,12 @@ public String getJVMServer() {
public void execute() throws MojoExecutionException, MojoFailureException {
BundlePublisher bundlePublisher = getBundlePublisher();

org.apache.maven.artifact.Artifact artifact = project.getArtifact();
Artifact artifact = project.getArtifact();

try {
AbstractJavaBundlePartBinding bundlePartBinding = getBundlePartBinding(artifact);
bundlePublisher.addResource(bundlePartBinding.toBundlePart(artifact, this));
AbstractJavaBundlePartBinding bundlePartBinding = getBundlePartBinding();
bundlePartBinding.setResolvedArtifact(artifact);
bundlePublisher.addResource(bundlePartBinding.toBundlePart(this));
bundlePublisher.publishResources();
} catch (PublishException e) {
throw new MojoExecutionException(e.getMessage(), e);
Expand All @@ -90,6 +92,6 @@ protected Path getWorkDir() {
return workDir.toPath();
}

protected abstract AbstractJavaBundlePartBinding getBundlePartBinding(org.apache.maven.artifact.Artifact artifact) throws MojoExecutionException;
protected abstract AbstractJavaBundlePartBinding getBundlePartBinding();

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
*/

import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;

public abstract class AbstractJavaBundlePartBinding extends BundlePartBinding {

private String jvmserver;
protected String name;
protected String jvmserver;

public AbstractJavaBundlePartBinding() {
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getJvmserver() {
Expand All @@ -32,12 +37,18 @@ public String getJvmserver() {
public void setJvmserver(String jvmserver) {
this.jvmserver = jvmserver;
}

@Override
protected void applyDefaults(Artifact artifact, DefaultsProvider defaults) throws MojoExecutionException {
protected void applyDefaults(DefaultsProvider defaults) throws MojoExecutionException {

if (StringUtils.isEmpty(name)) {
name = resolvedArtifact.getArtifactId() + "-" + resolvedArtifact.getBaseVersion();
}

if (StringUtils.isEmpty(jvmserver)) {
String defaultJVMServer = defaults.getJVMServer();
if (StringUtils.isEmpty(defaultJVMServer)) {
throw new MojoExecutionException("Bundle part for artifact " + artifact + " did not specify a JVM server explicitly, and no default was configured");
throw new MojoExecutionException("Bundle part for artifact " + resolvedArtifact + " did not specify a JVM server explicitly, and no default was configured");
} else {
jvmserver = defaultJVMServer;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
* #L%
*/

/**
* Maven will automatically instantiate this class and populate its fields
* using the values in the pom.xml that are provided by the user when they
* explicitly configure a bundle part using a <bundleParts> entry. These values
* will then be used to resolve the Maven artifact that the <bundleParts> entry
* is referring to.
*/
public class Artifact {

private String groupId;
Expand All @@ -25,14 +32,6 @@ public class Artifact {
public Artifact() {
}

public Artifact(org.apache.maven.artifact.Artifact a) {
artifactId = a.getArtifactId();
groupId = a.getGroupId();
type = a.getType();
version = a.getBaseVersion();
classifier = a.getClassifier();
}

public String getClassifier() {
return classifier;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ibm.cics.cbmp;
package com.ibm.cics.cbmp;

/*-
* #%L
Expand Down Expand Up @@ -26,7 +26,7 @@
public class BundleEarMojo extends AbstractBundleJavaMojo {

@Override
protected AbstractJavaBundlePartBinding getBundlePartBinding(org.apache.maven.artifact.Artifact artifact) {
protected AbstractJavaBundlePartBinding getBundlePartBinding() {
return new Earbundle();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ibm.cics.cbmp;

import org.apache.maven.plugin.MojoExecutionException;

/*-
* #%L
* CICS Bundle Maven Plugin
Expand All @@ -28,7 +26,7 @@
public class BundleEbaMojo extends AbstractBundleJavaMojo {

@Override
protected AbstractJavaBundlePartBinding getBundlePartBinding(org.apache.maven.artifact.Artifact artifact) throws MojoExecutionException {
protected AbstractJavaBundlePartBinding getBundlePartBinding() {
return new Ebabundle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* #L%
*/

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
Expand All @@ -28,7 +26,7 @@
public class BundleOSGiMojo extends AbstractBundleJavaMojo {

@Override
protected AbstractJavaBundlePartBinding getBundlePartBinding(Artifact artifact) throws MojoExecutionException {
protected AbstractJavaBundlePartBinding getBundlePartBinding() {
return new Osgibundle();
}

Expand Down
Loading