Wikitty-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
August 2011
- 6 participants
- 125 discussions
r1185 - in trunk/wp-maven-plugin: . src/main/java/org/nuiton/wikitty/plugin src/main/resources
by mfortun@users.nuiton.org 26 Aug '11
by mfortun@users.nuiton.org 26 Aug '11
26 Aug '11
Author: mfortun
Date: 2011-08-26 10:56:14 +0200 (Fri, 26 Aug 2011)
New Revision: 1185
Url: http://nuiton.org/repositories/revision/wikitty/1185
Log:
*Now load dependency from pom if needed
Added:
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/CopyDependencyUtil.java
trunk/wp-maven-plugin/src/main/resources/log4j.properties
Modified:
trunk/wp-maven-plugin/pom.xml
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.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/pom.xml
===================================================================
--- trunk/wp-maven-plugin/pom.xml 2011-08-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/pom.xml 2011-08-26 08:56:14 UTC (rev 1185)
@@ -87,6 +87,10 @@
<artifactId>maven-site-plugin</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </dependency>
</dependencies>
Added: 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 (rev 0)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPLoadDependencyMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -0,0 +1,67 @@
+package org.nuiton.wikitty.plugin;
+
+import java.io.File;
+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
+ *
+ * @author mfortun
+ * @requiresProject true
+ */
+public abstract class AbstractWPLoadDependencyMojo extends AbstractWPMojo {
+
+
+ /**
+ * @component
+ */
+ protected ArtifactInstaller installer;
+
+ /**
+ * @component
+ */
+ 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
+ + JAR_RESOURCES_DIR_NAME);
+
+ // initialize param for dependency copy
+ cpDep.setRepositoryFactory(repositoryFactory);
+ cpDep.setInstaller(installer);
+ cpDep.setProject(project);
+ cpDep.setOutputDirectory(jarDir);
+ cpDep.setFactory(factory);
+ cpDep.setLog(getLog());
+ // run
+ cpDep.execute();
+ }
+
+
+
+}
Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java
===================================================================
--- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java 2011-08-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -37,7 +37,10 @@
static public String SRC_DIR_NAME = "src";
static public String MAIN_DIR_NAME = "main";
-
+ static public String APPLICATION_DIR_NAME = "wp";
+ static public String RESOURCES_DIR_NAME = "resources";
+ static public String IMAGES_RESOURCES_DIR_NAME = "images";
+ static public String JAR_RESOURCES_DIR_NAME = "jar";
/**
* Project.
*
Added: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/CopyDependencyUtil.java
===================================================================
--- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/CopyDependencyUtil.java (rev 0)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/CopyDependencyUtil.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -0,0 +1,248 @@
+package org.nuiton.wikitty.plugin;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.AbstractFromDependenciesMojo;
+import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+
+public class CopyDependencyUtil extends AbstractFromDependenciesMojo {
+
+ public ArtifactInstaller getInstaller() {
+ return installer;
+ }
+
+ public void setInstaller(ArtifactInstaller installer) {
+ this.installer = installer;
+ }
+
+ public ArtifactRepositoryFactory getRepositoryFactory() {
+ return repositoryFactory;
+ }
+
+ public void setRepositoryFactory(ArtifactRepositoryFactory repositoryFactory) {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ public Map getRepositoryLayouts() {
+ return repositoryLayouts;
+ }
+
+ public void setRepositoryLayouts(Map repositoryLayouts) {
+ this.repositoryLayouts = repositoryLayouts;
+ }
+
+ /**
+ * @component
+ */
+ protected ArtifactInstaller installer;
+
+ /**
+ * @component
+ */
+ protected ArtifactRepositoryFactory repositoryFactory;
+
+ /**
+ * @component role=
+ * "org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
+ */
+ private Map repositoryLayouts;
+
+ /**
+ * Main entry into mojo. Gets the list of dependencies and iterates through
+ * calling copyArtifact.
+ *
+ * @throws MojoExecutionException
+ * with a message if an error occurs.
+ *
+ * @see #getDependencies
+ * @see #copyArtifact(Artifact, boolean)
+ */
+ public void execute() throws MojoExecutionException {
+ DependencyStatusSets dss = getDependencySets(this.failOnMissingClassifierArtifact);
+ Set artifacts = dss.getResolvedDependencies();
+
+ if (!useRepositoryLayout) {
+ for (Iterator i = artifacts.iterator(); i.hasNext();) {
+ copyArtifact((Artifact) i.next(), this.stripVersion,
+ this.prependGroupId);
+ }
+ } else {
+ try {
+ ArtifactRepository targetRepository = repositoryFactory
+ .createDeploymentArtifactRepository("local",
+ outputDirectory.toURL().toExternalForm(),
+ (ArtifactRepositoryLayout) repositoryLayouts
+ .get("default"), false /* uniqueVersion */);
+ for (Iterator i = artifacts.iterator(); i.hasNext();) {
+ installArtifact((Artifact) i.next(), targetRepository);
+ }
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException(
+ "Could not create outputDirectory repository", e);
+ }
+ }
+
+ Set skippedArtifacts = dss.getSkippedDependencies();
+ for (Iterator i = skippedArtifacts.iterator(); i.hasNext();) {
+ Artifact artifact = (Artifact) i.next();
+ getLog().info(
+ artifact.getFile().getName()
+ + " already exists in destination.");
+ }
+
+ if (isCopyPom()) {
+ copyPoms(getOutputDirectory(), artifacts, this.stripVersion);
+ copyPoms(getOutputDirectory(), skippedArtifacts, this.stripVersion); // Artifacts
+ // that
+ // already
+ // exist
+ // may
+ // not
+ // already
+ // have
+ // poms.
+ }
+ }
+
+ private void installArtifact(Artifact artifact,
+ ArtifactRepository targetRepository) {
+ try {
+ if ("pom".equals(artifact.getType())) {
+ installer.install(artifact.getFile(), artifact,
+ targetRepository);
+ installBaseSnapshot(artifact, targetRepository);
+ } else {
+ installer.install(artifact.getFile(), artifact,
+ targetRepository);
+ installBaseSnapshot(artifact, targetRepository);
+
+ if (isCopyPom()) {
+ Artifact pomArtifact = getResolvedPomArtifact(artifact);
+ if (pomArtifact.getFile() != null
+ && pomArtifact.getFile().exists()) {
+ installer.install(pomArtifact.getFile(), pomArtifact,
+ targetRepository);
+ installBaseSnapshot(pomArtifact, targetRepository);
+ }
+ }
+ }
+ } catch (ArtifactInstallationException e) {
+ getLog().info(e.getMessage());
+ }
+ }
+
+ private void installBaseSnapshot(Artifact artifact,
+ ArtifactRepository targetRepository)
+ throws ArtifactInstallationException {
+ if (artifact.isSnapshot()
+ && !artifact.getBaseVersion().equals(artifact.getVersion())) {
+ Artifact baseArtifact = this.factory.createArtifact(
+ artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getBaseVersion(), artifact.getScope(),
+ artifact.getType());
+ installer.install(artifact.getFile(), baseArtifact,
+ targetRepository);
+ }
+ }
+
+ /**
+ * Copies the Artifact after building the destination file name if
+ * overridden. This method also checks if the classifier is set and adds it
+ * to the destination file name if needed.
+ *
+ * @param artifact
+ * representing the object to be copied.
+ * @param removeVersion
+ * specifies if the version should be removed from the file name
+ * when copying.
+ * @param prependGroupId
+ * specifies if the groupId should be prepend to the file while
+ * copying.
+ * @throws MojoExecutionException
+ * with a message if an error occurs.
+ *
+ * @see DependencyUtil#copyFile(File, File, Log)
+ * @see DependencyUtil#getFormattedFileName(Artifact, boolean)
+ */
+ protected void copyArtifact(Artifact artifact, boolean removeVersion,
+ boolean prependGroupId) throws MojoExecutionException {
+
+ String destFileName = DependencyUtil.getFormattedFileName(artifact,
+ removeVersion, prependGroupId);
+
+ File destDir;
+ destDir = DependencyUtil.getFormattedOutputDirectory(
+ useSubDirectoryPerScope, useSubDirectoryPerType,
+ useSubDirectoryPerArtifact, useRepositoryLayout, stripVersion,
+ outputDirectory, artifact);
+ File destFile = new File(destDir, destFileName);
+
+ copyFile(artifact.getFile(), destFile);
+ }
+
+ /**
+ * Copy the pom files associated with the artifacts.
+ */
+ public void copyPoms(File destDir, Set artifacts, boolean removeVersion)
+ throws MojoExecutionException
+
+ {
+ Iterator iter = artifacts.iterator();
+ while (iter.hasNext()) {
+ Artifact artifact = (Artifact) iter.next();
+ Artifact pomArtifact = getResolvedPomArtifact(artifact);
+
+ // Copy the pom
+ if (pomArtifact.getFile() != null && pomArtifact.getFile().exists()) {
+ File pomDestFile = new File(destDir,
+ DependencyUtil.getFormattedFileName(pomArtifact,
+ removeVersion, prependGroupId));
+ if (!pomDestFile.exists()) {
+ copyFile(pomArtifact.getFile(), pomDestFile);
+ }
+ }
+ }
+ }
+
+ protected Artifact getResolvedPomArtifact(Artifact artifact) {
+ Artifact pomArtifact = this.factory.createArtifact(
+ artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion(), "", "pom");
+ // Resolve the pom artifact using repos
+ try {
+ this.resolver.resolve(pomArtifact, this.remoteRepos,
+ this.getLocal());
+ } catch (Exception e) {
+ getLog().info(e.getMessage());
+ }
+ return pomArtifact;
+ }
+
+ protected ArtifactsFilter getMarkedArtifactFilter() {
+ return new DestFileFilter(this.overWriteReleases,
+ this.overWriteSnapshots, this.overWriteIfNewer,
+ this.useSubDirectoryPerArtifact, this.useSubDirectoryPerType,
+ this.useSubDirectoryPerScope, this.useRepositoryLayout,
+ this.stripVersion, this.outputDirectory);
+ }
+
+ public void setProject(MavenProject pro) {
+ project = pro;
+ }
+
+}
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -88,7 +88,7 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPDeployJarMojo extends AbstractWPMojo implements Contextualizable {
+public class WPDeployJarMojo extends AbstractWPLoadDependencyMojo implements Contextualizable {
/**
* Id of server.
@@ -179,7 +179,7 @@
@Override
protected void init() throws Exception {
-
+ super.init();
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -39,10 +39,11 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPDeployMojo extends AbstractWPMojo {
+public class WPDeployMojo extends AbstractWPLoadDependencyMojo {
@Override
protected void init() throws Exception {
+ super.init();
// TODO
}
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPInitMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -41,11 +41,6 @@
public class WPInitMojo extends AbstractWPMojo {
- static public String APPLICATION_DIR_NAME = "wp";
- static public String RESSOURCES_DIR_NAME = "ressources";
- static public String IMAGES_RESSOURCES_DIR_NAME = "images";
- static public String JAR_RESSOURCES_DIR_NAME = "jar";
-
@Override
protected void init() throws Exception {
// TODO
@@ -66,11 +61,11 @@
File appDir = new File(mainDir.getAbsolutePath() + File.separator
+ APPLICATION_DIR_NAME);
File ressourceDir = new File(mainDir.getAbsolutePath() + File.separator
- + RESSOURCES_DIR_NAME);
+ + RESOURCES_DIR_NAME);
File imgDir = new File(ressourceDir.getAbsolutePath() + File.separator
- + IMAGES_RESSOURCES_DIR_NAME);
+ + IMAGES_RESOURCES_DIR_NAME);
File jarDir = new File(ressourceDir.getAbsolutePath() + File.separator
- + JAR_RESSOURCES_DIR_NAME);
+ + JAR_RESOURCES_DIR_NAME);
createDirectoryIfNecessary(srcDir);
createDirectoryIfNecessary(mainDir);
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPJarMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -47,12 +47,13 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPJarMojo extends AbstractWPMojo {
+public class WPJarMojo extends AbstractWPLoadDependencyMojo {
static public String EXTERNALIZE_PREFIX = "externalize-";
@Override
protected void init() throws Exception {
+ super.init();
// TODO
}
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -53,7 +53,7 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPRunMojo extends AbstractWPMojo {
+public class WPRunMojo extends AbstractWPLoadDependencyMojo {
private static final String DEPENDCY_TYPE_WAR = "war";
@@ -110,6 +110,7 @@
@Override
protected void init() throws Exception {
+ super.init();
// TODO
}
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-25 09:00:58 UTC (rev 1184)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPUpdateMojo.java 2011-08-26 08:56:14 UTC (rev 1185)
@@ -39,10 +39,11 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPUpdateMojo extends AbstractWPMojo {
+public class WPUpdateMojo extends AbstractWPLoadDependencyMojo {
@Override
protected void init() throws Exception {
+ super.init();
//TODO
}
Added: trunk/wp-maven-plugin/src/main/resources/log4j.properties
===================================================================
--- trunk/wp-maven-plugin/src/main/resources/log4j.properties (rev 0)
+++ trunk/wp-maven-plugin/src/main/resources/log4j.properties 2011-08-26 08:56:14 UTC (rev 1185)
@@ -0,0 +1,12 @@
+# Global logging configuration
+log4j.rootLogger=FATAL, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] (%F:%L) %M - %m%n
+
+# package level
+log4j.logger.org.nuiton.wikitty.publication=DEBUG
+#log4j.logger.org.nuiton.util.TimeLog=WARN
+log4j.logger.org.apache.struts2.dispatcher.mapper=DEBUG
1
0
r1184 - in trunk: wikitty-publication/src/main/java/org/nuiton/wikitty/publication wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action
by mfortun@users.nuiton.org 25 Aug '11
by mfortun@users.nuiton.org 25 Aug '11
25 Aug '11
Author: mfortun
Date: 2011-08-25 11:00:58 +0200 (Thu, 25 Aug 2011)
New Revision: 1184
Url: http://nuiton.org/repositories/revision/wikitty/1184
Log:
*move commit/update properties requirement/handling to synchronise class
*add method to wpContext
Modified:
trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/PublicationContext.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationSynchronize.java
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/PublicationContext.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/PublicationContext.java 2011-08-24 16:40:25 UTC (rev 1183)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/PublicationContext.java 2011-08-25 09:00:58 UTC (rev 1184)
@@ -33,6 +33,8 @@
List<String> getMandatoryArguments();
+ String getArgument(String name);
+
String getArgument(String name, String defaultValue);
String getContentType();
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-08-24 16:40:25 UTC (rev 1183)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationFileSystem.java 2011-08-25 09:00:58 UTC (rev 1184)
@@ -37,7 +37,6 @@
import org.nuiton.wikitty.WikittyUtil;
import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.entities.WikittyExtension;
-import org.nuiton.wikitty.entities.WikittyField;
import org.nuiton.wikitty.entities.WikittyImpl;
import org.nuiton.wikitty.entities.WikittyLabel;
import org.nuiton.wikitty.entities.WikittyLabelHelper;
@@ -126,11 +125,6 @@
static public String META_PREFIX_KEY_ID = "id.";
/**
- * The file name of the wikitty service property
- */
- static public String WIKITTY_FILE_SERVICE = "ws.properties";
-
- /**
* the file name of the property directory
*/
static public String PROPERTY_DIRECTORY = ".wp";
@@ -184,40 +178,7 @@
log.info("HomeDir:" + homeFile + "Label:" + label);
- File homeProperty = new File(homeFile.getAbsolutePath()
- + File.separator + PROPERTY_DIRECTORY);
- if (!homeProperty.exists()) {
- homeProperty.mkdir();
- }
-
- // write/update the "home property file"
- PropertiesExtended propertyWikittyService = getWikittyPublicationProperties(
- homeFile, WIKITTY_FILE_SERVICE);
-
- // the original label use to create if not exist
- if (!propertyWikittyService
- .containsKey(WikittyPublicationSynchronize.LABEL_KEY)) {
- log.debug("Writing home property label"
- + propertyWikittyService.getOrigin());
- propertyWikittyService.setProperty(
- WikittyPublicationSynchronize.LABEL_KEY, label);
- }
- // the service use to update or commit
- String uriService = app
- .getOption(WikittyPublicationSynchronize.WIKITTY_SERVICE_INTERLOCUTEUR);
- if (uriService != null) {
- log.debug("Writing home property service on:"
- + propertyWikittyService.getOrigin() + " uri" + uriService);
-
- propertyWikittyService
- .setProperty(
- WikittyPublicationSynchronize.WIKITTY_SERVICE_INTERLOCUTEUR,
- uriService);
- }
-
- propertyWikittyService.store();
-
recursion = true;
if (app.getOptions().containsKey(
WikittyPublicationSynchronize.IS_RECURSION_OPTION)) {
@@ -1114,49 +1075,4 @@
}
- /**
- * Use to search and return the home property that containt informations
- * about wikitty service use to synchronise a wikitty publication file
- * system
- *
- * @param start
- * the directory where starts the search
- * @return PropertiesExtended the home property
- * @throws IOException
- * if error while reading property file
- */
- static public File searchWikittyPublicationHomePropertie(File start)
- throws IOException {
-
- log.info("Search for home propertie from :" + start);
-
- if (start != null && start.exists() && start.isDirectory()) {
-
- // recursion, we search in the parents for the home property file
- // those which containt the wikitty service property withe the
- // adress of the interlocuteur
-
- File propertyDirectory = new File(start.getCanonicalPath()
- + File.separator + PROPERTY_DIRECTORY);
-
- if (propertyDirectory.exists()) {
- File propertie = new File(propertyDirectory.getCanonicalPath()
- + File.separator + WIKITTY_FILE_SERVICE);
- if (propertie.exists()) {
- return start;
- }
- }
-
- return searchWikittyPublicationHomePropertie(start.getParentFile());
- } else {
- if (start == null) {
- throw new IOException("Start cannot be null");
- }
- if (!start.exists()) {
- throw new IOException(start + " doen't exist");
- }
- throw new IOException(start + " is not a directory");
- }
- }
-
}
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationSynchronize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationSynchronize.java 2011-08-24 16:40:25 UTC (rev 1183)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/synchro/WikittyPublicationSynchronize.java 2011-08-25 09:00:58 UTC (rev 1184)
@@ -45,6 +45,7 @@
import org.nuiton.wikitty.search.Search;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -116,6 +117,21 @@
*/
static public String HESSIAN_URI_PREFIX = "hessian";
+
+ /**
+ * The file name of the wikitty service property
+ */
+ static public String WIKITTY_FILE_SERVICE = "ws.properties";
+
+ /*
+ * Two flag for commit/update mechanism
+ * if main true and flag commit false and if service is servive over
+ * file system, so write property to "know" the last service used to
+ * synchronise
+ */
+ static protected boolean MAIN_ENABLE=false;
+ static protected boolean FLAG_COMMIT_UPDATE=false;
+
static {
applicationConfig = new ApplicationConfig();
@@ -172,6 +188,8 @@
* @throws ArgumentsParserException
*/
static public void main(String[] args) throws Exception {
+ MAIN_ENABLE = true;
+
// parsing
applicationConfig.parse(args);
// execution
@@ -485,6 +503,9 @@
WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
.getKey(), WikittyPublicationFileSystem.class
.getName());
+
+
+ writeProperty(url);
} else if (uri.getScheme().equals(CAJO_URI_PREFIX)) {
result.setOption(
WikittyConfigOption.WIKITTY_WIKITTYSERVICE_COMPONENTS
@@ -542,7 +563,9 @@
static protected void commitUpdateDelegate(String label, boolean isCommit,
String... uriFileSystem) throws Exception {
-
+
+ FLAG_COMMIT_UPDATE = true;
+
File currentDir = new File(FileUtil.getCurrentDirectory()
.getAbsolutePath());
@@ -587,12 +610,11 @@
case 0:
// search for the home property dir that containt uri to the wikitty
// service
- File homePropertyDir = WikittyPublicationFileSystem
- .searchWikittyPublicationHomePropertie(currentDir);
+ File homePropertyDir = searchWikittyPublicationHomePropertie(currentDir);
homeProperty = WikittyPublicationFileSystem
.getWikittyPublicationProperties(homePropertyDir,
- WikittyPublicationFileSystem.WIKITTY_FILE_SERVICE);
+ WIKITTY_FILE_SERVICE);
// load the wikitty service uri (distant one)
wikittyServiceInter = homeProperty
@@ -631,7 +653,7 @@
File workingDir = new File(originUri.getPath());
homeProperty = WikittyPublicationFileSystem
.getWikittyPublicationProperties(workingDir,
- WikittyPublicationFileSystem.WIKITTY_FILE_SERVICE);
+ WIKITTY_FILE_SERVICE);
wikittyServiceInter = (String) homeProperty
.get(WIKITTY_SERVICE_INTERLOCUTEUR);
@@ -687,4 +709,113 @@
+ "''wp [update|commit] [--norecursion] [--delete|--existing] [URI file]''";
System.out.println(usage);
}
+
+
+ /**
+ * Called when syncrhonising with file system, used to store info about
+ * the "other" service used. Infos used when try to commit
+ * update from a service over file system
+ * @param label
+ */
+ protected static void writeProperty(String ur) {
+ try {
+ URI uri = new URI(ur);
+ String label = uri.getFragment();
+
+ File homeFile = new File(uri.getPath());
+
+
+ File homeProperty = new File(homeFile.getAbsolutePath()
+ + File.separator
+ + WikittyPublicationFileSystem.PROPERTY_DIRECTORY);
+
+ if (!homeProperty.exists()) {
+ homeProperty.mkdir();
+ }
+
+ // write/update the "home property file"
+ PropertiesExtended propertyWikittyService;
+
+ propertyWikittyService = WikittyPublicationFileSystem
+ .getWikittyPublicationProperties(homeFile,
+ WIKITTY_FILE_SERVICE);
+
+ // the original label use to create if not exist
+ if (!propertyWikittyService
+ .containsKey(WikittyPublicationSynchronize.LABEL_KEY)) {
+ log.debug("Writing home property label"
+ + propertyWikittyService.getOrigin());
+ propertyWikittyService.setProperty(
+ WikittyPublicationSynchronize.LABEL_KEY, label);
+ }
+ // the service use to update or commit
+ String uriService = applicationConfig
+ .getOption(WikittyPublicationSynchronize.WIKITTY_SERVICE_INTERLOCUTEUR);
+ if (uriService != null) {
+ log.debug("Writing home property service on:"
+ + propertyWikittyService.getOrigin() + " uri"
+ + uriService);
+
+ propertyWikittyService
+ .setProperty(
+ WikittyPublicationSynchronize.WIKITTY_SERVICE_INTERLOCUTEUR,
+ uriService);
+ }
+
+ propertyWikittyService.store();
+
+ } catch (Exception e) {
+ //TODO mfortun-2011-08-25
+ if (log.isErrorEnabled()) {
+ log.error("Error while writing properties for commit update", e);
+ }
+ }
+
+ }
+
+
+ /**
+ * Use to search and return the home property that containt informations
+ * about wikitty service use to synchronise a wikitty publication file
+ * system
+ *
+ * @param start
+ * the directory where starts the search
+ * @return PropertiesExtended the home property
+ * @throws IOException
+ * if error while reading property file
+ */
+ static public File searchWikittyPublicationHomePropertie(File start)
+ throws IOException {
+
+ log.info("Search for home propertie from :" + start);
+
+ if (start != null && start.exists() && start.isDirectory()) {
+
+ // recursion, we search in the parents for the home property file
+ // those which containt the wikitty service property withe the
+ // adress of the interlocuteur
+
+ File propertyDirectory = new File(start.getCanonicalPath()
+ + File.separator + WikittyPublicationFileSystem.PROPERTY_DIRECTORY);
+
+ if (propertyDirectory.exists()) {
+ File propertie = new File(propertyDirectory.getCanonicalPath()
+ + File.separator + WIKITTY_FILE_SERVICE);
+ if (propertie.exists()) {
+ return start;
+ }
+ }
+
+ return searchWikittyPublicationHomePropertie(start.getParentFile());
+ } else {
+ if (start == null) {
+ throw new IOException("Start cannot be null");
+ }
+ if (!start.exists()) {
+ throw new IOException(start + " doen't exist");
+ }
+ throw new IOException(start + " is not a directory");
+ }
+ }
}
Modified: trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
===================================================================
--- trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-24 16:40:25 UTC (rev 1183)
+++ trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-25 09:00:58 UTC (rev 1184)
@@ -495,4 +495,9 @@
return result;
}
+ @Override
+ public String getArgument(String name) {
+ return getArgument(name, StringUtils.EMPTY);
+ }
+
}
1
0
r1183 - in trunk: wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action
by mfortun@users.nuiton.org 24 Aug '11
by mfortun@users.nuiton.org 24 Aug '11
24 Aug '11
Author: mfortun
Date: 2011-08-24 18:40:25 +0200 (Wed, 24 Aug 2011)
New Revision: 1183
Url: http://nuiton.org/repositories/revision/wikitty/1183
Log:
*important correction for eval action, now overide the classloader to add jars extract from the service (in the case of evaluate script langage)
*add jars extract from the service to the compile classpath (in externalization and java evaluation
Modified:
trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/CompileHelper.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/CompileHelper.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/CompileHelper.java 2011-08-24 14:21:09 UTC (rev 1182)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/CompileHelper.java 2011-08-24 16:40:25 UTC (rev 1183)
@@ -76,11 +76,17 @@
* introspection <li>-10000 si une autre exception <li>sinon les
* valeurs retourné par le compilateur java
*/
- public static int compile(File rootSrc, File src, File dest, PrintWriter out) {
- int result = compile(rootSrc, Collections.singletonList(src), dest, out);
+ public static int compile(List<File> addToClassPath, File rootSrc, File src, File dest, PrintWriter out) {
+ int result = compile(addToClassPath, rootSrc, Collections.singletonList(src), dest, out);
return result;
}
+ public static int compile( File rootSrc, File src, File dest, PrintWriter out) {
+ int result = compile(null, rootSrc, Collections.singletonList(src), dest, out);
+ return result;
+ }
+
+
/**
* Methode permettant de compiler un ensemble de fichiers Java.
*
@@ -99,11 +105,14 @@
* introspection <li>-10000 si une autre exception <li>sinon les
* valeurs retourné par le compilateur java
*/
- public static int compile(File rootSrc, Collection<File> src, File dest,
+ public static int compile(List<File> addToClassPath, File rootSrc, Collection<File> src, File dest,
PrintWriter out) {
int result = -10000;
try {
List<File> classpath = new ArrayList<File>();
+ if (addToClassPath!=null){
+ classpath.addAll(addToClassPath);
+ }
classpath.add(rootSrc.getAbsoluteFile());
result = compile(classpath, src, dest, out);
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java 2011-08-24 14:21:09 UTC (rev 1182)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/JarUtil.java 2011-08-24 16:40:25 UTC (rev 1183)
@@ -38,6 +38,15 @@
*/
public class JarUtil {
+ public static FileFilter jarFilter = new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return (!pathname.isDirectory())&&pathname.getName().endsWith(".jar");
+
+ }
+ };
+
+
/** Class logger. */
private static Log log = LogFactory.getLog(JarUtil.class);
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-08-24 14:21:09 UTC (rev 1182)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyPublicationExternalize.java 2011-08-24 16:40:25 UTC (rev 1183)
@@ -3,9 +3,12 @@
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import java.util.jar.JarFile;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -45,6 +48,9 @@
static private Log log = LogFactory
.getLog(WikittyPublicationExternalize.class);
+
+ static public String JAR_CLASSPATH_DIR="jars";
+
static public String TEMPORARY_FILE_NAME = "tempBeforeJar";
static public String DEFAULT_JAR_NAME = "pub-externalized";
@@ -159,6 +165,9 @@
*
* metadata 18114-1811-181-18.version=1.0 18114-1811-181-18.exention=js
*/
+
+ List<File> classPathAdds = extractJarFromServiceForCompil(proxy);
+
for (Wikitty wikit : allWikittyOnFS) {
if (!wikit.hasExtension(WikittyLabel.EXT_WIKITTYLABEL)) {
// non usable wikitty
@@ -216,7 +225,7 @@
PrintWriter writer = new PrintWriter(System.out);
// compile
- CompileHelper.compile(tempDirectory, javaFile, classDirectory,
+ CompileHelper.compile(classPathAdds,tempDirectory, javaFile, classDirectory,
writer);
// write properties
@@ -281,6 +290,49 @@
* en jar et on va supprimer le dossier tempJar
*/
+
+ static protected List<File> extractJarFromServiceForCompil(WikittyProxy prox){
+ List<File> result = new LinkedList<File>();
+
+ // check for temporaryn dir
+ if (!FileUtils.getTempDirectory().exists()) {
+ FileUtils.getTempDirectory().mkdir();
+ }
+
+ Search wikittyPubDataJarCrit = Search.query().eq(
+ WikittyPubData.FQ_FIELD_WIKITTYPUBDATA_MIMETYPE,
+ MimeTypePubHelper.JAR_TYPE);
+
+ String jarRepoPath = FileUtils.getTempDirectory().getAbsolutePath()
+ + File.separator + JAR_CLASSPATH_DIR+"_"+WikittyPublicationSynchronize.class.getSimpleName();
+
+ File jarRepo = new File(jarRepoPath);
+ if (!jarRepo.exists()){
+ jarRepo.mkdir();
+ }
+
+ result.add(jarRepo);
+ PagedResult<Wikitty> jardatas = prox.findAllByCriteria(
+ wikittyPubDataJarCrit.criteria());
+
+ for (Wikitty w : jardatas) {
+ String name = WikittyPubDataHelper.getName(w);
+ byte[] content = WikittyPubDataHelper.getContent(w);
+ File tempJar = new File(jarRepo.getAbsolutePath()
+ + File.separator + name + ".jar");
+ try {
+ FileUtils.writeByteArrayToFile(tempJar, content);
+ result.add(tempJar);
+ } catch (IOException e) {
+ log.error("Error while writing jars for compile classpath",e);
+ // TODO Mfortun-2011-08-24- not really handled
+ }
+ }
+
+
+
+ return result;
+ }
}
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-08-24 14:21:09 UTC (rev 1182)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-08-24 16:40:25 UTC (rev 1183)
@@ -59,15 +59,6 @@
protected String dirLocation;
protected String MD5;
- protected FileFilter jarFilter = new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- return (!pathname.isDirectory())&&pathname.getName().endsWith(".jar");
-
- }
- };
-
-
protected Map<JarFile, WikittyPropertieIndex> index;
protected MimeTypePubHelper mimeHelper;
@@ -94,7 +85,7 @@
// initialise location
File jarLocation = new File(dirLocation);
//found jar
- File[] jarFiles = jarLocation.listFiles(jarFilter);
+ File[] jarFiles = jarLocation.listFiles(JarUtil.jarFilter);
// TODO mfortun-2011-08-18 BAD solution: need a notifier system
// to allow service to rebuild his index
Modified: trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
===================================================================
--- trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-24 14:21:09 UTC (rev 1182)
+++ trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-24 16:40:25 UTC (rev 1183)
@@ -29,6 +29,7 @@
import org.nuiton.wikitty.publication.entities.WikittyPubTextCompiledImpl;
import org.nuiton.wikitty.publication.entities.WikittyPubTextHelper;
import org.nuiton.wikitty.publication.externalize.CompileHelper;
+import org.nuiton.wikitty.publication.externalize.JarUtil;
import org.nuiton.wikitty.publication.externalize.WikittyPublicationClassLoader;
import org.nuiton.wikitty.search.Criteria;
import org.nuiton.wikitty.search.PagedResult;
@@ -46,6 +47,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -69,6 +71,7 @@
protected HttpServletRequest request;
protected InputStream inputStream;
protected WikittyPublicationClassLoader classloader;
+ protected List<File> classPathSup;
@Override
public void setServletResponse(HttpServletResponse arg0) {
@@ -90,13 +93,12 @@
File jarRepo;
File md5File;
- Search wikittyPubDataJarCrit = Search
- .query()
- .eq(WikittyPubData.FQ_FIELD_WIKITTYPUBDATA_MIMETYPE,
+ Search wikittyPubDataJarCrit = Search.query().eq(
+ WikittyPubData.FQ_FIELD_WIKITTYPUBDATA_MIMETYPE,
MimeTypePubHelper.JAR_TYPE);
String jarRepoPath = FileUtils.getTempDirectory().getAbsolutePath()
+ File.separator + JAR_TEMP_DIR_NAME;
-
+
// initialiser directory etc if context set
if (contextApps != null) {
// if application context is set sub dir
@@ -114,7 +116,7 @@
jarRepo.mkdir();
}
md5File.createNewFile();
-
+
String md5ref = FileUtil.readAsString(md5File);
PagedResult<Wikitty> jardatas = getWikittyProxy().findAllByCriteria(
@@ -138,10 +140,29 @@
}
- // initialize classLoader
+ File[] jarFiles = jarRepo.listFiles(JarUtil.jarFilter);
URL[] urls = new URL[1];
+ classPathSup = new LinkedList<File>();
+ classPathSup.add(jarRepo);
urls[0] = jarRepo.toURI().toURL();
+ if (jarFiles != null) {
+ urls = new URL[jarFiles.length + 1];
+ int i = 0;
+ urls[i] = jarRepo.toURI().toURL();
+ i++;
+ for (File fj : jarFiles) {
+ classPathSup.add(fj);
+ urls[i] = fj.toURI().toURL();
+ i++;
+ }
+ }
+
+ // initialize classLoader
+
classloader = new WikittyPublicationClassLoader(urls);
+ // REALLY IMPORTANT put the classloader with the jarloaded
+
+ Thread.currentThread().setContextClassLoader(classloader);
doAction(this, getMandatoryArguments());
@@ -211,20 +232,25 @@
File javaFile = new File(
javaWikittyFile.getAbsolutePath()
+ File.separator + name + ".java");
+ File clazzFile = new File(
+ javaWikittyFile.getAbsolutePath()
+ + File.separator + name + ".class");
if (javaFile.exists()) {
content = FileUtil.readAsString(javaFile);
}
if (content == null
|| !StringUtil.encodeMD5(javaContent).equals(
- StringUtil.encodeMD5(content))) {
+ StringUtil.encodeMD5(content))
+ || !clazzFile.exists()) {
javaFile.createNewFile();
FileUtil.writeString(javaFile, javaContent);
PrintWriter writer = new PrintWriter(System.out);
// compile
- CompileHelper.compile(javaWikittyFile, javaFile,
- javaWikittyFile, writer);
+ CompileHelper.compile(classPathSup,
+ javaWikittyFile, javaFile, javaWikittyFile,
+ writer);
}
File classFile = new File(
@@ -328,6 +354,7 @@
// TODO mfortun-2011-08-08 construire un class path avec
// des jar et les classes contenu dans wikitty publication
+
result = ScriptEvaluator.eval(classloader,
criteria.getName(), content, mimetype, bindings);
}
1
0
24 Aug '11
Author: mfortun
Date: 2011-08-24 16:21:09 +0200 (Wed, 24 Aug 2011)
New Revision: 1182
Url: http://nuiton.org/repositories/revision/wikitty/1182
Log:
remove cached from default publication properties
Modified:
trunk/wikitty-publication-ui/src/main/resources/wikitty-publication-ws-default.properties
Modified: trunk/wikitty-publication-ui/src/main/resources/wikitty-publication-ws-default.properties
===================================================================
--- trunk/wikitty-publication-ui/src/main/resources/wikitty-publication-ws-default.properties 2011-08-24 13:27:19 UTC (rev 1181)
+++ trunk/wikitty-publication-ui/src/main/resources/wikitty-publication-ws-default.properties 2011-08-24 14:21:09 UTC (rev 1182)
@@ -39,7 +39,6 @@
wikitty.WikittyService.components=org.nuiton.wikitty.services.WikittyServiceStorage,\
org.nuiton.wikitty.publication.WikittyPublicationFallbackService,\
org.nuiton.wikitty.services.WikittyServiceNotifier,\
-org.nuiton.wikitty.services.WikittyServiceCached,\
org.nuiton.wikitty.services.WikittyServiceSecurity,\
org.nuiton.wikitty.services.WikittyServiceAccessStat,\
org.nuiton.wikitty.services.WikittyServiceCajoServer
1
0
r1181 - in trunk: wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin
by mfortun@users.nuiton.org 24 Aug '11
by mfortun@users.nuiton.org 24 Aug '11
24 Aug '11
Author: mfortun
Date: 2011-08-24 15:27:19 +0200 (Wed, 24 Aug 2011)
New Revision: 1181
Url: http://nuiton.org/repositories/revision/wikitty/1181
Log:
*corrections, now version for wikitty publication is a parametter for plugin
*correct condition for jarclass path within evaluation
Modified:
trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java
Modified: trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java
===================================================================
--- trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-22 07:58:30 UTC (rev 1180)
+++ trunk/wikitty-publication-ui/src/main/java/org/nuiton/wikitty/publication/ui/action/PublicationActionEval.java 2011-08-24 13:27:19 UTC (rev 1181)
@@ -126,7 +126,7 @@
}
sumMd5 = StringUtil.encodeMD5(sumMd5);
- if (sumMd5.equals(md5ref)) {
+ if (!sumMd5.equals(md5ref)) {
FileUtil.writeString(md5File, sumMd5);
for (Wikitty w : jardatas) {
String name = WikittyPubDataHelper.getName(w);
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-22 07:58:30 UTC (rev 1180)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java 2011-08-24 13:27:19 UTC (rev 1181)
@@ -79,7 +79,15 @@
private ArtifactFactory artifactFactory;
+ /**
+ * URL of server to use to log into server.
+ *
+ * @parameter expression="${publicationVersion}"
+ * @required
+ */
+ protected String publicationVersion;
+
/**
* Local Repository.
*
@@ -168,7 +176,7 @@
// metadata rather than an artifact in 2.1?
Artifact artifact = artifactFactory.createArtifactWithClassifier(
PUBLICATION_WAR_GROUP_ID, PUBLICATION_WAR_ARTIFACT_ID,
- project.getVersion(), DEPENDCY_TYPE_WAR, StringUtils.EMPTY);
+ publicationVersion, DEPENDCY_TYPE_WAR, StringUtils.EMPTY);
// TODO mfortun-2011-08-18 change for version
try {
artifactResolver.resolve(artifact, remoteRepositories, localRepository);
1
0
r1180 - in trunk: wikitty-publication/src/main/java/org/nuiton/wikitty/publication wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin
by mfortun@users.nuiton.org 22 Aug '11
by mfortun@users.nuiton.org 22 Aug '11
22 Aug '11
Author: mfortun
Date: 2011-08-22 09:58:30 +0200 (Mon, 22 Aug 2011)
New Revision: 1180
Url: http://nuiton.org/repositories/revision/wikitty/1180
Log:
*correct mavenplugin deploy jar
*change variable result to wp_result
*wikitty service on jar correct init when there no jar in his directory
Modified:
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/CodeDecorator.java
trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.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/WPRunMojo.java
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/CodeDecorator.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/CodeDecorator.java 2011-08-19 16:31:12 UTC (rev 1179)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/CodeDecorator.java 2011-08-22 07:58:30 UTC (rev 1180)
@@ -43,8 +43,8 @@
static {
defaultFilterOption = new FilterOption();
- defaultFilterOption.setOpeningTemplate("var result=\"");
- defaultFilterOption.setWriteString("result");
+ defaultFilterOption.setOpeningTemplate("var wp_result=\"");
+ defaultFilterOption.setWriteString("wp_result");
defaultFilterOption.setStringDelim("\"");
defaultFilterOption.setConcatChar("+");
defaultFilterOption.setEndingCar(";");
Modified: trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java
===================================================================
--- trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-08-19 16:31:12 UTC (rev 1179)
+++ trunk/wikitty-publication/src/main/java/org/nuiton/wikitty/publication/externalize/WikittyServiceJarLoader.java 2011-08-22 07:58:30 UTC (rev 1180)
@@ -84,7 +84,8 @@
public WikittyServiceJarLoader(ApplicationConfig config) {
mimeHelper = new MimeTypePubHelper();
dirLocation = config.getOption(JAR_LOCATION_KEY);
- MD5 = StringUtils.EMPTY;
+ index = new HashMap<JarFile, WikittyPropertieIndex>();
+ MD5 = StringUtil.encodeMD5(StringUtils.EMPTY);
constructIndex();
}
@@ -98,8 +99,10 @@
// TODO mfortun-2011-08-18 BAD solution: need a notifier system
// to allow service to rebuild his index
String sumMd5 = StringUtils.EMPTY;
- for (File jf : jarFiles){
- sumMd5+=jf.getAbsolutePath();
+ if (jarFiles!=null){
+ for (File jf : jarFiles){
+ sumMd5+=jf.getAbsolutePath();
+ }
}
sumMd5 = StringUtil.encodeMD5(sumMd5);
// check if md5 is equal to the last reindaxtion
Modified: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java
===================================================================
--- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java 2011-08-19 16:31:12 UTC (rev 1179)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/AbstractWPMojo.java 2011-08-22 07:58:30 UTC (rev 1180)
@@ -52,7 +52,6 @@
* A flag to activate verbose mode.
*
* @parameter expression="${wp.verbose}" default-value="${maven.verbose}"
- * @since 1.2.5
*/
protected boolean verbose;
@@ -61,7 +60,6 @@
*
* @parameter expression="${wp.applicationName}"
* @required
- * @since 1.2.5
*/
protected String applicationName;
@@ -70,7 +68,6 @@
*
* @parameter expression="${wp.wikittyServiceUrl}"
* @required
- * @since 1.2.5
*/
protected String wikittyServiceUrl;
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-19 16:31:12 UTC (rev 1179)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-22 07:58:30 UTC (rev 1180)
@@ -112,7 +112,6 @@
* Defaults to "true".
*
* @parameter expression="${maven.site.chmod}" default-value="true"
- * @since 2.1
*/
protected boolean chmod;
@@ -121,7 +120,6 @@
* Defaults to "g+w,a+rX".
*
* @parameter expression="${maven.site.chmod.mode}" default-value="g+w,a+rX"
- * @since 2.1
*/
protected String chmodMode;
@@ -130,7 +128,6 @@
* Defaults to "-Rf".
*
* @parameter expression="${maven.site.chmod.options}" default-value="-Rf"
- * @since 2.1
*/
protected String chmodOptions;
@@ -150,7 +147,6 @@
* @parameter expression="${session}"
* @required
* @readonly
- * @since 3.0-beta-2
*/
protected MavenSession mavenSession;
@@ -173,16 +169,26 @@
protected Wagon wagon;
+ /**
+ * file to deploy
+ *
+ * @parameter expression="${fileToDeploy}"
+ * @required
+ */
protected File fileToDeploy;
@Override
protected void init() throws Exception {
- String file = getProject().getBuild().getDirectory();
- file+=File.separator+WPJarMojo.EXTERNALIZE_PREFIX+applicationName+".jar";
- fileToDeploy= new File(file);
+
+ if (fileToDeploy==null || !fileToDeploy.exists()){
+ String file = getProject().getBuild().getDirectory();
+ file+=File.separator+WPJarMojo.EXTERNALIZE_PREFIX+applicationName+".jar";
+ fileToDeploy= new File(file);
+ }
+
repository = new Repository(
serverId,
serverUrl
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-19 16:31:12 UTC (rev 1179)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPRunMojo.java 2011-08-22 07:58:30 UTC (rev 1180)
@@ -86,7 +86,6 @@
* @parameter expression="${localRepository}"
* @required
* @readonly
- * @since 1.0.0
*/
protected ArtifactRepository localRepository;
@@ -96,7 +95,6 @@
* @parameter expression="${project.remoteArtifactRepositories}"
* @required
* @readonly
- * @since 1.0.0
*/
protected List remoteRepositories;
1
0
Author: tchemit
Date: 2011-08-19 18:31:12 +0200 (Fri, 19 Aug 2011)
New Revision: 1179
Url: http://nuiton.org/repositories/revision/wikitty/1179
Log:
updates to mavenpom4redmine 3.0.2
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-08-19 08:53:55 UTC (rev 1178)
+++ trunk/pom.xml 2011-08-19 16:31:12 UTC (rev 1179)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.0.1</version>
+ <version>3.0.2</version>
</parent>
<!-- ************************************************************* -->
1
0
r1178 - trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin
by mfortun@users.nuiton.org 19 Aug '11
by mfortun@users.nuiton.org 19 Aug '11
19 Aug '11
Author: mfortun
Date: 2011-08-19 10:53:55 +0200 (Fri, 19 Aug 2011)
New Revision: 1178
Url: http://nuiton.org/repositories/revision/wikitty/1178
Log:
*little change in deploy-jar goal
Modified:
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java
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-19 08:22:52 UTC (rev 1177)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-19 08:53:55 UTC (rev 1178)
@@ -106,13 +106,6 @@
*/
protected String serverUrl;
- /**
- * File to deploy.
- *
- * @parameter expression="${fileToDeploy}"
- * @required
- */
- protected File fileToDeploy;
/**
* Whether to run the "chmod" command on the remote site after the deploy.
@@ -121,7 +114,7 @@
* @parameter expression="${maven.site.chmod}" default-value="true"
* @since 2.1
*/
- private boolean chmod;
+ protected boolean chmod;
/**
* The mode used by the "chmod" command. Only used if chmod = true.
@@ -130,7 +123,7 @@
* @parameter expression="${maven.site.chmod.mode}" default-value="g+w,a+rX"
* @since 2.1
*/
- private String chmodMode;
+ protected String chmodMode;
/**
* The options used by the "chmod" command. Only used if chmod = true.
@@ -139,10 +132,10 @@
* @parameter expression="${maven.site.chmod.options}" default-value="-Rf"
* @since 2.1
*/
- private String chmodOptions;
+ protected String chmodOptions;
/** @component */
- private WagonManager wagonManager;
+ protected WagonManager wagonManager;
/**
* The current user system settings for use in Maven.
@@ -151,7 +144,7 @@
* @required
* @readonly
*/
- private Settings settings;
+ protected Settings settings;
/**
* @parameter expression="${session}"
@@ -161,9 +154,9 @@
*/
protected MavenSession mavenSession;
- private PlexusContainer container;
+ protected PlexusContainer container;
- private Repository repository;
+ protected Repository repository;
/**
* All available wagons.
@@ -174,15 +167,22 @@
protected Map<String, Wagon> wagons;
/** @component */
- private SettingsDecrypter settingsDecrypter;
+ protected SettingsDecrypter settingsDecrypter;
- private ProxyInfo proxyInfo;
+ protected ProxyInfo proxyInfo;
- private Wagon wagon;
+ protected Wagon wagon;
+ protected File fileToDeploy;
+
@Override
protected void init() throws Exception {
+
+ String file = getProject().getBuild().getDirectory();
+ file+=File.separator+WPJarMojo.EXTERNALIZE_PREFIX+applicationName+".jar";
+ fileToDeploy= new File(file);
+
repository = new Repository(
serverId,
serverUrl
@@ -202,18 +202,14 @@
wagon = getWagon(repository, wagonManager);
- try {
- configureWagon(wagon, repository.getId(), settings, container, getLog());
- } catch (TransferFailedException e) {
- throw new MojoExecutionException("Unable to configure Wagon: '" + repository.getProtocol() + "'", e);
- }
-
}
@Override
protected void doAction() throws Exception {
+
+
if (getLog().isDebugEnabled()) {
getLog().debug("Deploying to '" + repository.getUrl()
+ "',\n Using credentials from server id '" + repository.getId() + "'");
@@ -221,6 +217,9 @@
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()));
1
0
r1177 - in trunk/wp-maven-plugin: . src src/it src/it/deploy-jar src/it/deploy-jar/file src/main/java/org/nuiton/wikitty/plugin
by mfortun@users.nuiton.org 19 Aug '11
by mfortun@users.nuiton.org 19 Aug '11
19 Aug '11
Author: mfortun
Date: 2011-08-19 10:22:52 +0200 (Fri, 19 Aug 2011)
New Revision: 1177
Url: http://nuiton.org/repositories/revision/wikitty/1177
Log:
*deploy jar completed, thanks to tchemit
Added:
trunk/wp-maven-plugin/src/it/
trunk/wp-maven-plugin/src/it/deploy-jar/
trunk/wp-maven-plugin/src/it/deploy-jar/file/
trunk/wp-maven-plugin/src/it/deploy-jar/file/invoker.properties
trunk/wp-maven-plugin/src/it/deploy-jar/file/pom.xml
trunk/wp-maven-plugin/src/it/deploy-jar/file/verify.groovy
trunk/wp-maven-plugin/src/it/settings.xml
Removed:
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/DeployUtil.java
Modified:
trunk/wp-maven-plugin/pom.xml
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java
Modified: trunk/wp-maven-plugin/pom.xml
===================================================================
--- trunk/wp-maven-plugin/pom.xml 2011-08-18 16:20:39 UTC (rev 1176)
+++ trunk/wp-maven-plugin/pom.xml 2011-08-19 08:22:52 UTC (rev 1177)
@@ -188,8 +188,8 @@
<id>run-its</id>
<activation>
<property>
- <name>performRelease</name>
- <value>true</value>
+ <name>maven.test.skip</name>
+ <value>!true</value>
</property>
</activation>
<build>
@@ -199,8 +199,12 @@
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<postBuildHookScript>verify</postBuildHookScript>
- <localRepositoryPath>${basedir}/target/local-repo
+ <localRepositoryPath>
+ ${basedir}/target/local-repo
</localRepositoryPath>
+ <pomIncludes>
+ <include>deploy-jar/*/pom.xml</include>
+ </pomIncludes>
<settingsFile>src/it/settings.xml</settingsFile>
<cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
<debug>${maven.verbose}</debug>
Added: trunk/wp-maven-plugin/src/it/deploy-jar/file/invoker.properties
===================================================================
--- trunk/wp-maven-plugin/src/it/deploy-jar/file/invoker.properties (rev 0)
+++ trunk/wp-maven-plugin/src/it/deploy-jar/file/invoker.properties 2011-08-19 08:22:52 UTC (rev 1177)
@@ -0,0 +1,7 @@
+
+# A comma or space separated list of goals/phases to execute, may
+# specify an empty list to execute the default goal of the IT project
+invoker.goals=clean verify
+
+# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+invoker.failureBehavior=fail-at-end
Added: trunk/wp-maven-plugin/src/it/deploy-jar/file/pom.xml
===================================================================
--- trunk/wp-maven-plugin/src/it/deploy-jar/file/pom.xml (rev 0)
+++ trunk/wp-maven-plugin/src/it/deploy-jar/file/pom.xml 2011-08-19 08:22:52 UTC (rev 1177)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.nuiton.wikitty.plugin.test</groupId>
+ <artifactId>deploy-jar-file</artifactId>
+ <version>1.0</version>
+
+ <properties>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ </properties>
+
+ <build>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wp-maven-plugin</artifactId>
+ <version>@pom.version@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.wikitty</groupId>
+ <artifactId>wp-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>deploy-jar</goal>
+ </goals>
+ <phase>verify</phase>
+ <configuration>
+ <applicationName>test</applicationName>
+ <wikittyServiceUrl>?</wikittyServiceUrl>
+ <serverId>serverFile</serverId>
+ <serverUrl>file://${basedir}/target/remote</serverUrl>
+ <fileToDeploy>
+ ${basedir}/target/${project.artifactId}-${project.version}.jar
+ </fileToDeploy>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
+
Added: trunk/wp-maven-plugin/src/it/deploy-jar/file/verify.groovy
===================================================================
--- trunk/wp-maven-plugin/src/it/deploy-jar/file/verify.groovy (rev 0)
+++ trunk/wp-maven-plugin/src/it/deploy-jar/file/verify.groovy 2011-08-19 08:22:52 UTC (rev 1177)
@@ -0,0 +1,6 @@
+
+
+file = new File(basedir, 'target/remote/deploy-jar-file-1.0.jar');
+assert file.exists();
+
+return true;
Added: trunk/wp-maven-plugin/src/it/settings.xml
===================================================================
--- trunk/wp-maven-plugin/src/it/settings.xml (rev 0)
+++ trunk/wp-maven-plugin/src/it/settings.xml 2011-08-19 08:22:52 UTC (rev 1177)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+
+<settings>
+
+ <servers>
+ <server>
+ <id>serverFile</id>
+ <username>tony</username>
+ </server>
+ </servers>
+
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+
+ <pluginGroups>
+ <pluginGroup>org.codehaus.mojo</pluginGroup>
+ </pluginGroups>
+</settings>
Deleted: trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/DeployUtil.java
===================================================================
--- trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/DeployUtil.java 2011-08-18 16:20:39 UTC (rev 1176)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/DeployUtil.java 2011-08-19 08:22:52 UTC (rev 1177)
@@ -1,811 +0,0 @@
-package org.nuiton.wikitty.plugin;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.execution.MavenExecutionRequest;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Site;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.settings.Proxy;
-import org.apache.maven.settings.Server;
-import org.apache.maven.settings.Settings;
-import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
-import org.apache.maven.settings.crypto.SettingsDecrypter;
-import org.apache.maven.settings.crypto.SettingsDecryptionResult;
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.CommandExecutor;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.configurator.ComponentConfigurator;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-
-
-public class DeployUtil {
- /* *//**
- * Directory containing the generated project sites and report distributions.
- *
- * @parameter alias="outputDirectory" expression="${project.reporting.outputDirectory}"
- * @required
- *//*
- private File inputDirectory;
-
- *//**
- * Whether to run the "chmod" command on the remote site after the deploy.
- * Defaults to "true".
- *
- * @parameter expression="${maven.site.chmod}" default-value="true"
- * @since 2.1
- *//*
- private boolean chmod;
-
- *//**
- * 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"
- * @since 2.1
- *//*
- private String chmodMode;
-
- *//**
- * The options used by the "chmod" command. Only used if chmod = true.
- * Defaults to "-Rf".
- *
- * @parameter expression="${maven.site.chmod.options}" default-value="-Rf"
- * @since 2.1
- *//*
- private String chmodOptions;
-
- *//**
- * Set this to 'true' to skip site deployment.
- *
- * @parameter expression="${maven.site.deploy.skip}" default-value="false"
- * @since 3.0
- *//*
- private boolean skipDeploy;
-
- *//**
- * @component
- *//*
- private WagonManager wagonManager;
-
- *//**
- * The current user system settings for use in Maven.
- *
- * @parameter expression="${settings}"
- * @required
- * @readonly
- *//*
- private Settings settings;
-
- *//**
- * @parameter expression="${session}"
- * @required
- * @readonly
- * @since 3.0-beta-2
- *//*
- protected MavenSession mavenSession;
-
- private PlexusContainer container;
-
- private String deployRepositoryID;
-
- private String deployRepositoryUrl;
-
- private Log log;
-
- *//**
- * The String "staging/".
- *//*
- protected static final String DEFAULT_STAGING_DIRECTORY = "staging/";
-
- *//** {@inheritDoc} *//*
- public void execute()
- throws MojoExecutionException
- {
- if ( skipDeploy )
- {
- getLog().info( "maven.site.deploy.skip = true: Skipping site deployment" );
- return;
- }
-
- deployTo( new org.apache.maven.plugins.site.wagon.repository.Repository(
- getDeployRepositoryID(),
- appendSlash( getDeployRepositoryURL() ) ) );
- }
-
- public Log getLog() {
- return log;
-
- }
-
- *//**
- * Make sure the given url ends with a slash.
- *
- * @param url a String.
- *
- * @return if url already ends with '/' it is returned unchanged,
- * otherwise a '/' character is appended.
- *//*
- protected static String appendSlash( final String url )
- {
- if ( url.endsWith( "/" ) )
- {
- return url;
- }
- else
- {
- return url + "/";
- }
- }
-
- *//**
- * Specifies the id to look up credential settings.
- *
- * @return the id to look up credentials for the deploy. Not null.
- *
- * @throws MojoExecutionException
- * if the ID cannot be determined
- *//*
- protected String getDeployRepositoryID()
- throws MojoExecutionException{
- return deployRepositoryID;
- }
-
- *//**
- * Specifies the target URL for the deploy.
- * This should be the top-level URL, ie above modules and locale sub-directories.
- *
- * @return the url to deploy to. Not null.
- *
- * @throws MojoExecutionException
- * if the URL cannot be constructed
- *//*
- protected String getDeployRepositoryURL()
- throws MojoExecutionException{
- return deployRepositoryUrl;
- }
-
- *//**
- * Find the relative path between the distribution URLs of the top parent and the current project.
- *
- * @return the relative path or "./" if the two URLs are the same.
- *
- * @throws MojoExecutionException
- *//*
- private String getDeployModuleDirectory()
- throws MojoExecutionException
- {
- String relative = siteTool.getRelativePath( getSite( project ).getUrl(),
- getRootSite( project ).getUrl() );
-
- // SiteTool.getRelativePath() uses File.separatorChar,
- // so we need to convert '\' to '/' in order for the URL to be valid for Windows users
- relative = relative.replace( '\\', '/' );
-
- return ( "".equals( relative ) ) ? "./" : relative;
- }
-
- *//**
- * Use wagon to deploy the generated site to a given repository.
- *
- * @param repository the repository to deply to.
- * This needs to contain a valid, non-null {@link Repository#getId() id}
- * to look up credentials for the deploy, and a valid, non-null
- * {@link Repository#getUrl() scm url} to deploy to.
- *
- * @throws MojoExecutionException if the deploy fails.
- *//*
- private void deployTo( final Repository repository )
- throws MojoExecutionException
- {
- if ( !inputDirectory.exists() )
- {
- throw new MojoExecutionException( "The site does not exist, please run site:site first" );
- }
-
- if ( getLog().isDebugEnabled() )
- {
- getLog().debug( "Deploying to '" + repository.getUrl()
- + "',\n Using credentials from server id '" + repository.getId() + "'" );
- }
-
- deploy( inputDirectory, repository );
- }
-
- private void deploy( final File directory, final Repository repository )
- throws MojoExecutionException
- {
- // TODO: work on moving this into the deployer like the other deploy methods
- final Wagon wagon = getWagon( repository, wagonManager );
-
- try
- {
- configureWagon( wagon, repository.getId(), settings, container, getLog() );
- }
- catch ( TransferFailedException e )
- {
- throw new MojoExecutionException( "Unable to configure Wagon: '" + repository.getProtocol() + "'", e );
- }
-
- try
- {
- final ProxyInfo proxyInfo;
- if ( !isMaven3OrMore() )
- {
- proxyInfo = getProxyInfo( repository, wagonManager );
- }
- else
- {
- try
- {
- SettingsDecrypter settingsDecrypter = container.lookup( SettingsDecrypter.class );
-
- proxyInfo = getProxy( repository, settingsDecrypter );
- }
- catch ( ComponentLookupException cle )
- {
- throw new MojoExecutionException( "Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle );
- }
- }
-
- push( directory, repository, wagon, proxyInfo, siteTool.getAvailableLocales( locales ),
- getDeployModuleDirectory() );
-
- if ( chmod )
- {
- chmod( wagon, repository, chmodOptions, chmodMode );
- }
- }
- finally
- {
- try
- {
- wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- getLog().error( "Error disconnecting wagon - ignored", e );
- }
- }
- }
-
- *//**
- * Find the build directory of the top level project in the reactor.
- * If no top level project is found, the build directory of the current project is returned.
- *
- * @return the build directory of the top level project.
- *//*
- protected File getTopLevelBuildDirectory()
- {
- // Find the top level project in the reactor
- final MavenProject topLevelProject = getTopLevelProject( reactorProjects );
-
- // Use the top level project's build directory if there is one, otherwise use this project's build directory
- final File buildDirectory;
-
- if ( topLevelProject == null )
- {
- getLog().debug( "No top level project found in the reactor, using the current project." );
-
- buildDirectory = new File( project.getBuild().getDirectory() );
- }
- else
- {
- getLog().debug( "Using the top level project found in the reactor." );
-
- buildDirectory = new File( topLevelProject.getBuild().getDirectory() );
- }
-
- return buildDirectory;
- }
-
- private Wagon getWagon( final Repository repository, final WagonManager manager )
- throws MojoExecutionException
- {
- final 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"
- + " Protocols may be added through wagon providers.\n"
- + " For more information, see "
- + "http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-pr…";
-
- getLog().error( longMessage );
-
- throw new MojoExecutionException( shortMessage );
- }
- catch ( TransferFailedException 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" );
- }
-
- return wagon;
- }
-
- private String getSupportedProtocols()
- {
- try
- {
- Set<String> protocols = container.lookupMap( Wagon.class ).keySet();
-
- return StringUtils.join( protocols.iterator(), ", " );
- }
- catch ( ComponentLookupException e )
- {
- // in the unexpected case there is a problem when instantiating a wagon provider
- getLog().error( e );
- }
- return "";
- }
-
- private void push( final File inputDirectory, final Repository repository, final Wagon wagon,
- final ProxyInfo proxyInfo, final List<Locale> localesList, final String relativeDir )
- throws MojoExecutionException
- {
- AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo( repository.getId() );
- getLog().debug( "authenticationInfo with id '" + repository.getId() + "': "
- + ( ( authenticationInfo == null ) ? "-" : authenticationInfo.getUserName() ) );
-
- try
- {
- Debug debug = new Debug();
-
- wagon.addSessionListener( debug );
-
- wagon.addTransferListener( debug );
-
- if ( proxyInfo != null )
- {
- getLog().debug( "connect with proxyInfo" );
- wagon.connect( repository, authenticationInfo, proxyInfo );
- }
- else if ( proxyInfo == null && authenticationInfo != null )
- {
- getLog().debug( "connect with authenticationInfo and without proxyInfo" );
- wagon.connect( repository, authenticationInfo );
- }
- else
- {
- getLog().debug( "connect without authenticationInfo and without proxyInfo" );
- wagon.connect( repository );
- }
-
- getLog().info( "Pushing " + inputDirectory );
-
- // Default is first in the list
- final String defaultLocale = localesList.get( 0 ).getLanguage();
-
- for ( Locale locale : localesList )
- {
- if ( locale.getLanguage().equals( defaultLocale ) )
- {
- // TODO: this also uploads the non-default locales,
- // is there a way to exclude directories in wagon?
- getLog().info( " >>> to " + repository.getUrl() + relativeDir );
-
- wagon.putDirectory( inputDirectory, relativeDir );
- }
- else
- {
- getLog().info( " >>> to " + repository.getUrl() + locale.getLanguage() + "/" + relativeDir );
-
- wagon.putDirectory( new File( inputDirectory, locale.getLanguage() ),
- locale.getLanguage() + "/" + relativeDir );
- }
- }
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( TransferFailedException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( AuthorizationException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( ConnectionException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- catch ( AuthenticationException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- }
-
- private static void chmod( final Wagon wagon, final Repository repository, final String chmodOptions,
- final String chmodMode )
- throws MojoExecutionException
- {
- try
- {
- if ( wagon instanceof CommandExecutor )
- {
- CommandExecutor exec = (CommandExecutor) wagon;
- exec.executeCommand( "chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir() );
- }
- // else ? silently ignore, FileWagon is not a CommandExecutor!
- }
- catch ( CommandExecutionException e )
- {
- throw new MojoExecutionException( "Error uploading site", e );
- }
- }
-
- *//**
- * <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>.
- * </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"
- * </p>
- * <p>
- * Defensively support for comma (",") and semi colon (";") in addition to pipe ("|") as separator.
- * </p>
- *
- * @param repository the Repository to extract the ProxyInfo from.
- * @param wagonManager the WagonManager used to connect to the Repository.
- * @return a ProxyInfo object instantiated or <code>null</code> if no matching proxy is found
- *//*
- public static ProxyInfo getProxyInfo( Repository repository, WagonManager wagonManager )
- {
- ProxyInfo proxyInfo = wagonManager.getProxy( repository.getProtocol() );
-
- if ( proxyInfo == null )
- {
- return null;
- }
-
- String host = repository.getHost();
- String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
- 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
- final 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 ) )
- {
- return null;
- }
- // *suffix
- if ( StringUtils.isEmpty( nonProxyHostPrefix )
- && StringUtils.isNotEmpty( nonProxyHostSuffix ) && host.endsWith( nonProxyHostSuffix ) )
- {
- return null;
- }
- // prefix*suffix
- if ( StringUtils.isNotEmpty( nonProxyHostPrefix ) && host.startsWith( nonProxyHostPrefix )
- && StringUtils.isNotEmpty( nonProxyHostSuffix ) && host.endsWith( nonProxyHostSuffix ) )
- {
- return null;
- }
- }
- else if ( host.equals( nonProxyHost ) )
- {
- return null;
- }
- }
- return proxyInfo;
- }
-
- *//**
- * Get proxy information for Maven 3.
- *
- * @param repository
- * @param log
- * @param mavenSession
- * @param settingsDecrypter
- * @return
- *//*
- private ProxyInfo getProxy( Repository repository, SettingsDecrypter settingsDecrypter )
- {
- String protocol = repository.getProtocol();
- String url = repository.getUrl();
-
- getLog().debug( "repository protocol " + protocol );
-
- String originalProtocol = protocol;
- // olamy: hackish here protocol (wagon hint in fact !) is dav
- // 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:" ) )
- {
- 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 );
- }
- catch ( MalformedURLException e )
- {
- getLog().warn( "fail to build URL with " + url );
- }
-
- }
- }
- else
- {
- getLog().debug( "getProxy 'protocol': " + protocol );
- }
- if ( mavenSession != null && protocol != null )
- {
- MavenExecutionRequest request = mavenSession.getRequest();
-
- if ( request != null )
- {
- List<Proxy> proxies = request.getProxies();
-
- if ( proxies != null )
- {
- for ( Proxy proxy : proxies )
- {
- if ( proxy.isActive()
- && ( protocol.equalsIgnoreCase( proxy.getProtocol() ) || originalProtocol
- .equalsIgnoreCase( proxy.getProtocol() ) ) )
- {
- SettingsDecryptionResult result = settingsDecrypter
- .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() );
- proxyInfo.setPort( proxy.getPort() );
- proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() );
- proxyInfo.setUserName( proxy.getUsername() );
- proxyInfo.setPassword( proxy.getPassword() );
-
- getLog().debug( "found proxyInfo "
- + ( proxyInfo == null ? "null" : "host:port " + proxyInfo.getHost()
- + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName() ) );
-
- return proxyInfo;
- }
- }
- }
- }
- }
- getLog().debug( "getProxy 'protocol': " + protocol + " no ProxyInfo found");
- return null;
- }
-
- *//**
- * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml )
- *
- * @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5.
- * @param wagon
- * @param repositoryId
- * @param settings
- * @param container
- * @param log
- * @throws WagonConfigurationException
- *//*
- private static void configureWagon( Wagon wagon, String repositoryId, Settings settings, PlexusContainer container,
- Log log )
- throws TransferFailedException
- {
- log.debug( " configureWagon " );
-
- // MSITE-25: Make sure that the server settings are inserted
- for ( int i = 0; i < settings.getServers().size(); i++ )
- {
- Server server = settings.getServers().get( i );
- String id = server.getId();
-
- log.debug( "configureWagon server " + id );
-
- if ( id != null && id.equals( repositoryId ) )
- {
- if ( server.getConfiguration() != null )
- {
- final PlexusConfiguration plexusConf =
- new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration() );
-
- ComponentConfigurator componentConfigurator = null;
- try
- {
- componentConfigurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, "basic" );
- componentConfigurator.configureComponent( wagon, plexusConf, container.getContainerRealm() );
- }
- catch ( final ComponentLookupException 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 );
- }
- finally
- {
- if ( componentConfigurator != null )
- {
- try
- {
- container.release( componentConfigurator );
- }
- catch ( ComponentLifecycleException e )
- {
- log.error( "Problem releasing configurator - ignoring: " + e.getMessage() );
- }
- }
- }
- }
- }
- }
- }
-
- *//** {@inheritDoc} *//*
- public void contextualize( Context context )
- throws ContextException
- {
- container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
- }
-
- *//**
- * Find the top level parent in the reactor, i.e. the execution root.
- *
- * @param reactorProjects The projects in the reactor. May be null in which case null is returned.
- *
- * @return The top level project in the reactor, or <code>null</code> if none can be found
- *//*
- private static MavenProject getTopLevelProject( List<MavenProject> reactorProjects )
- {
- if ( reactorProjects == null )
- {
- return null;
- }
-
- for ( MavenProject reactorProject : reactorProjects )
- {
- if ( reactorProject.isExecutionRoot() )
- {
- return reactorProject;
- }
- }
-
- return null;
- }
-
- *//**
- * Extract the distributionManagment site from the given MavenProject.
- *
- * @param project the MavenProject. Not null.
- *
- * @return the project site. Not null.
- * Also site.getUrl() and site.getId() are guaranteed to be not null.
- *
- * @throws MojoExecutionException if any of the site info is missing.
- *//*
- protected static Site getSite( final MavenProject project )
- throws MojoExecutionException
- {
- final String name = project.getName() + " ("
- + project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion() + ")";
-
- final DistributionManagement distributionManagement = project.getDistributionManagement();
-
- if ( distributionManagement == null )
- {
- throw new MojoExecutionException( "Missing distribution management in project " + name );
- }
-
- final Site site = distributionManagement.getSite();
-
- if ( site == null )
- {
- throw new MojoExecutionException(
- "Missing site information in the distribution management of the project " + name );
- }
-
- if ( site.getUrl() == null || site.getId() == null )
- {
- throw new MojoExecutionException( "Missing site data: specify url and id for project " + name );
- }
-
- return site;
- }
-
- *//**
- * Extract the distributionManagment site of the top level parent of the given MavenProject.
- * This climbs up the project hierarchy and returns the site of the last project
- * for which {@link #getSite(org.apache.maven.project.MavenProject)} returns a site.
- *
- * @param project the MavenProject. Not null.
- *
- * @return the top level site. Not null.
- * Also site.getUrl() and site.getId() are guaranteed to be not null.
- *
- * @throws MojoExecutionException if no site info is found in the tree.
- *//*
- protected Site getRootSite( MavenProject project )
- throws MojoExecutionException
- {
- Site site = getSite( project );
-
- MavenProject parent = project;
-
- while ( parent.getParent() != null )
- {
- // MSITE-585, MNG-1943
- parent = siteTool.getParentProject( parent, reactorProjects, localRepository );
-
- try
- {
- site = getSite( parent );
- }
- catch ( MojoExecutionException e )
- {
- break;
- }
- }
-
- return site;
- }*/
-}
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-18 16:20:39 UTC (rev 1176)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-19 08:22:52 UTC (rev 1177)
@@ -24,37 +24,59 @@
*/
package org.nuiton.wikitty.plugin;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
+import org.apache.maven.artifact.manager.WagonConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.site.AbstractSiteMojo;
-import org.apache.maven.plugins.site.SiteDeployMojo;
-import org.apache.maven.plugins.site.SiteMojo;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.site.wagon.repository.Repository;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
import org.apache.maven.settings.crypto.SettingsDecrypter;
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
+import org.apache.maven.wagon.CommandExecutionException;
+import org.apache.maven.wagon.CommandExecutor;
import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
/**
* To deploy a wikitty publication jar.
*
@@ -66,14 +88,60 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPDeployJarMojo extends AbstractWPMojo {
- // implements Contextualizable
- protected String uploadUrl;
- protected String serveurID;
-
+public class WPDeployJarMojo extends AbstractWPMojo implements Contextualizable {
+
/**
- * @component
+ * Id of server.
+ *
+ * @parameter expression="${serverId}"
+ * @required
*/
+ protected String serverId;
+
+ /**
+ * URL of server to use to log into server.
+ *
+ * @parameter expression="${serverUrl}"
+ * @required
+ */
+ protected String serverUrl;
+
+ /**
+ * File to deploy.
+ *
+ * @parameter expression="${fileToDeploy}"
+ * @required
+ */
+ protected File fileToDeploy;
+
+ /**
+ * Whether to run the "chmod" command on the remote site after the deploy.
+ * Defaults to "true".
+ *
+ * @parameter expression="${maven.site.chmod}" default-value="true"
+ * @since 2.1
+ */
+ private boolean chmod;
+
+ /**
+ * 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"
+ * @since 2.1
+ */
+ private String chmodMode;
+
+ /**
+ * The options used by the "chmod" command. Only used if chmod = true.
+ * Defaults to "-Rf".
+ *
+ * @parameter expression="${maven.site.chmod.options}" default-value="-Rf"
+ * @since 2.1
+ */
+ private String chmodOptions;
+
+ /** @component */
private WagonManager wagonManager;
/**
@@ -85,42 +153,376 @@
*/
private Settings settings;
+ /**
+ * @parameter expression="${session}"
+ * @required
+ * @readonly
+ * @since 3.0-beta-2
+ */
+ protected MavenSession mavenSession;
private PlexusContainer container;
-
-
+
+ private Repository repository;
+
+ /**
+ * All available wagons.
+ *
+ * @component role="org.apache.maven.wagon.Wagon"
+ * @since 1.0
+ */
+ protected Map<String, Wagon> wagons;
+
+ /** @component */
+ private SettingsDecrypter settingsDecrypter;
+
+ private ProxyInfo proxyInfo;
+
+ private Wagon wagon;
+
@Override
protected void init() throws Exception {
- //TODO
+
+ repository = new Repository(
+ serverId,
+ serverUrl
+ );
+
+ if (!fileToDeploy.exists()) {
+ throw new MojoExecutionException("The file to deploy " + fileToDeploy + " does not exist");
+ }
+
+
+ if (!isMaven3OrMore()) {
+ proxyInfo = getProxyInfo();
+ } else {
+
+ proxyInfo = getProxy();
+ }
+
+ wagon = getWagon(repository, wagonManager);
+
+ try {
+ configureWagon(wagon, repository.getId(), settings, container, getLog());
+ } catch (TransferFailedException e) {
+ throw new MojoExecutionException("Unable to configure Wagon: '" + repository.getProtocol() + "'", e);
+ }
+
}
@Override
protected void doAction() throws Exception {
-
- DeployUtil deploy = new DeployUtil();
-
- String file = getProject().getBuild().getDirectory();
- file+=File.separator+WPJarMojo.EXTERNALIZE_PREFIX+applicationName+".jar";
- File jarFile= new File(file);
-
- // SiteDeployMojo
-
-
- /*
-
- deploy.setFile(jarFile);
- deploy.setUrl("localhost:7878");
- deploy.setRepositoryId("bob");
-
-
-
-
-
-
- deploy.execute();*/
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Deploying to '" + repository.getUrl()
+ + "',\n Using credentials from server id '" + repository.getId() + "'");
+ }
+
+ try {
+
+ AuthenticationInfo authenticationInfo = wagonManager.getAuthenticationInfo(repository.getId());
+ getLog().debug("authenticationInfo with id '" + repository.getId() + "': "
+ + (authenticationInfo == null ? "-" : authenticationInfo.getUserName()));
+
+ try {
+ Debug debug = new Debug();
+
+ wagon.addSessionListener(debug);
+
+ wagon.addTransferListener(debug);
+
+ if (proxyInfo != null) {
+ getLog().debug("connect with proxyInfo");
+ wagon.connect(repository, authenticationInfo, proxyInfo);
+ } else if (authenticationInfo != null) {
+ getLog().debug("connect with authenticationInfo and without proxyInfo");
+ wagon.connect(repository, authenticationInfo);
+ } else {
+ getLog().debug("connect without authenticationInfo and without proxyInfo");
+ wagon.connect(repository);
+ }
+
+ getLog().info("Pushing " + fileToDeploy);
+
+ wagon.put(fileToDeploy, fileToDeploy.getName());
+
+ } catch (ResourceDoesNotExistException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ } catch (TransferFailedException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ } catch (AuthorizationException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ } catch (ConnectionException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ } catch (AuthenticationException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ }
+
+ if (chmod) {
+ try {
+ if (wagon instanceof CommandExecutor) {
+ CommandExecutor exec = (CommandExecutor) wagon;
+ exec.executeCommand("chmod " + chmodOptions + " " + chmodMode + " " + repository.getBasedir());
+ }
+ // else ? silently ignore, FileWagon is not a CommandExecutor!
+ } catch (CommandExecutionException e) {
+ throw new MojoExecutionException("Error uploading site", e);
+ }
+ }
+ } finally {
+ try {
+ wagon.disconnect();
+ } catch (ConnectionException e) {
+ getLog().error("Error disconnecting wagon - ignored", e);
+ }
+ }
+
}
+ protected boolean isMaven3OrMore() {
+ return new ComparableVersion(getMavenVersion()).compareTo(new ComparableVersion("3.0")) >= 0;
+ }
-}
+ protected String getMavenVersion() {
+ // This relies on the fact that MavenProject is the in core classloader
+ // and that the core classloader is for the maven-core artifact
+ // 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");
+ try {
+ properties.load(in);
+ } catch (IOException ioe) {
+ return "";
+ } finally {
+ IOUtil.close(in);
+ }
+
+ return properties.getProperty("version").trim();
+ }
+
+ private String getSupportedProtocols() {
+ Set<String> protocols = wagons.keySet();
+
+ return StringUtils.join(protocols.iterator(), ", ");
+ }
+
+ /**
+ * <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>.
+ * </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"
+ * </p>
+ * <p>
+ * 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
+ */
+ public ProxyInfo getProxyInfo() {
+
+ ProxyInfo proxyInfo = wagonManager.getProxy(repository.getProtocol());
+
+ if (proxyInfo == null) {
+ return null;
+ }
+
+ String host = repository.getHost();
+ String nonProxyHostsAsString = proxyInfo.getNonProxyHosts();
+ 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
+ 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)) {
+ return null;
+ }
+ // *suffix
+ if (StringUtils.isEmpty(nonProxyHostPrefix)
+ && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
+ return null;
+ }
+ // prefix*suffix
+ if (StringUtils.isNotEmpty(nonProxyHostPrefix) && host.startsWith(nonProxyHostPrefix)
+ && StringUtils.isNotEmpty(nonProxyHostSuffix) && host.endsWith(nonProxyHostSuffix)) {
+ return null;
+ }
+ } else if (host.equals(nonProxyHost)) {
+ return null;
+ }
+ }
+ return proxyInfo;
+ }
+
+ /**
+ * Get proxy information for Maven 3.
+ *
+ * @return
+ */
+ private ProxyInfo getProxy() {
+ String protocol = repository.getProtocol();
+ String url = repository.getUrl();
+
+ getLog().debug("repository protocol " + protocol);
+
+ String originalProtocol = protocol;
+ // olamy: hackish here protocol (wagon hint in fact !) is dav
+ // 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:")) {
+ 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);
+ } catch (MalformedURLException e) {
+ getLog().warn("fail to build URL with " + url);
+ }
+
+ }
+ } else {
+ getLog().debug("getProxy 'protocol': " + protocol);
+ }
+ if (mavenSession != null && protocol != null) {
+ MavenExecutionRequest request = mavenSession.getRequest();
+
+ if (request != null) {
+ List<Proxy> proxies = request.getProxies();
+
+ if (proxies != null) {
+ for (Proxy proxy : proxies) {
+ if (proxy.isActive()
+ && (protocol.equalsIgnoreCase(proxy.getProtocol()) || originalProtocol
+ .equalsIgnoreCase(proxy.getProtocol()))) {
+ SettingsDecryptionResult result = settingsDecrypter
+ .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() );
+ proxyInfo.setPort(proxy.getPort());
+ proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
+ proxyInfo.setUserName(proxy.getUsername());
+ proxyInfo.setPassword(proxy.getPassword());
+
+ getLog().debug("found proxyInfo "
+ + "host:port " + proxyInfo.getHost()
+ + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName());
+
+ return proxyInfo;
+ }
+ }
+ }
+ }
+ }
+ getLog().debug("getProxy 'protocol': " + protocol + " no ProxyInfo found");
+ return null;
+ }
+
+ 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"
+ + " Protocols may be added through wagon providers.\n"
+ + " For more information, see "
+ + "http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-pr…";
+
+ getLog().error(longMessage);
+
+ throw new MojoExecutionException(shortMessage);
+ } catch (TransferFailedException 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");
+ }
+
+ return wagon;
+ }
+
+ /**
+ * 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.
+ */
+ private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container,
+ Log log)
+ throws TransferFailedException {
+ log.debug(" configureWagon ");
+
+ // MSITE-25: Make sure that the server settings are inserted
+ for (int i = 0; i < settings.getServers().size(); i++) {
+ Server server = settings.getServers().get(i);
+ String id = server.getId();
+
+ log.debug("configureWagon server " + id);
+
+ if (id != null && id.equals(repositoryId)) {
+ if (server.getConfiguration() != null) {
+ PlexusConfiguration plexusConf =
+ new XmlPlexusConfiguration((Xpp3Dom) server.getConfiguration());
+
+ ComponentConfigurator componentConfigurator = null;
+ try {
+ 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);
+ } catch (ComponentConfigurationException 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());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void contextualize(Context context)
+ throws ContextException {
+ container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
+ }
+
+
+}
\ No newline at end of file
1
0
r1176 - trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin
by mfortun@users.nuiton.org 18 Aug '11
by mfortun@users.nuiton.org 18 Aug '11
18 Aug '11
Author: mfortun
Date: 2011-08-18 18:20:39 +0200 (Thu, 18 Aug 2011)
New Revision: 1176
Url: http://nuiton.org/repositories/revision/wikitty/1176
Log:
*remove error
Modified:
trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java
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-18 16:19:47 UTC (rev 1175)
+++ trunk/wp-maven-plugin/src/main/java/org/nuiton/wikitty/plugin/WPDeployJarMojo.java 2011-08-18 16:20:39 UTC (rev 1176)
@@ -66,7 +66,8 @@
* @requiresDependencyResolution runtime
* @since 3.2
*/
-public class WPDeployJarMojo extends AbstractWPMojo implements Contextualizable {
+public class WPDeployJarMojo extends AbstractWPMojo {
+ // implements Contextualizable
protected String uploadUrl;
protected String serveurID;
1
0