jsedding commented on a change in pull request #3: URL: https://github.com/apache/sling-maven-plugin/pull/3#discussion_r516015046
########## File path: sling-maven-plugin/src/main/java/org/apache/sling/maven/bundlesupport/JcrInstallMojo.java ########## @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.sling.maven.bundlesupport; + +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.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.sling.maven.bundlesupport.deploy.BundleDeploymentMethod; +import org.apache.sling.maven.bundlesupport.deploy.DeployContext; +import org.apache.sling.maven.bundlesupport.deploy.DeployMethod; + +import java.io.File; +import java.util.Optional; + +/** + * Upload a non-bundle artifact to the JCR repository of a running Sling instance. + * This goal mirrors the behavior of the <code>install</code> goal for uploading bundles when <code>deploymentMethod</code> + * is set to either <code>WebDAV</code> or <code>SlingPostServlet</code>, and is skipped when <code>deploymentMethod</code> + * is set to <code>WebConsole</code>. + * For <code>WebDAV</code> the goal will use HTTP PUT to leverage the <a href="http://sling.apache.org/documentation/development/repository-based-development.html">WebDAV bundle from Sling</a>. + * For <code>SlingPostServlet</code>, the goal will leverage the <a href="http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html">Sling POST servlet</a> + * instead. The chosen method depends on the parameter {@link #deploymentMethod}. + * <br> + * <p><strong>Intermediate Node Creation</strong></p> + * <p> + * For supported <code>deploymentMethod</code>s, the artifact is not directly deployed within the OSGi container, + * but rather is uploaded to the JCR and from there on being picked up by the + * <a href="https://sling.apache.org/documentation/bundles/jcr-installer-provider.html">JCR Installer Provider</a> asynchronously, which takes care + * of performing any installable resource transformation supported by the OSGi container. For both supported deployment methods, intermediate nodes (i.e. inexisting parent nodes) + * are automatically created. The primary type of those intermediate nodes depends on the deployment method. + * </p> + * <ul> + * <li> + * WebDAV, uses the configured collection node type, by default <code>sling:Folder</code> + * (see also <a href="https://sling.apache.org/documentation/development/repository-based-development.html">WebDAV Configuration</a>)</li> + * <li> + * SlingPostServlet, uses internally <code>ResourceResolverFactory.create(...)</code> without setting any <code>jcr:primaryType</code>. + * Therefore the <code>JcrResourceProviderFactory</code> will call <code>Node.addNode(String relPath)</code> which determines a fitting + * node type automatically, depending on the parents node type definition (see <a href="https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/javax/jcr/Node.html#addNode(java.lang.String)">Javadoc</a>). + * So in most of the cases this should be a <code>sling:Folder</code>, as this is the first allowed child node definition in <code>sling:Folder</code>. + * This only may differ, if your existing parent node is not of type <code>sling:Folder</code> itself. + * </li> + * </ul> + * + * @since 2.5.0 + */ +@Mojo(name = "jcr-install", defaultPhase = LifecyclePhase.INSTALL) Review comment: I agree with @kwin. It could be interesting to use the same mechanism to install other resources, e.g. feature archives (FAR). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
