Author: mfortun Date: 2011-08-29 11:45:10 +0200 (Mon, 29 Aug 2011) New Revision: 1195 Url: http://nuiton.org/repositories/revision/wikitty/1195 Log: add comments to plugin Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/JettyUtil.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPInitMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPJarMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPUpdateMojo.java Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -4,20 +4,17 @@ import org.apache.maven.artifact.installer.ArtifactInstaller; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; - /** * This mojo is for init for the goal that need to construct the application - * this mojo, with init will read pom file to load dependency declared - * and so needed by the wikitty publication application project. - * This will copy those needed dependency to the right directory: - * src/main/resources/jar + * this mojo, with init will read pom file to load dependency declared and so + * needed by the wikitty publication application project. This will copy those + * needed dependency to the right directory: src/main/resources/jar * * @author mfortun * @requiresProject true */ public abstract class AbstractWPLoadDependencyMojo extends AbstractWPMojo { - /** * @component */ @@ -28,29 +25,25 @@ */ protected ArtifactRepositoryFactory repositoryFactory; - /** * Used to look up Artifacts in the remote repository. - * + * * @component */ protected org.apache.maven.artifact.factory.ArtifactFactory factory; - - @Override protected void init() throws Exception { - + CopyDependencyUtil cpDep = new CopyDependencyUtil(); - + // construct path to jar dir File basedir = getProject().getBasedir(); File jarDir = new File(basedir.getAbsolutePath() + File.separator - + SRC_DIR_NAME + File.separator - + MAIN_DIR_NAME + File.separator - + RESOURCES_DIR_NAME + File.separator + + SRC_DIR_NAME + File.separator + MAIN_DIR_NAME + + File.separator + RESOURCES_DIR_NAME + File.separator + JAR_RESOURCES_DIR_NAME); - + // initialize param for dependency copy cpDep.setRepositoryFactory(repositoryFactory); cpDep.setInstaller(installer); @@ -58,10 +51,9 @@ cpDep.setOutputDirectory(jarDir); cpDep.setFactory(factory); cpDep.setLog(getLog()); - // run - cpDep.execute(); + // run that will copy jar declared as dependency into the resource/jar + // dir + cpDep.execute(); } - - - + } Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/JettyUtil.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/JettyUtil.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/JettyUtil.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -15,7 +15,7 @@ * New definition of the JettyRunWarMojo * to set the protected visibility and getter and setter for the webApp file * - * @author mfortun + * @author mfortun <manoel.fortun@gmail.com> * */ public class JettyUtil extends AbstractJettyMojo Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -76,11 +76,10 @@ import java.util.Properties; import java.util.Set; - /** * To deploy a wikitty publication jar. - * - * @author tchemit <chemit@codelutin.com> + * + * @author tchemit <chemit@codelutin.com>, mfortun <manoel.fortun@gmail.com> * @version $Id$ * @goal deploy-jar * @requiresProject true @@ -88,11 +87,12 @@ * @requiresDependencyResolution runtime * @since 3.2 */ -public class WPDeployJarMojo extends AbstractWPLoadDependencyMojo implements Contextualizable { +public class WPDeployJarMojo extends AbstractWPLoadDependencyMojo implements + Contextualizable { /** * Id of server. - * + * * @parameter expression="${serverId}" * @required */ @@ -100,25 +100,24 @@ /** * URL of server to use to log into server. - * + * * @parameter expression="${serverUrl}" * @required */ protected String serverUrl; - /** * Whether to run the "chmod" command on the remote site after the deploy. * Defaults to "true". - * + * * @parameter expression="${maven.site.chmod}" default-value="true" */ protected boolean chmod; /** - * The mode used by the "chmod" command. Only used if chmod = true. - * Defaults to "g+w,a+rX". - * + * The mode used by the "chmod" command. Only used if chmod = true. Defaults + * to "g+w,a+rX". + * * @parameter expression="${maven.site.chmod.mode}" default-value="g+w,a+rX" */ protected String chmodMode; @@ -126,7 +125,7 @@ /** * The options used by the "chmod" command. Only used if chmod = true. * Defaults to "-Rf". - * + * * @parameter expression="${maven.site.chmod.options}" default-value="-Rf" */ protected String chmodOptions; @@ -136,7 +135,7 @@ /** * The current user system settings for use in Maven. - * + * * @parameter expression="${settings}" * @required * @readonly @@ -156,7 +155,7 @@ /** * All available wagons. - * + * * @component role="org.apache.maven.wagon.Wagon" * @since 1.0 */ @@ -171,7 +170,7 @@ /** * file to deploy - * + * * @parameter expression="${fileToDeploy}" * @required */ @@ -180,25 +179,23 @@ @Override protected void init() throws Exception { super.init(); - - - - if (fileToDeploy==null || !fileToDeploy.exists()){ + + // if file not declare seach for the default file construct by + // wp:jar + if (fileToDeploy == null || !fileToDeploy.exists()) { String file = getProject().getBuild().getDirectory(); - file+=File.separator+WPJarMojo.EXTERNALIZE_PREFIX+applicationName+".jar"; - fileToDeploy= new File(file); + file += File.separator + WPJarMojo.EXTERNALIZE_PREFIX + + applicationName + ".jar"; + fileToDeploy = new File(file); } - - repository = new Repository( - serverId, - serverUrl - ); + repository = new Repository(serverId, serverUrl); + if (!fileToDeploy.exists()) { - throw new MojoExecutionException("The file to deploy " + fileToDeploy + " does not exist"); + throw new MojoExecutionException("The file to deploy " + + fileToDeploy + " does not exist"); } - if (!isMaven3OrMore()) { proxyInfo = getProxyInfo(); } else { @@ -213,23 +210,27 @@ @Override protected void doAction() throws Exception { - - - if (getLog().isDebugEnabled()) { - getLog().debug("Deploying to '" + repository.getUrl() - + "',\n Using credentials from server id '" + repository.getId() + "'"); + getLog().debug( + "Deploying to '" + repository.getUrl() + + "',\n Using credentials from server id '" + + repository.getId() + "'"); } try { - - configureWagon(wagon, repository.getId(), settings, container, getLog()); - - AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo(repository.getId()); - getLog().debug("authenticationInfo with id '" + repository.getId() + "': " - + (authenticationInfo == null ? "-" : authenticationInfo.getUserName())); + configureWagon(wagon, repository.getId(), settings, container, + getLog()); + AuthenticationInfo authenticationInfo = wagonManager + .getAuthenticationInfo(repository.getId()); + getLog().debug( + "authenticationInfo with id '" + + repository.getId() + + "': " + + (authenticationInfo == null ? "-" + : authenticationInfo.getUserName())); + try { Debug debug = new Debug(); @@ -241,10 +242,12 @@ getLog().debug("connect with proxyInfo"); wagon.connect(repository, authenticationInfo, proxyInfo); } else if (authenticationInfo != null) { - getLog().debug("connect with authenticationInfo and without proxyInfo"); + getLog().debug( + "connect with authenticationInfo and without proxyInfo"); wagon.connect(repository, authenticationInfo); } else { - getLog().debug("connect without authenticationInfo and without proxyInfo"); + getLog().debug( + "connect without authenticationInfo and without proxyInfo"); wagon.connect(repository); } @@ -268,9 +271,11 @@ try { if (wagon instanceof CommandExecutor) { CommandExecutor exec = (CommandExecutor) wagon; - exec.executeCommand("chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir()); + exec.executeCommand("chmod " + chmodOptions + " " + + chmodMode + " " + repository.getBasedir()); } - // else ? silently ignore, FileWagon is not a CommandExecutor! + // else ? silently ignore, FileWagon is not a + // CommandExecutor! } catch (CommandExecutionException e) { throw new MojoExecutionException("Error uploading site", e); } @@ -286,7 +291,8 @@ } protected boolean isMaven3OrMore() { - return new ComparableVersion(getMavenVersion()).compareTo(new ComparableVersion("3.0")) >= 0; + return new ComparableVersion(getMavenVersion()) + .compareTo(new ComparableVersion("3.0")) >= 0; } protected String getMavenVersion() { @@ -295,8 +301,10 @@ // and that should have a pom.properties file // if this ever changes, we will have to revisit this code. Properties properties = new Properties(); - InputStream in = - MavenProject.class.getClassLoader().getResourceAsStream("META-INF/maven/org.apache.maven/maven-core/pom.properties"); + InputStream in = MavenProject.class + .getClassLoader() + .getResourceAsStream( + "META-INF/maven/org.apache.maven/maven-core/pom.properties"); try { properties.load(in); } catch (IOException ioe) { @@ -316,19 +324,24 @@ /** * <p> - * Get the <code>ProxyInfo</code> of the proxy associated with the <code>host</code> - * and the <code>protocol</code> of the given <code>repository</code>. + * Get the <code>ProxyInfo</code> of the proxy associated with the + * <code>host</code> and the <code>protocol</code> of the given + * <code>repository</code>. * </p> * <p> - * Extract from <a href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html"> - * J2SE Doc : Networking Properties - nonProxyHosts</a> : "The value can be a list of hosts, - * each separated by a |, and in addition a wildcard character (*) can be used for matching" + * Extract from <a + * href="http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html"> + * J2SE Doc : Networking Properties - nonProxyHosts</a> : "The value can be + * a list of hosts, each separated by a |, and in addition a wildcard + * character (*) can be used for matching" * </p> * <p> - * Defensively support for comma (",") and semi colon (";") in addition to pipe ("|") as separator. + * Defensively support for comma (",") and semi colon (";") in addition to + * pipe ("|") as separator. * </p> - * - * @return a ProxyInfo object instantiated or <code>null</code> if no matching proxy is found + * + * @return a ProxyInfo object instantiated or <code>null</code> if no + * matching proxy is found */ public ProxyInfo getProxyInfo() { @@ -340,27 +353,33 @@ String host = repository.getHost(); String nonProxyHostsAsString = proxyInfo.getNonProxyHosts(); - String[] nonProxyHosts = StringUtils.split(nonProxyHostsAsString, ",;|"); + String[] nonProxyHosts = StringUtils + .split(nonProxyHostsAsString, ",;|"); for (int i = 0; i < nonProxyHosts.length; i++) { String nonProxyHost = nonProxyHosts[i]; if (StringUtils.contains(nonProxyHost, "*")) { - // Handle wildcard at the end, beginning or middle of the nonProxyHost + // Handle wildcard at the end, beginning or middle of the + // nonProxyHost int pos = nonProxyHost.indexOf('*'); String nonProxyHostPrefix = nonProxyHost.substring(0, pos); String nonProxyHostSuffix = nonProxyHost.substring(pos + 1); // prefix* - if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) - && StringUtils.isEmpty(nonProxyHostSuffix)) { + if (StringUtils.isNotEmpty(nonProxyHostPrefix) + && host.startsWith(nonProxyHostPrefix) + && StringUtils.isEmpty(nonProxyHostSuffix)) { return null; } // *suffix if (StringUtils.isEmpty(nonProxyHostPrefix) - && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) { + && StringUtils.isNotEmpty(nonProxyHostSuffix) + && host.endsWith(nonProxyHostSuffix)) { return null; } // prefix*suffix - if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix) - && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) { + if (StringUtils.isNotEmpty(nonProxyHostPrefix) + && host.startsWith(nonProxyHostPrefix) + && StringUtils.isNotEmpty(nonProxyHostSuffix) + && host.endsWith(nonProxyHostSuffix)) { return null; } } else if (host.equals(nonProxyHost)) { @@ -372,7 +391,7 @@ /** * Get proxy information for Maven 3. - * + * * @return */ private ProxyInfo getProxy() { @@ -386,13 +405,16 @@ // but the real protocol (transport layer) is http(s) // and it's the one use in wagon to find the proxy arghhh // so we will check both - if (StringUtils.equalsIgnoreCase("dav", protocol) && url.startsWith("dav:")) { + if (StringUtils.equalsIgnoreCase("dav", protocol) + && url.startsWith("dav:")) { url = url.substring(4); if (url.startsWith("http")) { try { URL urlSite = new URL(url); protocol = urlSite.getProtocol(); - getLog().debug("found dav protocol so transform to real transport protocol " + protocol); + getLog().debug( + "found dav protocol so transform to real transport protocol " + + protocol); } catch (MalformedURLException e) { getLog().warn("fail to build URL with " + url); } @@ -410,24 +432,31 @@ if (proxies != null) { for (Proxy proxy : proxies) { if (proxy.isActive() - && (protocol.equalsIgnoreCase(proxy.getProtocol()) || originalProtocol - .equalsIgnoreCase(proxy.getProtocol()))) { + && (protocol.equalsIgnoreCase(proxy + .getProtocol()) || originalProtocol + .equalsIgnoreCase(proxy.getProtocol()))) { SettingsDecryptionResult result = settingsDecrypter - .decrypt(new DefaultSettingsDecryptionRequest(proxy)); + .decrypt(new DefaultSettingsDecryptionRequest( + proxy)); proxy = result.getProxy(); ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setHost(proxy.getHost()); - // so hackish for wagon the protocol is https for site dav : dav:https://dav.codehaus.org/mojo/ - proxyInfo.setType(protocol);//proxy.getProtocol() ); + // so hackish for wagon the protocol is https for + // site dav : dav:https://dav.codehaus.org/mojo/ + proxyInfo.setType(protocol);// proxy.getProtocol() + // ); proxyInfo.setPort(proxy.getPort()); - proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts()); + proxyInfo + .setNonProxyHosts(proxy.getNonProxyHosts()); proxyInfo.setUserName(proxy.getUsername()); proxyInfo.setPassword(proxy.getPassword()); - getLog().debug("found proxyInfo " - + "host:port " + proxyInfo.getHost() - + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName()); + getLog().debug( + "found proxyInfo " + "host:port " + + proxyInfo.getHost() + ":" + + proxyInfo.getPort() + ", " + + proxyInfo.getUserName()); return proxyInfo; } @@ -435,23 +464,29 @@ } } } - getLog().debug("getProxy 'protocol': " + protocol + " no ProxyInfo found"); + getLog().debug( + "getProxy 'protocol': " + protocol + " no ProxyInfo found"); return null; } - private Wagon getWagon(org.apache.maven.wagon.repository.Repository repository, WagonManager manager) - throws MojoExecutionException { + private Wagon getWagon( + org.apache.maven.wagon.repository.Repository repository, + WagonManager manager) throws MojoExecutionException { Wagon wagon; try { wagon = manager.getWagon(repository); } catch (UnsupportedProtocolException e) { - String shortMessage = - "Unsupported protocol: '" + repository.getProtocol() + "' for site deployment to " - + "distributionManagement.site.url=" + repository.getUrl() + "."; - String longMessage = - "\n" + shortMessage + "\n" + - "Currently supported protocols are: " + getSupportedProtocols() + ".\n" + String shortMessage = "Unsupported protocol: '" + + repository.getProtocol() + "' for site deployment to " + + "distributionManagement.site.url=" + repository.getUrl() + + "."; + String longMessage = "\n" + + shortMessage + + "\n" + + "Currently supported protocols are: " + + getSupportedProtocols() + + ".\n" + " Protocols may be added through wagon providers.\n" + " For more information, see " + "http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-pro..."; @@ -460,30 +495,35 @@ throw new MojoExecutionException(shortMessage); } catch (TransferFailedException e) { - throw new MojoExecutionException("Unable to configure Wagon: '" + repository.getProtocol() + "'", e); + throw new MojoExecutionException("Unable to configure Wagon: '" + + repository.getProtocol() + "'", e); } if (!wagon.supportsDirectoryCopy()) { - throw new MojoExecutionException( - "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying"); + throw new MojoExecutionException("Wagon protocol '" + + repository.getProtocol() + + "' doesn't support directory copying"); } return wagon; } /** - * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml ) - * + * Configure the Wagon with the information from serverConfigurationMap ( + * which comes from settings.xml ) + * * @param wagon * @param repositoryId * @param settings * @param container * @param log * @throws WagonConfigurationException - * @todo Remove when {@link WagonManager#getWagon(org.apache.maven.wagon.repository.Repository) is available}. It's available in Maven 2.0.5. + * @todo Remove when + * {@link WagonManager#getWagon(org.apache.maven.wagon.repository.Repository) + * is available}. It's available in Maven 2.0.5. */ - private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container, - Log log) + private static void configureWagon(Wagon wagon, String repositoryId, + Settings settings, PlexusContainer container, Log log) throws TransferFailedException { log.debug(" configureWagon "); @@ -496,25 +536,35 @@ if (id != null && id.equals(repositoryId)) { if (server.getConfiguration() != null) { - PlexusConfiguration plexusConf = - new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration()); + PlexusConfiguration plexusConf = new XmlPlexusConfiguration( + (Xpp3Dom) server.getConfiguration()); ComponentConfigurator componentConfigurator = null; try { - componentConfigurator = (ComponentConfigurator) container.lookup(ComponentConfigurator.ROLE, "basic"); - componentConfigurator.configureComponent(wagon, plexusConf, container.getContainerRealm()); + componentConfigurator = (ComponentConfigurator) container + .lookup(ComponentConfigurator.ROLE, "basic"); + componentConfigurator.configureComponent(wagon, + plexusConf, container.getContainerRealm()); } catch (ComponentLookupException e) { - throw new TransferFailedException("While configuring wagon for \'" + repositoryId - + "\': Unable to lookup wagon configurator." + " Wagon configuration cannot be applied.", e); + throw new TransferFailedException( + "While configuring wagon for \'" + + repositoryId + + "\': Unable to lookup wagon configurator." + + " Wagon configuration cannot be applied.", + e); } catch (ComponentConfigurationException e) { - throw new TransferFailedException("While configuring wagon for \'" + repositoryId - + "\': Unable to apply wagon configuration.", e); + throw new TransferFailedException( + "While configuring wagon for \'" + + repositoryId + + "\': Unable to apply wagon configuration.", + e); } finally { if (componentConfigurator != null) { try { container.release(componentConfigurator); } catch (ComponentLifecycleException e) { - log.error("Problem releasing configurator - ignoring: " + e.getMessage()); + log.error("Problem releasing configurator - ignoring: " + + e.getMessage()); } } } @@ -524,10 +574,8 @@ } /** {@inheritDoc} */ - public void contextualize(Context context) - throws ContextException { + public void contextualize(Context context) throws ContextException { container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); } - } \ No newline at end of file Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -31,7 +31,7 @@ /** * To deploy a wikitty publication. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com>, mfortun <manoel.fortun@gmail.com> * @version $Id$ * @goal deploy * @requiresProject true @@ -50,14 +50,24 @@ @Override protected void doAction() throws Exception { - // Use syncrhonise. + // construct uri of the file system wikitty service uri + // with the correct label as fragment. String origin = getProject().getBasedir().toURI().toURL() .toExternalForm(); origin += WikittyPublicationConstant.LABEL_DELIM + SRC_DIR_NAME + WikittyFileUtil.WIKITTY_LABEL_SEPARATOR + MAIN_DIR_NAME; + + + // Construct the target uri with the correct label as fragment + // to ensure that wikitty under src/main/java label will be under + // application name label String target = wikittyServiceUrl; target += WikittyPublicationConstant.LABEL_DELIM + applicationName; + + + // launch syncrhonise with recursion enabled and delete and existing option + // disable WikittyPublicationSynchronize.synchronisationServices(origin, target, true, false, false); } Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPInitMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPInitMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPInitMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -67,6 +67,7 @@ File jarDir = new File(ressourceDir.getAbsolutePath() + File.separator + JAR_RESOURCES_DIR_NAME); + // create dirs createDirectoryIfNecessary(srcDir); createDirectoryIfNecessary(mainDir); createDirectoryIfNecessary(appDir); Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPJarMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPJarMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPJarMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -39,7 +39,7 @@ /** * To create a wikitty publication jar. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com>, mfortun <manoel.fortun@gmail.com> * @version $Id$ * @goal jar * @requiresProject true @@ -64,14 +64,15 @@ // with this we will obtain the same directory/label configuration // that we will have on a classic service - + // construct uri of the file system wikitty service uri + // with the correct label as fragment. String origin = getProject().getBasedir().toURI().toURL() .toExternalForm(); origin += WikittyPublicationConstant.LABEL_DELIM + SRC_DIR_NAME + WikittyFileUtil.WIKITTY_LABEL_SEPARATOR + MAIN_DIR_NAME; - + // Construct first inside the build dir a temporary repositorie String buildDir = getProject().getBuild().getDirectory(); File targetFile = new File(buildDir); createDirectoryIfNecessary(targetFile); @@ -80,31 +81,40 @@ File appsDir = new File(buildDir+File.separator+appPath); createDirectoryIfNecessary(appsDir); - + // Construct the uri over file system to ensure that wikitties will + // have the correct String target = targetFile.toURI().toURL().toExternalForm(); target += WikittyPublicationConstant.LABEL_DELIM + applicationName; - + // launch syncrhonise with recursion enabled and delete and existing option + // disable WikittyPublicationSynchronize.synchronisationServices(origin, target, true, false, false); - // then externalize the target - + + + + // then externalize the target that have the correct label ApplicationConfig appconfig = new ApplicationConfig(); - + + // construct application config with the current wikitty service over + // file system appconfig.setOption( WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS.getKey(), WikittyPublicationFileSystem.class.getName()); appconfig.setOption(WikittyConfigOption.WIKITTY_SERVER_URL.getKey(), target); - + + // the criteria to externalize all the wikitty Criteria critOnWikittyWithLabel = Search.query().keyword("*") .criteria(); String jarName = EXTERNALIZE_PREFIX+applicationName; + // construct the jar with a custom name, in the build dir + // the correct config for the service a the criteria WikittyPublicationExternalize.externalize(appconfig, critOnWikittyWithLabel,targetFile, jarName); Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -45,7 +45,7 @@ /** * To run a wikitty publication project. * - * @author tchemit <chemit@codelutin.com> + * @author tchemit <chemit@codelutin.com>, mfortun <manoel.fortun@gmail.com> * @version $Id$ * @goal run * @requiresProject true @@ -117,13 +117,16 @@ @Override protected void doAction() throws Exception { + // search for the wikitty publication ui war File webApp = resolveFile(); - + // prepare the fall back uri that will be a wikitty service orver + // file system, our current src/main dir with the application String build = project.getBuild().getDirectory(); File buildDir = new File(build); createDirectoryIfNecessary(buildDir); + // construct props dir that will contain properties for fallback File propsFile = new File(build + File.separator + FALLBACK_PROPERTIE_FILE_NAME); if (propsFile.exists()) { @@ -133,7 +136,7 @@ // construct propertie for fallback service String fileSystemUrlService = getProject().getBasedir().toURI().toURL() .toExternalForm(); - + fileSystemUrlService += WikittyPublicationConstant.LABEL_DELIM + SRC_DIR_NAME + WikittyFileUtil.WIKITTY_LABEL_SEPARATOR + MAIN_DIR_NAME; @@ -157,6 +160,7 @@ System.setProperty(ApplicationConfig.CONFIG_PATH, getProject() .getBuild().getDirectory()); + // run jetty with our application inside fallback in wikitty publication JettyUtil jettyRunMojo = new JettyUtil(); jettyRunMojo.setWebApp(webApp); jettyRunMojo.setProject(project); Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPUpdateMojo.java =================================================================== --- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPUpdateMojo.java 2011-08-29 09:11:40 UTC (rev 1194) +++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPUpdateMojo.java 2011-08-29 09:45:10 UTC (rev 1195) @@ -30,8 +30,8 @@ /** * To update a wikitty publication project. - * - * @author tchemit <chemit@codelutin.com> + * + * @author tchemit <chemit@codelutin.com>, mfortun <manoel.fortun@gmail.com> * @version $Id$ * @goal update * @requiresProject true @@ -44,20 +44,29 @@ @Override protected void init() throws Exception { super.init(); - //TODO + // TODO } @Override protected void doAction() throws Exception { - // same as deploy - // Use syncrhonise. + // Same as deploy + + // construct uri of the file system wikitty service uri + // with the correct label as fragment. String origin = getProject().getBasedir().toURI().toURL() .toExternalForm(); origin += WikittyPublicationConstant.LABEL_DELIM + SRC_DIR_NAME + WikittyFileUtil.WIKITTY_LABEL_SEPARATOR + MAIN_DIR_NAME; + + // Construct the target uri with the correct label as fragment + // to ensure that wikitty under src/main/java label will be under + // application name label String target = wikittyServiceUrl; target += WikittyPublicationConstant.LABEL_DELIM + applicationName; + // launch syncrhonise with recursion enabled and delete and existing + // option + // disable WikittyPublicationSynchronize.synchronisationServices(origin, target, true, false, false); }