You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2020/09/03 13:21:39 UTC
[karaf] branch karaf-4.2.x updated: [KARAF-6828] Add fallback to
artifact ${project.build.directory}/${project.build.finalName}.jar in the
karaf:run goal
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
new 6b86267 [KARAF-6828] Add fallback to artifact ${project.build.directory}/${project.build.finalName}.jar in the karaf:run goal
6b86267 is described below
commit 6b862673639f050213103f96cb55afa7f2dbe145
Author: jbonofre <jb...@apache.org>
AuthorDate: Thu Sep 3 07:49:05 2020 +0200
[KARAF-6828] Add fallback to artifact ${project.build.directory}/${project.build.finalName}.jar in the karaf:run goal
(cherry picked from commit 471f2b67eaca0ad7b999d166ba6a438bb116a680)
---
.../java/org/apache/karaf/tooling/RunMojo.java | 29 ++++++++++++----------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
index ae439fe..20b6aad 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/RunMojo.java
@@ -175,23 +175,26 @@ public class RunMojo extends MojoSupport {
File artifact = project.getArtifact().getFile();
File attachedFeatureFile = getAttachedFeatureFile(project);
boolean artifactExists = artifact != null && artifact.exists();
+ if (!artifactExists) {
+ artifact = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".jar");
+ artifactExists = artifact != null && artifact.exists();
+ }
boolean attachedFeatureFileExists = attachedFeatureFile != null && attachedFeatureFile.exists();
- if (artifactExists) {
- if (project.getPackaging().equals("bundle")) {
- try {
- Bundle bundle = bundleContext.installBundle(artifact.toURI().toURL().toString());
- bundle.start();
- } catch (Exception e) {
- throw new MojoExecutionException("Can't deploy project artifact in container", e);
- }
- } else {
- throw new MojoExecutionException("Packaging " + project.getPackaging() + " is not supported");
- }
- } else if (attachedFeatureFileExists) {
+ if (attachedFeatureFileExists) {
+ getLog().info("Deploying features repository " + attachedFeatureFile.getAbsolutePath());
addFeaturesAttachmentAsFeatureRepository(featureService, attachedFeatureFile);
+ } else if (artifactExists) {
+ try {
+ getLog().info("Deploying bundle " + artifact.getAbsolutePath());
+ Bundle bundle = bundleContext.installBundle(artifact.toURI().toURL().toString());
+ bundle.start();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Can't deploy project artifact in container", e);
+ }
} else {
- throw new MojoExecutionException("Project artifact doesn't exist");
+ throw new MojoExecutionException("No artifact to deploy");
}
+ getLog().info("Artifact deployed");
}
}