You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/06/28 17:47:23 UTC
svn commit: r551602 [2/4] - in /incubator/servicemix/trunk/tooling: ./
jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/
jbi-maven-plugin/src/test/java/org/apache/servicemix/maven/plugin/jbi/
xfire-maven-plugin/src/main/java/org/ap...
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java Thu Jun 28 08:47:21 2007
@@ -44,56 +44,57 @@
*/
public class GenerateServiceAssemblyMojo extends AbstractJbiMojo {
- /**
- * Directory where the application.xml file will be auto-generated.
- *
- * @parameter expression="${project.build.directory}/classes"
- * @required
- */
- private File workDirectory;
+ /**
+ * Directory where the application.xml file will be auto-generated.
+ *
+ * @parameter expression="${project.build.directory}/classes"
+ * @required
+ */
+ private File workDirectory;
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- injectDependentServiceUnits();
- } catch (Exception e) {
- throw new MojoExecutionException("Failed to inject dependencies", e);
- }
- }
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ injectDependentServiceUnits();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Failed to inject dependencies", e);
+ }
+ }
- private void injectDependentServiceUnits() throws JbiPluginException,
- ArtifactResolutionException, ArtifactNotFoundException {
- Set artifacts = project.getArtifacts();
- for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
+ private void injectDependentServiceUnits() throws JbiPluginException,
+ ArtifactResolutionException, ArtifactNotFoundException {
+ Set artifacts = project.getArtifacts();
+ for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
- // TODO: utilise appropriate methods from project builder
- ScopeArtifactFilter filter = new ScopeArtifactFilter(
- Artifact.SCOPE_RUNTIME);
- if (!artifact.isOptional() && filter.include(artifact)
- && (artifact.getDependencyTrail().size() == 2)) {
- MavenProject project = null;
- try {
- project = projectBuilder.buildFromRepository(artifact,
- remoteRepos, localRepo);
- } catch (ProjectBuildingException e) {
- getLog().warn(
- "Unable to determine packaging for dependency : "
- + artifact.getArtifactId()
- + " assuming jar");
- }
- if ((project != null)
- && (project.getPackaging().equals("jbi-service-unit"))) {
- try {
+ // TODO: utilise appropriate methods from project builder
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
+ Artifact.SCOPE_RUNTIME);
+ if (!artifact.isOptional() && filter.include(artifact)
+ && (artifact.getDependencyTrail().size() == 2)) {
+ MavenProject project = null;
+ try {
+ project = projectBuilder.buildFromRepository(artifact,
+ remoteRepos, localRepo);
+ } catch (ProjectBuildingException e) {
+ getLog().warn(
+ "Unable to determine packaging for dependency : "
+ + artifact.getArtifactId()
+ + " assuming jar");
+ }
+ if ((project != null)
+ && (project.getPackaging().equals("jbi-service-unit"))) {
+ try {
String path = artifact.getFile().getAbsolutePath();
- path = path.substring(0, path.lastIndexOf('.')) + ".zip";
- FileUtils.copyFileToDirectory(new File(path),
- workDirectory);
- } catch (IOException e) {
- throw new JbiPluginException(e);
- }
- }
- }
- }
- }
+ path = path.substring(0, path.lastIndexOf('.'))
+ + ".zip";
+ FileUtils.copyFileToDirectory(new File(path),
+ workDirectory);
+ } catch (IOException e) {
+ throw new JbiPluginException(e);
+ }
+ }
+ }
+ }
+ }
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitDescriptorMojo.java Thu Jun 28 08:47:21 2007
@@ -46,221 +46,222 @@
*/
public class GenerateServiceUnitDescriptorMojo extends AbstractJbiMojo {
- public static final String UTF_8 = "UTF-8";
+ public static final String UTF_8 = "UTF-8";
- /**
- * Whether the jbi.xml should be generated or not.
- *
- * @parameter
- */
- private Boolean generateJbiDescriptor = Boolean.TRUE;
-
- /**
- * Determines whether to use the service unit analyzer
- *
- * @parameter
- */
- private Boolean useServiceUnitAnalyzer = Boolean.TRUE;
-
- /**
- * Fail if the descriptor generation fails
- *
- * @parameter
- */
- private Boolean failOnJbiDescriptorFailure = Boolean.FALSE;
-
- /**
- * Single directory for extra files to include in the JBI component.
- *
- * @parameter expression="${basedir}/src/main/resources/jbi-services.xml"
- * @required
- */
- private File jbiServicesFile;
-
- /**
- * The component name.
- *
- * @parameter expression="${project.artifactId}"
- */
- private String name;
-
- /**
- * The component description.
- *
- * @parameter expression="${project.name}"
- */
- private String description;
-
- /**
- * Character encoding for the auto-generated application.xml file.
- *
- * @parameter
- */
- private String encoding = UTF_8;
-
- /**
- * Directory where the application.xml file will be auto-generated.
- *
- * @parameter expression="${project.build.directory}/classes/META-INF"
- */
- private String generatedDescriptorLocation;
-
- /**
- * Directory where artifacts for the service unit are held
- *
- * @parameter expression="${basedir}/src/main/resources"
- */
- private File serviceUnitArtifactsDir;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- getLog().debug(
- " ======= GenerateServiceUnitDescriptorMojo settings =======");
- getLog().debug("workDirectory[" + workDirectory + "]");
- getLog().debug("generateDescriptor[" + generateJbiDescriptor + "]");
- getLog().debug("name[" + name + "]");
- getLog().debug("description[" + description + "]");
- getLog().debug("encoding[" + encoding + "]");
- getLog().debug(
- "generatedDescriptorLocation[" + generatedDescriptorLocation
- + "]");
-
- if (!generateJbiDescriptor.booleanValue()) {
- getLog().debug("Generation of jbi.xml is disabled");
- return;
- }
-
- // Generate jbi descriptor and copy it to the build directory
- getLog().info("Generating jbi.xml");
- try {
- generateJbiDescriptor();
- } catch (JbiPluginException e) {
- if (failOnJbiDescriptorFailure.booleanValue()) {
- throw new MojoExecutionException("Failed to generate jbi.xml", e);
- } else {
- getLog().warn("Failed to generate jbi.xml: " + e, e);
+ /**
+ * Whether the jbi.xml should be generated or not.
+ *
+ * @parameter
+ */
+ private Boolean generateJbiDescriptor = Boolean.TRUE;
+
+ /**
+ * Determines whether to use the service unit analyzer
+ *
+ * @parameter
+ */
+ private Boolean useServiceUnitAnalyzer = Boolean.TRUE;
+
+ /**
+ * Fail if the descriptor generation fails
+ *
+ * @parameter
+ */
+ private Boolean failOnJbiDescriptorFailure = Boolean.FALSE;
+
+ /**
+ * Single directory for extra files to include in the JBI component.
+ *
+ * @parameter expression="${basedir}/src/main/resources/jbi-services.xml"
+ * @required
+ */
+ private File jbiServicesFile;
+
+ /**
+ * The component name.
+ *
+ * @parameter expression="${project.artifactId}"
+ */
+ private String name;
+
+ /**
+ * The component description.
+ *
+ * @parameter expression="${project.name}"
+ */
+ private String description;
+
+ /**
+ * Character encoding for the auto-generated application.xml file.
+ *
+ * @parameter
+ */
+ private String encoding = UTF_8;
+
+ /**
+ * Directory where the application.xml file will be auto-generated.
+ *
+ * @parameter expression="${project.build.directory}/classes/META-INF"
+ */
+ private String generatedDescriptorLocation;
+
+ /**
+ * Directory where artifacts for the service unit are held
+ *
+ * @parameter expression="${basedir}/src/main/resources"
+ */
+ private File serviceUnitArtifactsDir;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ getLog().debug(
+ " ======= GenerateServiceUnitDescriptorMojo settings =======");
+ getLog().debug("workDirectory[" + workDirectory + "]");
+ getLog().debug("generateDescriptor[" + generateJbiDescriptor + "]");
+ getLog().debug("name[" + name + "]");
+ getLog().debug("description[" + description + "]");
+ getLog().debug("encoding[" + encoding + "]");
+ getLog().debug(
+ "generatedDescriptorLocation[" + generatedDescriptorLocation
+ + "]");
+
+ if (!generateJbiDescriptor.booleanValue()) {
+ getLog().debug("Generation of jbi.xml is disabled");
+ return;
+ }
+
+ // Generate jbi descriptor and copy it to the build directory
+ getLog().info("Generating jbi.xml");
+ try {
+ generateJbiDescriptor();
+ } catch (JbiPluginException e) {
+ if (failOnJbiDescriptorFailure.booleanValue()) {
+ throw new MojoExecutionException("Failed to generate jbi.xml",
+ e);
+ } else {
+ getLog().warn("Failed to generate jbi.xml: " + e, e);
+ }
+ }
+
+ }
+
+ /**
+ * Generates the deployment descriptor if necessary.
+ */
+ protected void generateJbiDescriptor() throws JbiPluginException {
+ File outputDir = new File(generatedDescriptorLocation);
+ if (!outputDir.exists()) {
+ outputDir.mkdirs();
+ }
+
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+
+ try {
+ URLClassLoader newClassLoader = getClassLoader();
+ Thread.currentThread().setContextClassLoader(newClassLoader);
+ File descriptor = new File(outputDir, JBI_DESCRIPTOR);
+ List uris = new ArrayList();
+ JbiServiceUnitDescriptorWriter writer = new JbiServiceUnitDescriptorWriter(
+ encoding);
+
+ List consumes = new ArrayList();
+ List provides = new ArrayList();
+
+ String serviceUnitAnalyzerClazzName = getServiceUnitAnalyzer();
+ // The ServiceUnitAnalyzer should give us the consumes and
+ // provides
+ if (serviceUnitAnalyzerClazzName != null) {
+ ServiceUnitAnalyzer serviceUnitAnalyzer = (ServiceUnitAnalyzer) newClassLoader
+ .loadClass(serviceUnitAnalyzerClazzName).newInstance();
+ getLog().info(
+ "Created Service Unit Analyzer " + serviceUnitAnalyzer);
+ serviceUnitAnalyzer.init(serviceUnitArtifactsDir);
+
+ // Need to determine whether we are using the dummy analyzer
+ // if so we need to give it the services file
+ if (serviceUnitAnalyzer instanceof JbiServiceFileAnalyzer) {
+ ((JbiServiceFileAnalyzer) serviceUnitAnalyzer)
+ .setJbiServicesFile(jbiServicesFile);
+ }
+ consumes.addAll(serviceUnitAnalyzer.getConsumes());
+ provides.addAll(serviceUnitAnalyzer.getProvides());
+ }
+
+ getLog().info(
+ "generated : consumes " + consumes + " provides "
+ + provides);
+
+ boolean bc = false;
+ // TODO: find if the component target is a BC ?
+ writer.write(descriptor, bc, name, description, uris, consumes,
+ provides);
+ } catch (Exception e) {
+ throw new JbiPluginException(
+ "Unable to generate service unit descriptor!", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ private String getServiceUnitAnalyzer() {
+ // We need to work out here whether we should use a dummy service unit
+ // analyzer that will examine a local services file or whether
+ // to look for the service unit analyzer from the component
+ if (jbiServicesFile.exists()) {
+ return JbiServiceFileAnalyzer.class.getCanonicalName();
+ }
+ if (useServiceUnitAnalyzer.booleanValue()) {
+ MavenProject project = getComponentProject();
+ if (project != null) {
+ List plugins = project.getBuild().getPlugins();
+ for (Iterator iterator = plugins.iterator(); iterator.hasNext();) {
+ Plugin plugin = (Plugin) iterator.next();
+ if ("org.apache.servicemix.tooling".equals(plugin
+ .getGroupId())
+ && "jbi-maven-plugin"
+ .equals(plugin.getArtifactId())) {
+ Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
+ if (o != null
+ && o.getChild("serviceUnitAnalyzer") != null) {
+ String clazzName = o
+ .getChild("serviceUnitAnalyzer").getValue();
+ return clazzName;
+ }
}
- }
-
- }
-
- /**
- * Generates the deployment descriptor if necessary.
- */
- protected void generateJbiDescriptor() throws JbiPluginException {
- File outputDir = new File(generatedDescriptorLocation);
- if (!outputDir.exists()) {
- outputDir.mkdirs();
- }
-
- ClassLoader old = Thread.currentThread().getContextClassLoader();
-
- try {
- URLClassLoader newClassLoader = getClassLoader();
- Thread.currentThread().setContextClassLoader(newClassLoader);
- File descriptor = new File(outputDir, JBI_DESCRIPTOR);
- List uris = new ArrayList();
- JbiServiceUnitDescriptorWriter writer = new JbiServiceUnitDescriptorWriter(
- encoding);
-
- List consumes = new ArrayList();
- List provides = new ArrayList();
-
- String serviceUnitAnalyzerClazzName = getServiceUnitAnalyzer();
- // The ServiceUnitAnalyzer should give us the consumes and
- // provides
- if (serviceUnitAnalyzerClazzName != null) {
- ServiceUnitAnalyzer serviceUnitAnalyzer = (ServiceUnitAnalyzer) newClassLoader
- .loadClass(serviceUnitAnalyzerClazzName).newInstance();
- getLog().info(
- "Created Service Unit Analyzer " + serviceUnitAnalyzer);
- serviceUnitAnalyzer.init(serviceUnitArtifactsDir);
-
- // Need to determine whether we are using the dummy analyzer
- // if so we need to give it the services file
- if (serviceUnitAnalyzer instanceof JbiServiceFileAnalyzer) {
- ((JbiServiceFileAnalyzer) serviceUnitAnalyzer)
- .setJbiServicesFile(jbiServicesFile);
- }
- consumes.addAll(serviceUnitAnalyzer.getConsumes());
- provides.addAll(serviceUnitAnalyzer.getProvides());
- }
-
- getLog().info(
- "generated : consumes " + consumes + " provides "
- + provides);
-
- boolean bc = false;
- // TODO: find if the component target is a BC ?
- writer.write(descriptor, bc, name, description, uris, consumes,
- provides);
- } catch (Exception e) {
- throw new JbiPluginException(
- "Unable to generate service unit descriptor!", e);
- } finally {
- Thread.currentThread().setContextClassLoader(old);
- }
- }
-
- private String getServiceUnitAnalyzer() {
- // We need to work out here whether we should use a dummy service unit
- // analyzer that will examine a local services file or whether
- // to look for the service unit analyzer from the component
- if (jbiServicesFile.exists()) {
- return JbiServiceFileAnalyzer.class.getCanonicalName();
- }
- if (useServiceUnitAnalyzer.booleanValue()) {
- MavenProject project = getComponentProject();
- if (project != null) {
- List plugins = project.getBuild().getPlugins();
- for (Iterator iterator = plugins.iterator(); iterator.hasNext();) {
- Plugin plugin = (Plugin) iterator.next();
- if ("org.apache.servicemix.tooling".equals(plugin
- .getGroupId())
- && "jbi-maven-plugin"
- .equals(plugin.getArtifactId())) {
- Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
- if (o != null
- && o.getChild("serviceUnitAnalyzer") != null) {
- String clazzName = o
- .getChild("serviceUnitAnalyzer").getValue();
- return clazzName;
- }
- }
- }
- }
- }
- return null;
- }
-
- private MavenProject getComponentProject() {
- Set artifacts = project.getArtifacts();
- for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
-
- // TODO: utilise appropriate methods from project builder
- ScopeArtifactFilter filter = new ScopeArtifactFilter(
- Artifact.SCOPE_RUNTIME);
- if (!artifact.isOptional() && filter.include(artifact)
- && (artifact.getDependencyTrail().size() == 2)) {
- MavenProject project = null;
- try {
- project = projectBuilder.buildFromRepository(artifact,
- remoteRepos, localRepo);
- } catch (ProjectBuildingException e) {
- getLog().warn(
- "Unable to determine packaging for dependency : "
- + artifact.getArtifactId()
- + " assuming jar");
- }
- if ((project != null)
- && (project.getPackaging().equals("jbi-component"))) {
- return project;
- }
-
- }
- }
- return null;
- }
+ }
+ }
+ }
+ return null;
+ }
+
+ private MavenProject getComponentProject() {
+ Set artifacts = project.getArtifacts();
+ for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
+
+ // TODO: utilise appropriate methods from project builder
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
+ Artifact.SCOPE_RUNTIME);
+ if (!artifact.isOptional() && filter.include(artifact)
+ && (artifact.getDependencyTrail().size() == 2)) {
+ MavenProject project = null;
+ try {
+ project = projectBuilder.buildFromRepository(artifact,
+ remoteRepos, localRepo);
+ } catch (ProjectBuildingException e) {
+ getLog().warn(
+ "Unable to determine packaging for dependency : "
+ + artifact.getArtifactId()
+ + " assuming jar");
+ }
+ if ((project != null)
+ && (project.getPackaging().equals("jbi-component"))) {
+ return project;
+ }
+
+ }
+ }
+ return null;
+ }
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceUnitMojo.java Thu Jun 28 08:47:21 2007
@@ -49,153 +49,150 @@
*/
public class GenerateServiceUnitMojo extends AbstractJbiMojo {
- /**
- * The name of the generated war.
- *
- * @parameter expression="${project.artifactId}-${project.version}.zip"
- * @required
- */
- private String serviceUnitName;
-
- /**
- * The directory for the generated JBI component.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private File outputDirectory;
-
- /**
- * The Zip archiver.
- *
- * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
- * @required
- */
- private JarArchiver jarArchiver;
-
- /**
- * The maven archive configuration to use.
- *
- * @parameter
- */
- private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
-
- /**
- * Directory where the application.xml file will be auto-generated.
- *
- * @parameter expression="${project.build.directory}/classes"
- */
- private File serviceUnitLocation;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
-
- createUnpackedInstaller();
-
- File serviceUnitFile = new File(outputDirectory, serviceUnitName);
- createArchive(serviceUnitFile);
-
- projectHelper.attachArtifact(project, "zip", "", new File(
- outputDirectory, serviceUnitName));
-
- } catch (JbiPluginException e) {
- throw new MojoExecutionException("Failed to create service unit", e);
- }
-
- }
-
- private void createArchive(File installerFile) throws JbiPluginException {
- try {
-
- // generate war file
- getLog().info(
- "Generating service unit "
- + installerFile.getAbsolutePath());
- MavenArchiver archiver = new MavenArchiver();
- archiver.setArchiver(jarArchiver);
- archiver.setOutputFile(installerFile);
- jarArchiver.addDirectory(workDirectory);
-
- // create archive
- archiver.createArchive(getProject(), archive);
-
- } catch (ArchiverException e) {
- throw new JbiPluginException("Error creating service unit: "
- + e.getMessage(), e);
- } catch (ManifestException e) {
- throw new JbiPluginException("Error creating service unit: "
- + e.getMessage(), e);
- } catch (IOException e) {
- throw new JbiPluginException("Error creating service unit: "
- + e.getMessage(), e);
- } catch (DependencyResolutionRequiredException e) {
- throw new JbiPluginException("Error creating service unit: "
- + e.getMessage(), e);
- }
-
- }
-
- private void createUnpackedInstaller() throws JbiPluginException {
-
- if (!workDirectory.isDirectory()) {
- if (!workDirectory.mkdirs()) {
- throw new JbiPluginException(
- "Unable to create work directory: " + workDirectory);
- }
- }
-
- try {
- FileUtils.copyDirectoryStructure(serviceUnitLocation, workDirectory);
- } catch (IOException e) {
- throw new JbiPluginException("Unable to copy directory "
- + serviceUnitLocation, e);
- }
-
- ScopeArtifactFilter filter = new ScopeArtifactFilter(
- Artifact.SCOPE_RUNTIME);
-
- JbiResolutionListener listener = resolveProject();
- // print(listener.getRootNode(), "");
-
- Set includes = new HashSet();
- for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
- if (!artifact.isOptional() && filter.include(artifact)) {
- MavenProject project = null;
- getLog().info("Resolving "+artifact);
- try {
- project = projectBuilder.buildFromRepository(artifact,
- remoteRepos, localRepo);
- } catch (ProjectBuildingException e) {
- getLog().warn(
- "Unable to determine packaging for dependency : "
- + artifact.getArtifactId()
- + " assuming jar");
- }
- String type = project != null ? project.getPackaging()
- : artifact.getType();
- if ("jbi-component".equals(type)) {
- removeBranch(listener, artifact);
- } else if ("jbi-shared-library".equals(type)) {
- removeBranch(listener, artifact);
- } else {
- includes.add(artifact);
- }
- }
- }
- // print(listener.getRootNode(), "");
-
- for (Iterator iter = retainArtifacts(includes, listener).iterator(); iter
- .hasNext();) {
- Artifact artifact = (Artifact) iter.next();
- try {
- getLog().info("Including: " + artifact);
- FileUtils.copyFileToDirectory(artifact.getFile(), new File(
- workDirectory, LIB_DIRECTORY));
- } catch (IOException e) {
- throw new JbiPluginException("Unable to copy file "
- + artifact.getFile(), e);
- }
- }
- }
+ /**
+ * The name of the generated war.
+ *
+ * @parameter expression="${project.artifactId}-${project.version}.zip"
+ * @required
+ */
+ private String serviceUnitName;
+
+ /**
+ * The directory for the generated JBI component.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private File outputDirectory;
+
+ /**
+ * The Zip archiver.
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
+ * @required
+ */
+ private JarArchiver jarArchiver;
+
+ /**
+ * The maven archive configuration to use.
+ *
+ * @parameter
+ */
+ private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+ /**
+ * Directory where the application.xml file will be auto-generated.
+ *
+ * @parameter expression="${project.build.directory}/classes"
+ */
+ private File serviceUnitLocation;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+
+ createUnpackedInstaller();
+
+ File serviceUnitFile = new File(outputDirectory, serviceUnitName);
+ createArchive(serviceUnitFile);
+
+ projectHelper.attachArtifact(project, "zip", "", new File(
+ outputDirectory, serviceUnitName));
+
+ } catch (JbiPluginException e) {
+ throw new MojoExecutionException("Failed to create service unit", e);
+ }
+
+ }
+
+ private void createArchive(File installerFile) throws JbiPluginException {
+ try {
+
+ // generate war file
+ getLog().info(
+ "Generating service unit "
+ + installerFile.getAbsolutePath());
+ MavenArchiver archiver = new MavenArchiver();
+ archiver.setArchiver(jarArchiver);
+ archiver.setOutputFile(installerFile);
+ jarArchiver.addDirectory(workDirectory);
+
+ // create archive
+ archiver.createArchive(getProject(), archive);
+
+ } catch (ArchiverException e) {
+ throw new JbiPluginException("Error creating service unit: "
+ + e.getMessage(), e);
+ } catch (ManifestException e) {
+ throw new JbiPluginException("Error creating service unit: "
+ + e.getMessage(), e);
+ } catch (IOException e) {
+ throw new JbiPluginException("Error creating service unit: "
+ + e.getMessage(), e);
+ } catch (DependencyResolutionRequiredException e) {
+ throw new JbiPluginException("Error creating service unit: "
+ + e.getMessage(), e);
+ }
+
+ }
+
+ private void createUnpackedInstaller() throws JbiPluginException {
+
+ if (!workDirectory.isDirectory() && !workDirectory.mkdirs()) {
+ throw new JbiPluginException("Unable to create work directory: " + workDirectory);
+ }
+
+ try {
+ FileUtils.copyDirectoryStructure(serviceUnitLocation, workDirectory);
+ } catch (IOException e) {
+ throw new JbiPluginException("Unable to copy directory "
+ + serviceUnitLocation, e);
+ }
+
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
+ Artifact.SCOPE_RUNTIME);
+
+ JbiResolutionListener listener = resolveProject();
+ // print(listener.getRootNode(), "");
+
+ Set includes = new HashSet();
+ for (Iterator iter = project.getArtifacts().iterator(); iter.hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
+ if (!artifact.isOptional() && filter.include(artifact)) {
+ MavenProject project = null;
+ getLog().info("Resolving " + artifact);
+ try {
+ project = projectBuilder.buildFromRepository(artifact,
+ remoteRepos, localRepo);
+ } catch (ProjectBuildingException e) {
+ getLog().warn(
+ "Unable to determine packaging for dependency : "
+ + artifact.getArtifactId()
+ + " assuming jar");
+ }
+ String type = project != null ? project.getPackaging()
+ : artifact.getType();
+ if ("jbi-component".equals(type)) {
+ removeBranch(listener, artifact);
+ } else if ("jbi-shared-library".equals(type)) {
+ removeBranch(listener, artifact);
+ } else {
+ includes.add(artifact);
+ }
+ }
+ }
+ // print(listener.getRootNode(), "");
+
+ for (Iterator iter = retainArtifacts(includes, listener).iterator(); iter
+ .hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
+ try {
+ getLog().info("Including: " + artifact);
+ FileUtils.copyFileToDirectory(artifact.getFile(), new File(
+ workDirectory, LIB_DIRECTORY));
+ } catch (IOException e) {
+ throw new JbiPluginException("Unable to copy file "
+ + artifact.getFile(), e);
+ }
+ }
+ }
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryDescriptorMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryDescriptorMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryDescriptorMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryDescriptorMojo.java Thu Jun 28 08:47:21 2007
@@ -42,133 +42,136 @@
*/
public class GenerateSharedLibraryDescriptorMojo extends AbstractJbiMojo {
- public static final String UTF_8 = "UTF-8";
+ public static final String UTF_8 = "UTF-8";
- /**
- * Whether the jbi.xml should be generated or not.
- *
- * @parameter
- */
- private Boolean generateJbiDescriptor = Boolean.TRUE;
-
- /**
- * The shared library name.
- *
- * @parameter expression="${project.artifactId}"
- */
- private String name;
-
- /**
- * The shared library description.
- *
- * @parameter expression="${project.name}"
- */
- private String description;
-
- /**
- * The shared library version.
- *
- * @parameter expression="${project.version}"
- */
- private String version;
-
- /**
- * The shared library class loader delegation
- *
- * @parameter expression="parent-first"
- */
- private String classLoaderDelegation;
-
- /**
- * Character encoding for the auto-generated application.xml file.
- *
- * @parameter
- */
- private String encoding = UTF_8;
-
- /**
- * Directory where the application.xml file will be auto-generated.
- *
- * @parameter expression="${project.build.directory}"
- */
- private String generatedDescriptorLocation;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- getLog()
- .debug(
- " ======= GenerateSharedLibraryDescriptorMojo settings =======");
- getLog().debug("workDirectory[" + workDirectory + "]");
- getLog().debug("generateJbiDescriptor[" + generateJbiDescriptor + "]");
- getLog().debug("name[" + name + "]");
- getLog().debug("description[" + description + "]");
- getLog().debug("encoding[" + encoding + "]");
- getLog().debug("generatedDescriptorLocation[" + generatedDescriptorLocation + "]");
- getLog().debug("version[" + version + "]");
-
- if (!generateJbiDescriptor.booleanValue()) {
- getLog().debug("Generation of jbi.xml is disabled");
- return;
- }
-
- // Generate jbi descriptor and copy it to the build directory
- getLog().info("Generating jbi.xml");
- try {
- generateJbiDescriptor();
- } catch (JbiPluginException e) {
- throw new MojoExecutionException("Failed to generate jbi.xml", e);
- }
-
- try {
- FileUtils.copyFileToDirectory(new File(generatedDescriptorLocation,
- JBI_DESCRIPTOR), new File(getWorkDirectory(), META_INF));
- } catch (IOException e) {
- throw new MojoExecutionException(
- "Unable to copy jbi.xml to final destination", e);
- }
- }
-
- /**
- * Generates the deployment descriptor if necessary.
- */
- protected void generateJbiDescriptor() throws JbiPluginException {
- File outputDir = new File(generatedDescriptorLocation);
- if (!outputDir.exists()) {
- outputDir.mkdirs();
- }
-
- File descriptor = new File(outputDir, JBI_DESCRIPTOR);
-
- List embeddedLibraries = new ArrayList();
-
- DependencyInformation info = new DependencyInformation();
- info.setFilename(LIB_DIRECTORY + "/" + project.getArtifactId() + "-"
- + project.getVersion() + ".jar");
- info.setVersion(project.getVersion());
- info.setName(project.getArtifactId());
- info.setType("jar");
- embeddedLibraries.add(info);
-
- Set artifacts = project.getArtifacts();
- for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
-
- // TODO: utilise appropriate methods from project builder
- ScopeArtifactFilter filter = new ScopeArtifactFilter(
- Artifact.SCOPE_RUNTIME);
- if (!artifact.isOptional() && filter.include(artifact)) {
- String type = artifact.getType();
- if ("jar".equals(type)) {
- info = new DependencyInformation();
- info.setFilename(LIB_DIRECTORY + "/" + artifact.getFile().getName());
- embeddedLibraries.add(info);
- }
- }
- }
-
- JbiSharedLibraryDescriptorWriter writer = new JbiSharedLibraryDescriptorWriter(
- encoding);
- writer.write(descriptor, name, description, version,
- classLoaderDelegation, embeddedLibraries);
- }
+ /**
+ * Whether the jbi.xml should be generated or not.
+ *
+ * @parameter
+ */
+ private Boolean generateJbiDescriptor = Boolean.TRUE;
+
+ /**
+ * The shared library name.
+ *
+ * @parameter expression="${project.artifactId}"
+ */
+ private String name;
+
+ /**
+ * The shared library description.
+ *
+ * @parameter expression="${project.name}"
+ */
+ private String description;
+
+ /**
+ * The shared library version.
+ *
+ * @parameter expression="${project.version}"
+ */
+ private String version;
+
+ /**
+ * The shared library class loader delegation
+ *
+ * @parameter expression="parent-first"
+ */
+ private String classLoaderDelegation;
+
+ /**
+ * Character encoding for the auto-generated application.xml file.
+ *
+ * @parameter
+ */
+ private String encoding = UTF_8;
+
+ /**
+ * Directory where the application.xml file will be auto-generated.
+ *
+ * @parameter expression="${project.build.directory}"
+ */
+ private String generatedDescriptorLocation;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ getLog()
+ .debug(
+ " ======= GenerateSharedLibraryDescriptorMojo settings =======");
+ getLog().debug("workDirectory[" + workDirectory + "]");
+ getLog().debug("generateJbiDescriptor[" + generateJbiDescriptor + "]");
+ getLog().debug("name[" + name + "]");
+ getLog().debug("description[" + description + "]");
+ getLog().debug("encoding[" + encoding + "]");
+ getLog().debug(
+ "generatedDescriptorLocation[" + generatedDescriptorLocation
+ + "]");
+ getLog().debug("version[" + version + "]");
+
+ if (!generateJbiDescriptor.booleanValue()) {
+ getLog().debug("Generation of jbi.xml is disabled");
+ return;
+ }
+
+ // Generate jbi descriptor and copy it to the build directory
+ getLog().info("Generating jbi.xml");
+ try {
+ generateJbiDescriptor();
+ } catch (JbiPluginException e) {
+ throw new MojoExecutionException("Failed to generate jbi.xml", e);
+ }
+
+ try {
+ FileUtils.copyFileToDirectory(new File(generatedDescriptorLocation,
+ JBI_DESCRIPTOR), new File(getWorkDirectory(), META_INF));
+ } catch (IOException e) {
+ throw new MojoExecutionException(
+ "Unable to copy jbi.xml to final destination", e);
+ }
+ }
+
+ /**
+ * Generates the deployment descriptor if necessary.
+ */
+ protected void generateJbiDescriptor() throws JbiPluginException {
+ File outputDir = new File(generatedDescriptorLocation);
+ if (!outputDir.exists()) {
+ outputDir.mkdirs();
+ }
+
+ File descriptor = new File(outputDir, JBI_DESCRIPTOR);
+
+ List embeddedLibraries = new ArrayList();
+
+ DependencyInformation info = new DependencyInformation();
+ info.setFilename(LIB_DIRECTORY + "/" + project.getArtifactId() + "-"
+ + project.getVersion() + ".jar");
+ info.setVersion(project.getVersion());
+ info.setName(project.getArtifactId());
+ info.setType("jar");
+ embeddedLibraries.add(info);
+
+ Set artifacts = project.getArtifacts();
+ for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
+
+ // TODO: utilise appropriate methods from project builder
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
+ Artifact.SCOPE_RUNTIME);
+ if (!artifact.isOptional() && filter.include(artifact)) {
+ String type = artifact.getType();
+ if ("jar".equals(type)) {
+ info = new DependencyInformation();
+ info.setFilename(LIB_DIRECTORY + "/"
+ + artifact.getFile().getName());
+ embeddedLibraries.add(info);
+ }
+ }
+ }
+
+ JbiSharedLibraryDescriptorWriter writer = new JbiSharedLibraryDescriptorWriter(
+ encoding);
+ writer.write(descriptor, name, description, version,
+ classLoaderDelegation, embeddedLibraries);
+ }
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java Thu Jun 28 08:47:21 2007
@@ -44,144 +44,141 @@
*/
public class GenerateSharedLibraryMojo extends AbstractJbiMojo {
- /**
- * The directory for the generated JBI component.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private File outputDirectory;
-
- /**
- * The name of the generated war.
- *
- * @parameter expression="${project.artifactId}-${project.version}.zip"
- * @required
- */
- private String sharedLibraryName;
-
- /**
- * The name of the generated war.
- *
- * @parameter expression="${project.artifactId}-${project.version}.jar"
- * @required
- */
- private String jarName;
-
- /**
- * The Zip archiver.
- *
- * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
- * @required
- */
- private JarArchiver jarArchiver;
-
- /**
- * Single directory for extra files to include in the JBI component.
- *
- * @parameter expression="${basedir}/src/main/jbi"
- * @required
- */
- private File jbiSourceDirectory;
-
- /**
- * The maven archive configuration to use.
- *
- * @parameter
- */
- private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- getLog().debug(" ======= GenerateInstallerMojo settings =======");
- getLog().debug("workDirectory[" + workDirectory + "]");
- getLog().debug("installerName[" + sharedLibraryName + "]");
- getLog().debug("jbiSourceDirectory[" + jbiSourceDirectory + "]");
-
- try {
-
- createUnpackedSharedLibrary();
-
- File installerFile = new File(outputDirectory, sharedLibraryName);
- createArchive(installerFile);
-
- projectHelper.attachArtifact(project,"jar", "", new File(
- outputDirectory, jarName));
-
- projectHelper.attachArtifact(project,"zip", "installer", new File(
- outputDirectory, sharedLibraryName));
-
- } catch (JbiPluginException e) {
- throw new MojoExecutionException("Failed to create shared library",
- e);
- }
- }
-
- private void createArchive(File installerFile) throws JbiPluginException {
- try {
-
- // generate war file
- getLog().info(
- "Generating shared library "
- + installerFile.getAbsolutePath());
- MavenArchiver archiver = new MavenArchiver();
- archiver.setArchiver(jarArchiver);
- archiver.setOutputFile(installerFile);
- jarArchiver.addDirectory(workDirectory);
- if (jbiSourceDirectory.isDirectory()) {
- jarArchiver.addDirectory(jbiSourceDirectory, null,
- DirectoryScanner.DEFAULTEXCLUDES);
- }
- // create archive
- archiver.createArchive(getProject(), archive);
-
- } catch (Exception e) {
- throw new JbiPluginException("Error creating shared library: "
- + e.getMessage(), e);
- }
- }
-
- private void createUnpackedSharedLibrary() throws JbiPluginException {
-
- if (!workDirectory.isDirectory()) {
- if (!workDirectory.mkdirs()) {
- throw new JbiPluginException(
- "Unable to create work directory: " + workDirectory);
- }
- }
-
- File projectArtifact = new File(outputDirectory, project
- .getArtifactId()
- + "-" + project.getVersion() + ".jar");
- try {
- FileUtils.copyFileToDirectory(projectArtifact, new File(
- workDirectory, LIB_DIRECTORY));
-
- } catch (IOException e) {
- throw new JbiPluginException("Unable to copy file "
- + projectArtifact, e);
- }
-
- Set artifacts = project.getArtifacts();
- for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
- Artifact artifact = (Artifact) iter.next();
-
- // TODO: utilise appropriate methods from project builder
- ScopeArtifactFilter filter = new ScopeArtifactFilter(
- Artifact.SCOPE_RUNTIME);
- if (!artifact.isOptional() && filter.include(artifact)) {
- String type = artifact.getType();
- if ("jar".equals(type)) {
- try {
- FileUtils.copyFileToDirectory(artifact.getFile(),
- new File(workDirectory, LIB_DIRECTORY));
- } catch (IOException e) {
- throw new JbiPluginException("Unable to copy file "
- + artifact.getFile(), e);
- }
- }
- }
- }
- }
+ /**
+ * The directory for the generated JBI component.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private File outputDirectory;
+
+ /**
+ * The name of the generated war.
+ *
+ * @parameter expression="${project.artifactId}-${project.version}.zip"
+ * @required
+ */
+ private String sharedLibraryName;
+
+ /**
+ * The name of the generated war.
+ *
+ * @parameter expression="${project.artifactId}-${project.version}.jar"
+ * @required
+ */
+ private String jarName;
+
+ /**
+ * The Zip archiver.
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
+ * @required
+ */
+ private JarArchiver jarArchiver;
+
+ /**
+ * Single directory for extra files to include in the JBI component.
+ *
+ * @parameter expression="${basedir}/src/main/jbi"
+ * @required
+ */
+ private File jbiSourceDirectory;
+
+ /**
+ * The maven archive configuration to use.
+ *
+ * @parameter
+ */
+ private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ getLog().debug(" ======= GenerateInstallerMojo settings =======");
+ getLog().debug("workDirectory[" + workDirectory + "]");
+ getLog().debug("installerName[" + sharedLibraryName + "]");
+ getLog().debug("jbiSourceDirectory[" + jbiSourceDirectory + "]");
+
+ try {
+
+ createUnpackedSharedLibrary();
+
+ File installerFile = new File(outputDirectory, sharedLibraryName);
+ createArchive(installerFile);
+
+ projectHelper.attachArtifact(project, "jar", "", new File(
+ outputDirectory, jarName));
+
+ projectHelper.attachArtifact(project, "zip", "installer", new File(
+ outputDirectory, sharedLibraryName));
+
+ } catch (JbiPluginException e) {
+ throw new MojoExecutionException("Failed to create shared library",
+ e);
+ }
+ }
+
+ private void createArchive(File installerFile) throws JbiPluginException {
+ try {
+
+ // generate war file
+ getLog().info(
+ "Generating shared library "
+ + installerFile.getAbsolutePath());
+ MavenArchiver archiver = new MavenArchiver();
+ archiver.setArchiver(jarArchiver);
+ archiver.setOutputFile(installerFile);
+ jarArchiver.addDirectory(workDirectory);
+ if (jbiSourceDirectory.isDirectory()) {
+ jarArchiver.addDirectory(jbiSourceDirectory, null,
+ DirectoryScanner.DEFAULTEXCLUDES);
+ }
+ // create archive
+ archiver.createArchive(getProject(), archive);
+
+ } catch (Exception e) {
+ throw new JbiPluginException("Error creating shared library: "
+ + e.getMessage(), e);
+ }
+ }
+
+ private void createUnpackedSharedLibrary() throws JbiPluginException {
+
+ if (!workDirectory.isDirectory() && !workDirectory.mkdirs()) {
+ throw new JbiPluginException("Unable to create work directory: " + workDirectory);
+ }
+
+ File projectArtifact = new File(outputDirectory, project
+ .getArtifactId()
+ + "-" + project.getVersion() + ".jar");
+ try {
+ FileUtils.copyFileToDirectory(projectArtifact, new File(
+ workDirectory, LIB_DIRECTORY));
+
+ } catch (IOException e) {
+ throw new JbiPluginException("Unable to copy file "
+ + projectArtifact, e);
+ }
+
+ Set artifacts = project.getArtifacts();
+ for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
+ Artifact artifact = (Artifact) iter.next();
+
+ // TODO: utilise appropriate methods from project builder
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
+ Artifact.SCOPE_RUNTIME);
+ if (!artifact.isOptional() && filter.include(artifact)) {
+ String type = artifact.getType();
+ if ("jar".equals(type)) {
+ try {
+ FileUtils.copyFileToDirectory(artifact.getFile(),
+ new File(workDirectory, LIB_DIRECTORY));
+ } catch (IOException e) {
+ throw new JbiPluginException("Unable to copy file "
+ + artifact.getFile(), e);
+ }
+ }
+ }
+ }
+ }
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GraphArtifactCollector.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GraphArtifactCollector.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GraphArtifactCollector.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GraphArtifactCollector.java Thu Jun 28 08:47:21 2007
@@ -41,380 +41,382 @@
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange;
-public class GraphArtifactCollector
- implements ArtifactCollector
-{
- public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact,
- ArtifactRepository localRepository, List remoteRepositories,
- ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
- throws ArtifactResolutionException
- {
- return collect( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories,
- source, filter, listeners );
+public class GraphArtifactCollector implements ArtifactCollector {
+
+ public ArtifactResolutionResult collect(
+ Set artifacts,
+ Artifact originatingArtifact,
+ ArtifactRepository localRepository,
+ List remoteRepositories,
+ ArtifactMetadataSource source,
+ ArtifactFilter filter,
+ List listeners) throws ArtifactResolutionException {
+ return collect(artifacts, originatingArtifact, Collections.EMPTY_MAP,
+ localRepository, remoteRepositories, source, filter, listeners);
}
- public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
- ArtifactRepository localRepository, List remoteRepositories,
- ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
- throws ArtifactResolutionException
- {
+ public ArtifactResolutionResult collect(
+ Set artifacts,
+ Artifact originatingArtifact,
+ Map managedVersions,
+ ArtifactRepository localRepository,
+ List remoteRepositories,
+ ArtifactMetadataSource source,
+ ArtifactFilter filter,
+ List listeners) throws ArtifactResolutionException {
Map resolvedArtifacts = new HashMap();
- ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
-
- root.addDependencies( artifacts, remoteRepositories, filter );
-
- recurse( root, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter,
- listeners );
+ ResolutionNode root = new ResolutionNode(originatingArtifact, remoteRepositories);
+ root.addDependencies(artifacts, remoteRepositories, filter);
+ recurse(root, resolvedArtifacts, managedVersions, localRepository,
+ remoteRepositories, source, filter, listeners);
Set set = new HashSet();
-
- for ( Iterator i = resolvedArtifacts.values().iterator(); i.hasNext(); )
- {
+ for (Iterator i = resolvedArtifacts.values().iterator(); i.hasNext();) {
List nodes = (List) i.next();
- for ( Iterator j = nodes.iterator(); j.hasNext(); )
- {
+ for (Iterator j = nodes.iterator(); j.hasNext();) {
ResolutionNode node = (ResolutionNode) j.next();
- if ( !node.equals( root ) && node.isActive() )
- {
- Artifact artifact = node.getArtifact();
-
- if ( node.filterTrail( filter ) )
- {
- // If it was optional and not a direct dependency,
- // we don't add it or its children, just allow the update of the version and scope
- if ( node.isChildOfRootNode() || !artifact.isOptional() )
- {
- artifact.setDependencyTrail( node.getDependencyTrail() );
-
- set.add( node );
- }
- }
+ Artifact artifact = node.getArtifact();
+ if (!node.equals(root) && node.isActive() && node.filterTrail(filter)
+ // If it was optional and not a direct dependency,
+ // we don't add it or its children, just allow the
+ // update of the version and scope
+ && (node.isChildOfRootNode() || !artifact.isOptional())) {
+ artifact.setDependencyTrail(node.getDependencyTrail());
+ set.add(node);
}
}
}
ArtifactResolutionResult result = new ArtifactResolutionResult();
- result.setArtifactResolutionNodes( set );
+ result.setArtifactResolutionNodes(set);
return result;
}
- private void recurse( ResolutionNode node, Map resolvedArtifacts, Map managedVersions,
- ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source,
- ArtifactFilter filter, List listeners )
- throws CyclicDependencyException, ArtifactResolutionException, OverConstrainedVersionException
- {
- fireEvent( ResolutionListener.TEST_ARTIFACT, listeners, node );
+ private void recurse(
+ ResolutionNode node,
+ Map resolvedArtifacts,
+ Map managedVersions,
+ ArtifactRepository localRepository,
+ List remoteRepositories,
+ ArtifactMetadataSource source,
+ ArtifactFilter filter,
+ List listeners) throws CyclicDependencyException, ArtifactResolutionException,
+ OverConstrainedVersionException {
+ fireEvent(ResolutionListener.TEST_ARTIFACT, listeners, node);
// TODO: use as a conflict resolver
Object key = node.getKey();
- if ( managedVersions.containsKey( key ) )
- {
- Artifact artifact = (Artifact) managedVersions.get( key );
-
- fireEvent( ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact );
-
- if ( artifact.getVersion() != null )
- {
- node.getArtifact().setVersion( artifact.getVersion() );
+ if (managedVersions.containsKey(key)) {
+ Artifact artifact = (Artifact) managedVersions.get(key);
+ fireEvent(ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact);
+ if (artifact.getVersion() != null) {
+ node.getArtifact().setVersion(artifact.getVersion());
}
- if ( artifact.getScope() != null )
- {
- node.getArtifact().setScope( artifact.getScope() );
+ if (artifact.getScope() != null) {
+ node.getArtifact().setScope(artifact.getScope());
}
}
- List previousNodes = (List) resolvedArtifacts.get( key );
- if ( previousNodes != null )
- {
- for ( Iterator i = previousNodes.iterator(); i.hasNext(); )
- {
- ResolutionNode previous = (ResolutionNode) i.next();
-
- if ( previous.isActive() )
- {
- // Version mediation
- VersionRange previousRange = previous.getArtifact().getVersionRange();
- VersionRange currentRange = node.getArtifact().getVersionRange();
-
- // TODO: why do we force the version on it? what if they don't match?
- if ( previousRange == null )
- {
- // version was already resolved
- node.getArtifact().setVersion( previous.getArtifact().getVersion() );
- }
- else if ( currentRange == null )
- {
- // version was already resolved
- previous.getArtifact().setVersion( node.getArtifact().getVersion() );
- }
- else
- {
- // TODO: shouldn't need to double up on this work, only done for simplicity of handling recommended
- // version but the restriction is identical
- VersionRange newRange = previousRange.restrict( currentRange );
- // TODO: ick. this forces the OCE that should have come from the previous call. It is still correct
- if ( newRange.isSelectedVersionKnown( previous.getArtifact() ) )
- {
- fireEvent( ResolutionListener.RESTRICT_RANGE, listeners, node, previous.getArtifact(),
- newRange );
- }
- previous.getArtifact().setVersionRange( newRange );
- node.getArtifact().setVersionRange( currentRange.restrict( previousRange ) );
-
- //Select an appropriate available version from the (now restricted) range
- //Note this version was selected before to get the appropriate POM
- //But it was reset by the call to setVersionRange on restricting the version
- ResolutionNode[] resetNodes = {previous, node};
- for ( int j = 0; j < 2; j++ )
- {
- Artifact resetArtifact = resetNodes[j].getArtifact();
- if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange() != null &&
- resetArtifact.getAvailableVersions() != null )
- {
-
- resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion(
- resetArtifact.getAvailableVersions() ).toString() );
- fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, resetNodes[j] );
- }
- }
- }
-
- // Conflict Resolution
- // TODO: use as conflict resolver(s), chain
-
- // TODO: should this be part of mediation?
- // previous one is more dominant
- if ( previous.getDepth() <= node.getDepth() )
- {
- checkScopeUpdate( node, previous, listeners );
- }
- else
- {
- checkScopeUpdate( previous, node, listeners );
- }
-
- if ( previous.getDepth() <= node.getDepth() )
- {
- // previous was nearer
- fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, node, previous.getArtifact() );
- node.disable();
- node = previous;
- }
- else
- {
- fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, previous, node.getArtifact() );
- previous.disable();
- }
- }
- }
- }
- else
- {
+ List previousNodes = (List) resolvedArtifacts.get(key);
+ if (previousNodes != null) {
+ node = checkPreviousNodes(node, listeners, previousNodes);
+ } else {
previousNodes = new ArrayList();
- resolvedArtifacts.put( key, previousNodes );
+ resolvedArtifacts.put(key, previousNodes);
}
- previousNodes.add( node );
+ previousNodes.add(node);
- if ( node.isActive() )
- {
- fireEvent( ResolutionListener.INCLUDE_ARTIFACT, listeners, node );
+ if (node.isActive()) {
+ fireEvent(ResolutionListener.INCLUDE_ARTIFACT, listeners, node);
}
// don't pull in the transitive deps of a system-scoped dependency.
- if ( node.isActive() && !Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) )
- {
- fireEvent( ResolutionListener.PROCESS_CHILDREN, listeners, node );
-
- for ( Iterator i = node.getChildrenIterator(); i.hasNext(); )
- {
+ if (node.isActive() && !Artifact.SCOPE_SYSTEM.equals(node.getArtifact().getScope())) {
+ fireEvent(ResolutionListener.PROCESS_CHILDREN, listeners, node);
+ for (Iterator i = node.getChildrenIterator(); i.hasNext();) {
ResolutionNode child = (ResolutionNode) i.next();
// We leave in optional ones, but don't pick up its dependencies
- if ( !child.isResolved() && ( !child.getArtifact().isOptional() || child.isChildOfRootNode() ) )
- {
+ if (!child.isResolved()
+ && (!child.getArtifact().isOptional() || child.isChildOfRootNode())) {
Artifact artifact = child.getArtifact();
- try
- {
- if ( artifact.getVersion() == null )
- {
+ try {
+ if (artifact.getVersion() == null) {
// set the recommended version
- // TODO: maybe its better to just pass the range through to retrieval and use a transformation?
+ // TODO: maybe its better to just pass the range
+ // through to retrieval and use a transformation?
ArtifactVersion version;
- if ( !artifact.isSelectedVersionKnown() )
- {
- List versions = artifact.getAvailableVersions();
- if ( versions == null )
- {
- versions = source.retrieveAvailableVersions( artifact, localRepository,
- remoteRepositories );
- artifact.setAvailableVersions( versions );
- }
-
- VersionRange versionRange = artifact.getVersionRange();
-
- version = versionRange.matchVersion( versions );
-
- if ( version == null )
- {
- if ( versions.isEmpty() )
- {
- throw new OverConstrainedVersionException(
- "No versions are present in the repository for the artifact with a range " +
- versionRange, artifact, remoteRepositories );
- }
- else
- {
- throw new OverConstrainedVersionException( "Couldn't find a version in " +
- versions + " to match range " + versionRange, artifact,
- remoteRepositories );
- }
- }
- }
- else
- {
- version = artifact.getSelectedVersion();
- }
+ version = getArtifactVersion(localRepository, remoteRepositories, source, artifact);
- artifact.selectVersion( version.toString() );
- fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child );
+ artifact.selectVersion(version.toString());
+ fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
+ listeners, child);
}
- ResolutionGroup rGroup = source.retrieve( artifact, localRepository, remoteRepositories );
+ ResolutionGroup rGroup = source.retrieve(artifact,
+ localRepository, remoteRepositories);
- //TODO might be better to have source.retreive() throw a specific exception for this situation
- //and catch here rather than have it return null
- if ( rGroup == null )
- {
- //relocated dependency artifact is declared excluded, no need to add and recurse further
+ // TODO might be better to have source.retreive() throw
+ // a specific exception for this situation
+ // and catch here rather than have it return null
+ if (rGroup == null) {
+ // relocated dependency artifact is declared
+ // excluded, no need to add and recurse further
continue;
}
- child.addDependencies( rGroup.getArtifacts(), rGroup.getResolutionRepositories(), filter );
- }
- catch ( CyclicDependencyException e )
- {
- // would like to throw this, but we have crappy stuff in the repo
-
- fireEvent( ResolutionListener.OMIT_FOR_CYCLE, listeners,
- new ResolutionNode( e.getArtifact(), remoteRepositories, child ) );
- }
- catch ( ArtifactMetadataRetrievalException e )
- {
- artifact.setDependencyTrail( node.getDependencyTrail() );
+ child.addDependencies(rGroup.getArtifacts(),
+ rGroup.getResolutionRepositories(), filter);
+ } catch (CyclicDependencyException e) {
+ // would like to throw this, but we have crappy stuff in
+ // the repo
+
+ fireEvent(ResolutionListener.OMIT_FOR_CYCLE, listeners,
+ new ResolutionNode(e.getArtifact(), remoteRepositories, child));
+ } catch (ArtifactMetadataRetrievalException e) {
+ artifact.setDependencyTrail(node.getDependencyTrail());
throw new ArtifactResolutionException(
- "Unable to get dependency information: " + e.getMessage(), artifact, e );
+ "Unable to get dependency information: "
+ + e.getMessage(), artifact, e);
}
- recurse( child, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source,
- filter, listeners );
+ recurse(child, resolvedArtifacts, managedVersions,
+ localRepository, remoteRepositories, source,
+ filter, listeners);
}
}
+ fireEvent(ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners,
+ node);
+ }
+ }
+
+ private ArtifactVersion getArtifactVersion(
+ ArtifactRepository localRepository,
+ List remoteRepositories,
+ ArtifactMetadataSource source,
+ Artifact artifact) throws OverConstrainedVersionException,
+ ArtifactMetadataRetrievalException {
+ ArtifactVersion version;
+ if (!artifact.isSelectedVersionKnown()) {
+ List versions = artifact.getAvailableVersions();
+ if (versions == null) {
+ versions = source.retrieveAvailableVersions(
+ artifact, localRepository,
+ remoteRepositories);
+ artifact.setAvailableVersions(versions);
+ }
+
+ VersionRange versionRange = artifact.getVersionRange();
+
+ version = versionRange.matchVersion(versions);
+
+ if (version == null) {
+ if (versions.isEmpty()) {
+ throw new OverConstrainedVersionException(
+ "No versions are present in the repository for the artifact with a range "
+ + versionRange, artifact, remoteRepositories);
+ } else {
+ throw new OverConstrainedVersionException(
+ "Couldn't find a version in "
+ + versions
+ + " to match range "
+ + versionRange,
+ artifact, remoteRepositories);
+ }
+ }
+ } else {
+ version = artifact.getSelectedVersion();
+ }
+ return version;
+ }
+
+ private ResolutionNode checkPreviousNodes(
+ ResolutionNode node,
+ List listeners,
+ List previousNodes) throws OverConstrainedVersionException {
+ for (Iterator i = previousNodes.iterator(); i.hasNext();) {
+ ResolutionNode previous = (ResolutionNode) i.next();
+ if (previous.isActive()) {
+ // Version mediation
+ VersionRange previousRange = previous.getArtifact().getVersionRange();
+ VersionRange currentRange = node.getArtifact().getVersionRange();
+ // TODO: why do we force the version on it? what if they
+ // don't match?
+ if (previousRange == null) {
+ // version was already resolved
+ node.getArtifact().setVersion(previous.getArtifact().getVersion());
+ } else if (currentRange == null) {
+ // version was already resolved
+ previous.getArtifact().setVersion(node.getArtifact().getVersion());
+ } else {
+ // TODO: shouldn't need to double up on this work, only
+ // done for simplicity of handling recommended
+ // version but the restriction is identical
+ VersionRange newRange = previousRange.restrict(currentRange);
+ // TODO: ick. this forces the OCE that should have come
+ // from the previous call. It is still correct
+ if (newRange.isSelectedVersionKnown(previous.getArtifact())) {
+ fireEvent(ResolutionListener.RESTRICT_RANGE,
+ listeners, node, previous.getArtifact(),
+ newRange);
+ }
+ previous.getArtifact().setVersionRange(newRange);
+ node.getArtifact().setVersionRange(
+ currentRange.restrict(previousRange));
+
+ // Select an appropriate available version from the (now
+ // restricted) range
+ // Note this version was selected before to get the
+ // appropriate POM
+ // But it was reset by the call to setVersionRange on
+ // restricting the version
+ ResolutionNode[] resetNodes = {previous, node };
+ for (int j = 0; j < 2; j++) {
+ Artifact resetArtifact = resetNodes[j]
+ .getArtifact();
+ if (resetArtifact.getVersion() == null
+ && resetArtifact.getVersionRange() != null
+ && resetArtifact.getAvailableVersions() != null) {
+
+ resetArtifact
+ .selectVersion(resetArtifact
+ .getVersionRange()
+ .matchVersion(
+ resetArtifact
+ .getAvailableVersions())
+ .toString());
+ fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE,
+ listeners, resetNodes[j]);
+ }
+ }
+ }
+
+ // Conflict Resolution
+ // TODO: use as conflict resolver(s), chain
- fireEvent( ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners, node );
+ // TODO: should this be part of mediation?
+ // previous one is more dominant
+ if (previous.getDepth() <= node.getDepth()) {
+ checkScopeUpdate(node, previous, listeners);
+ } else {
+ checkScopeUpdate(previous, node, listeners);
+ }
+
+ if (previous.getDepth() <= node.getDepth()) {
+ // previous was nearer
+ fireEvent(ResolutionListener.OMIT_FOR_NEARER,
+ listeners, node, previous.getArtifact());
+ node.disable();
+ node = previous;
+ } else {
+ fireEvent(ResolutionListener.OMIT_FOR_NEARER,
+ listeners, previous, node.getArtifact());
+ previous.disable();
+ }
+ }
}
+ return node;
}
- private void checkScopeUpdate( ResolutionNode farthest, ResolutionNode nearest, List listeners )
- {
+ private void checkScopeUpdate(ResolutionNode farthest,
+ ResolutionNode nearest, List listeners) {
boolean updateScope = false;
Artifact farthestArtifact = farthest.getArtifact();
Artifact nearestArtifact = nearest.getArtifact();
- if ( Artifact.SCOPE_RUNTIME.equals( farthestArtifact.getScope() ) && (
- Artifact.SCOPE_TEST.equals( nearestArtifact.getScope() ) ||
- Artifact.SCOPE_PROVIDED.equals( nearestArtifact.getScope() ) ) )
- {
+ if (Artifact.SCOPE_RUNTIME.equals(farthestArtifact.getScope())
+ && (Artifact.SCOPE_TEST.equals(nearestArtifact.getScope()) || Artifact.SCOPE_PROVIDED
+ .equals(nearestArtifact.getScope()))) {
updateScope = true;
}
- if ( Artifact.SCOPE_COMPILE.equals( farthestArtifact.getScope() ) &&
- !Artifact.SCOPE_COMPILE.equals( nearestArtifact.getScope() ) )
- {
+ if (Artifact.SCOPE_COMPILE.equals(farthestArtifact.getScope())
+ && !Artifact.SCOPE_COMPILE.equals(nearestArtifact.getScope())) {
updateScope = true;
}
// current POM rules all
- if ( nearest.getDepth() < 2 && updateScope )
- {
+ if (nearest.getDepth() < 2 && updateScope) {
updateScope = false;
- fireEvent( ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners, nearest, farthestArtifact );
+ fireEvent(ResolutionListener.UPDATE_SCOPE_CURRENT_POM, listeners,
+ nearest, farthestArtifact);
}
- if ( updateScope )
- {
- fireEvent( ResolutionListener.UPDATE_SCOPE, listeners, nearest, farthestArtifact );
-
- // previously we cloned the artifact, but it is more effecient to just update the scope
- // if problems are later discovered that the original object needs its original scope value, cloning may
+ if (updateScope) {
+ fireEvent(ResolutionListener.UPDATE_SCOPE, listeners, nearest,
+ farthestArtifact);
+
+ // previously we cloned the artifact, but it is more effecient to
+ // just update the scope
+ // if problems are later discovered that the original object needs
+ // its original scope value, cloning may
// again be appropriate
- nearestArtifact.setScope( farthestArtifact.getScope() );
+ nearestArtifact.setScope(farthestArtifact.getScope());
}
}
- private void fireEvent( int event, List listeners, ResolutionNode node )
- {
- fireEvent( event, listeners, node, null );
+ private void fireEvent(int event, List listeners, ResolutionNode node) {
+ fireEvent(event, listeners, node, null);
}
- private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement )
- {
- fireEvent( event, listeners, node, replacement, null );
+ private void fireEvent(int event, List listeners, ResolutionNode node,
+ Artifact replacement) {
+ fireEvent(event, listeners, node, replacement, null);
}
- private void fireEvent( int event, List listeners, ResolutionNode node, Artifact replacement,
- VersionRange newRange )
- {
- for ( Iterator i = listeners.iterator(); i.hasNext(); )
- {
+ private void fireEvent(int event, List listeners, ResolutionNode node,
+ Artifact replacement, VersionRange newRange) {
+ for (Iterator i = listeners.iterator(); i.hasNext();) {
ResolutionListener listener = (ResolutionListener) i.next();
- switch ( event )
- {
- case ResolutionListener.TEST_ARTIFACT:
- listener.testArtifact( node.getArtifact() );
- break;
- case ResolutionListener.PROCESS_CHILDREN:
- listener.startProcessChildren( node.getArtifact() );
- break;
- case ResolutionListener.FINISH_PROCESSING_CHILDREN:
- listener.endProcessChildren( node.getArtifact() );
- break;
- case ResolutionListener.INCLUDE_ARTIFACT:
- listener.includeArtifact( node.getArtifact() );
- break;
- case ResolutionListener.OMIT_FOR_NEARER:
- String version = node.getArtifact().getVersion();
- String replacementVersion = replacement.getVersion();
- if ( version != null ? !version.equals( replacementVersion ) : replacementVersion != null )
- {
- listener.omitForNearer( node.getArtifact(), replacement );
- }
- break;
- case ResolutionListener.OMIT_FOR_CYCLE:
- listener.omitForCycle( node.getArtifact() );
- break;
- case ResolutionListener.UPDATE_SCOPE:
- listener.updateScope( node.getArtifact(), replacement.getScope() );
- break;
- case ResolutionListener.UPDATE_SCOPE_CURRENT_POM:
- listener.updateScopeCurrentPom( node.getArtifact(), replacement.getScope() );
- break;
- case ResolutionListener.MANAGE_ARTIFACT:
- listener.manageArtifact( node.getArtifact(), replacement );
- break;
- case ResolutionListener.SELECT_VERSION_FROM_RANGE:
- listener.selectVersionFromRange( node.getArtifact() );
- break;
- case ResolutionListener.RESTRICT_RANGE:
- if ( node.getArtifact().getVersionRange().hasRestrictions() ||
- replacement.getVersionRange().hasRestrictions() )
- {
- listener.restrictRange( node.getArtifact(), replacement, newRange );
- }
- break;
- default:
- throw new IllegalStateException( "Unknown event: " + event );
+ switch (event) {
+ case ResolutionListener.TEST_ARTIFACT:
+ listener.testArtifact(node.getArtifact());
+ break;
+ case ResolutionListener.PROCESS_CHILDREN:
+ listener.startProcessChildren(node.getArtifact());
+ break;
+ case ResolutionListener.FINISH_PROCESSING_CHILDREN:
+ listener.endProcessChildren(node.getArtifact());
+ break;
+ case ResolutionListener.INCLUDE_ARTIFACT:
+ listener.includeArtifact(node.getArtifact());
+ break;
+ case ResolutionListener.OMIT_FOR_NEARER:
+ String version = node.getArtifact().getVersion();
+ String replacementVersion = replacement.getVersion();
+ if (version != null ? !version.equals(replacementVersion)
+ : replacementVersion != null) {
+ listener.omitForNearer(node.getArtifact(), replacement);
+ }
+ break;
+ case ResolutionListener.OMIT_FOR_CYCLE:
+ listener.omitForCycle(node.getArtifact());
+ break;
+ case ResolutionListener.UPDATE_SCOPE:
+ listener
+ .updateScope(node.getArtifact(), replacement.getScope());
+ break;
+ case ResolutionListener.UPDATE_SCOPE_CURRENT_POM:
+ listener.updateScopeCurrentPom(node.getArtifact(), replacement
+ .getScope());
+ break;
+ case ResolutionListener.MANAGE_ARTIFACT:
+ listener.manageArtifact(node.getArtifact(), replacement);
+ break;
+ case ResolutionListener.SELECT_VERSION_FROM_RANGE:
+ listener.selectVersionFromRange(node.getArtifact());
+ break;
+ case ResolutionListener.RESTRICT_RANGE:
+ if (node.getArtifact().getVersionRange().hasRestrictions()
+ || replacement.getVersionRange().hasRestrictions()) {
+ listener.restrictRange(node.getArtifact(), replacement,
+ newRange);
+ }
+ break;
+ default:
+ throw new IllegalStateException("Unknown event: " + event);
}
}
}
Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/IsDeployedTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/IsDeployedTask.java?view=diff&rev=551602&r1=551601&r2=551602
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/IsDeployedTask.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/IsDeployedTask.java Thu Jun 28 08:47:21 2007
@@ -21,57 +21,56 @@
public class IsDeployedTask extends JbiTask {
- private static final String JBI_SHARED_LIBRARY = "jbi-shared-library";
+ private static final String JBI_SHARED_LIBRARY = "jbi-shared-library";
- private static final String JBI_COMPONENT = "jbi-component";
+ private static final String JBI_COMPONENT = "jbi-component";
- private static final String JBI_SERVICE_ASSEMBLY = "jbi-service-assembly";
+ private static final String JBI_SERVICE_ASSEMBLY = "jbi-service-assembly";
- private boolean deployed = false;
+ private boolean deployed;
- private String type;
-
- private String name;
-
- public boolean isDeployed() {
- return deployed;
- }
-
- public void setDeployed(boolean deployed) {
- this.deployed = deployed;
- }
-
- protected void doExecute(AdminCommandsServiceMBean acs) throws Exception {
- if (JBI_SHARED_LIBRARY.equals(type)) {
- String result = acs.listSharedLibraries(null, name);
- setDeployed(isResultContaining(result, "shared-library", name));
- } else if (JBI_SERVICE_ASSEMBLY.equals(type)) {
- String result = acs.listServiceAssemblies(null, null, name);
- setDeployed(result.contains("<service-assembly-info name='" + name
- + "'"));
- }
- if (JBI_COMPONENT.equals(type)) {
- String result = acs.listComponents(false, false, false, null, null,
- null);
- if (isResultContaining(result, "service-engine", name)
- || isResultContaining(result, "binding-component", name)) {
- setDeployed(true);
- }
- }
- }
-
- private boolean isResultContaining(String result, String type, String name) {
- String componentLine = "<component-info type='" + type + "' name='"
- + name + "'";
- return result.contains(componentLine);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void setName(String name) {
- this.name = name;
- }
+ private String type;
+
+ private String name;
+
+ public boolean isDeployed() {
+ return deployed;
+ }
+
+ public void setDeployed(boolean deployed) {
+ this.deployed = deployed;
+ }
+
+ protected void doExecute(AdminCommandsServiceMBean acs) throws Exception {
+ if (JBI_SHARED_LIBRARY.equals(type)) {
+ String result = acs.listSharedLibraries(null, name);
+ setDeployed(isResultContaining(result, "shared-library", name));
+ } else if (JBI_SERVICE_ASSEMBLY.equals(type)) {
+ String result = acs.listServiceAssemblies(null, null, name);
+ setDeployed(result.contains("<service-assembly-info name='" + name
+ + "'"));
+ }
+ if (JBI_COMPONENT.equals(type)) {
+ String result = acs.listComponents(false, false, false, null, null,
+ null);
+ if (isResultContaining(result, "service-engine", name)
+ || isResultContaining(result, "binding-component", name)) {
+ setDeployed(true);
+ }
+ }
+ }
+
+ private boolean isResultContaining(String result, String t, String n) {
+ String componentLine = "<component-info type='" + t + "' name='" + n + "'";
+ return result.contains(componentLine);
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}