}.
70 | *
71 | * Example:
72 | * {@code scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin-LATEST/}
73 | *
74 | * @see SCM URL Format
75 | */
76 | // CHECKSTYLE_ON: LineLength
77 | @Parameter(
78 | property = "scmpublish.pubScmUrl",
79 | defaultValue = "${project.distributionManagement.site.url}",
80 | required = true)
81 | protected String pubScmUrl;
82 |
83 | /**
84 | * If the {@link AbstractScmPublishMojo#checkoutDirectory} exists and this flag is activated, the plugin will try an SCM-update instead
85 | * of deleting first and then doing a fresh checkout.
86 | */
87 | @Parameter(property = "scmpublish.tryUpdate", defaultValue = "false")
88 | protected boolean tryUpdate;
89 |
90 | // CHECKSTYLE_OFF: LineLength
91 | /**
92 | * Filesystem path of the directory to where the scm check-out is done. By default, scm checkout is done in build (target) directory,
93 | * which is deleted on every mvn clean
. To avoid this and get better performance, configure
94 | * this location outside build structure and set tryUpdate
to true
.
95 | * See
96 | * Improving SCM Checkout Performance for more information.
97 | */
98 | // CHECKSTYLE_ON: LineLength
99 | @Parameter(
100 | property = "scmpublish.checkoutDirectory",
101 | defaultValue = "${project.build.directory}/scmpublish-checkout")
102 | protected File checkoutDirectory;
103 |
104 | /**
105 | * Location where the content is published inside the ${checkoutDirectory}
.
106 | * By default, content is copyed at the root of ${checkoutDirectory}
.
107 | */
108 | @Parameter(property = "scmpublish.subDirectory")
109 | protected String subDirectory;
110 |
111 | /**
112 | * If set to {@code true} displays list of added, deleted, and changed files, but does not do any actual SCM operations.
113 | */
114 | @Parameter(property = "scmpublish.dryRun")
115 | private boolean dryRun;
116 |
117 | /**
118 | * Set this to {@code true} to skip site deployment.
119 | *
120 | * @deprecated Please use {@link #skipDeployment}.
121 | */
122 | @Deprecated
123 | @Parameter(defaultValue = "false")
124 | private boolean skipDeployement;
125 |
126 | /**
127 | * Set this to {@code true} to skip site deployment.
128 | */
129 | @Parameter(property = "scmpublish.skipDeploy", alias = "maven.site.deploy.skip", defaultValue = "false")
130 | private boolean skipDeployment;
131 |
132 | /**
133 | * Only executes local SCM add and delete commands, but leave the actual checkin for the user to run manually.
134 | */
135 | @Parameter(property = "scmpublish.skipCheckin")
136 | private boolean skipCheckin;
137 |
138 | /**
139 | * Push changes to the upstream remote repository during commit (only affects distributed SCMs like Git).
140 | * @since 3.4.0
141 | */
142 | @Parameter(property = "scmpublish.pushChanges", defaultValue = "true")
143 | private boolean pushChanges;
144 |
145 | /**
146 | * SCM log/checkin comment for this publication.
147 | */
148 | @Parameter(property = "scmpublish.checkinComment", defaultValue = "Site checkin for project ${project.name}")
149 | private String checkinComment;
150 |
151 | /**
152 | * List of SCM provider implementations.
153 | * Key is the provider type, eg. cvs
.
154 | * Value is the provider implementation (the role-hint of the provider), eg. cvs
or
155 | * cvs_native
.
156 | * @see ScmManager.setScmProviderImplementation
157 | */
158 | @Parameter
159 | private Map providerImplementations;
160 |
161 | /**
162 | * The server id specified in the {@code settings.xml}, which should be used for the authentication.
163 | * @see Settings Reference
164 | */
165 | @Parameter(property = "scmpublish.serverId", defaultValue = "${project.distributionManagement.site.id}")
166 | private String serverId;
167 |
168 | /**
169 | * The SCM username to use.
170 | * This value takes precedence over the username derived from {@link #serverId}.
171 | * @see #serverId
172 | */
173 | @Parameter(property = "username")
174 | protected String username;
175 |
176 | /**
177 | * The SCM password to use.
178 | * This value takes precedence over the password derived from {@link #serverId}.
179 | * @see #serverId
180 | */
181 | @Parameter(property = "password")
182 | protected String password;
183 |
184 | /**
185 | * Use a local checkout instead of doing a checkout from the upstream repository.
186 | * WARNING: This will only work with distributed SCMs which support the file:// protocol.
187 | * TODO: we should think about having the defaults for the various SCM providers provided via Modello!
188 | */
189 | @Parameter(property = "localCheckout", defaultValue = "false")
190 | protected boolean localCheckout;
191 |
192 | /**
193 | * The outputEncoding parameter of the site plugin. This plugin will corrupt your site
194 | * if this does not match the value used by the site plugin.
195 | */
196 | @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}")
197 | protected String siteOutputEncoding;
198 |
199 | /**
200 | * If set to {@code true} does not delete files in the SCM that are not in the site.
201 | */
202 | @Parameter(property = "scmpublish.skipDeletedFiles", defaultValue = "false")
203 | protected boolean skipDeletedFiles;
204 |
205 | /**
206 | * Add each directory in a separated SCM command: this can be necessary if SCM does not support
207 | * adding subdirectories in one command.
208 | */
209 | @Parameter(defaultValue = "false")
210 | protected boolean addUniqueDirectory;
211 |
212 | /**
213 | */
214 | @Parameter(defaultValue = "${basedir}", readonly = true)
215 | protected File basedir;
216 |
217 | /**
218 | */
219 | @Parameter(defaultValue = "${settings}", readonly = true, required = true)
220 | protected Settings settings;
221 |
222 | /**
223 | * Collections of path patterns specifying files/directories which should never be deleted by this goal.
224 | * Each pattern is either
225 | *
226 | * - an Ant pattern (when surrounded by {@code %ant[} and {@code ]} or not starting with {@code %regex[}), or
227 | * - a full regex pattern when surrounded by {@code %regex[} and {@code ]}.
228 | *
229 | * Files/directories with a matching path will be skipped when deleting files from the SCM.
230 | *
231 | * If your site has subdirectories or individual files published by an other mechanism/build you should leverage this parameter.
232 | * @see Ant Patterns
233 | * @see org.codehaus.plexus.util.MatchPatterns
234 | * @see #skipDeletedFiles
235 | */
236 | @Parameter
237 | protected String[] ignorePathsToDelete;
238 |
239 | /**
240 | * SCM branch to use. For using with GitHub Pages,
241 | * you conventionally use gh-pages
.
242 | */
243 | @Parameter(property = "scmpublish.scm.branch")
244 | protected String scmBranch;
245 |
246 | /**
247 | * Configure svn automatic remote url creation.
248 | */
249 | @Parameter(property = "scmpublish.automaticRemotePathCreation", defaultValue = "true")
250 | protected boolean automaticRemotePathCreation;
251 |
252 | /**
253 | * File name extensions of files where line ending normalization should be applied.
254 | * @see #extraNormalizeExtensions
255 | */
256 | private static final String[] NORMALIZE_EXTENSIONS = {"html", "css", "js"};
257 |
258 | /**
259 | * Additional file name extensions of files where line ending normalization should be applied (will be added to the default list containing
260 | * html
,css
and js
)
261 | */
262 | @Parameter
263 | protected String[] extraNormalizeExtensions;
264 |
265 | private Set normalizeExtensions;
266 |
267 | protected ScmProvider scmProvider;
268 |
269 | protected ScmRepository scmRepository;
270 |
271 | /**
272 | * The SCM manager.
273 | */
274 | private final ScmManager scmManager;
275 |
276 | /**
277 | * Tool that gets a configured SCM repository from release configuration.
278 | */
279 | protected final ScmRepositoryConfigurator scmRepositoryConfigurator;
280 |
281 | protected AbstractScmPublishMojo(ScmManager scmManager, ScmRepositoryConfigurator scmRepositoryConfigurator) {
282 | this.scmManager = scmManager;
283 | this.scmRepositoryConfigurator = scmRepositoryConfigurator;
284 | }
285 |
286 | protected void logInfo(String format, Object... params) {
287 | getLog().info(String.format(format, params));
288 | }
289 |
290 | protected void logWarn(String format, Object... params) {
291 | getLog().warn(String.format(format, params));
292 | }
293 |
294 | protected void logError(String format, Object... params) {
295 | getLog().error(String.format(format, params));
296 | }
297 |
298 | private File relativize(File base, File file) {
299 | return new File(base.toURI().relativize(file.toURI()).getPath());
300 | }
301 |
302 | protected boolean requireNormalizeNewlines(File f) throws IOException {
303 | if (normalizeExtensions == null) {
304 | normalizeExtensions = new HashSet<>(Arrays.asList(NORMALIZE_EXTENSIONS));
305 | if (extraNormalizeExtensions != null) {
306 | normalizeExtensions.addAll(Arrays.asList(extraNormalizeExtensions));
307 | }
308 | }
309 |
310 | return FilenameUtils.isExtension(f.getName(), normalizeExtensions);
311 | }
312 |
313 | private void setupScm() throws ScmRepositoryException, NoSuchScmProviderException {
314 | String scmUrl;
315 | if (localCheckout) {
316 | // in the release phase we have to change the checkout URL
317 | // to do a local checkout instead of going over the network.
318 |
319 | String provider = ScmUrlUtils.getProvider(pubScmUrl);
320 | String delimiter = ScmUrlUtils.getDelimiter(pubScmUrl);
321 |
322 | String providerPart = "scm:" + provider + delimiter;
323 |
324 | // X TODO: also check the information from releaseDescriptor.getScmRelativePathProjectDirectory()
325 | // X TODO: in case our toplevel git directory has no pom.
326 | // X TODO: fix pathname once I understand this.
327 | scmUrl = providerPart + "file://" + "target/localCheckout";
328 | logInfo("Performing a LOCAL checkout from " + scmUrl);
329 | }
330 |
331 | ReleaseDescriptorBuilder descriptorBuilder = new ReleaseDescriptorBuilder();
332 | descriptorBuilder.setInteractive(settings.isInteractiveMode());
333 |
334 | descriptorBuilder.setScmPassword(password);
335 | descriptorBuilder.setScmUsername(username);
336 | // used for lookup of credentials from settings.xml in DefaultScmRepositoryConfigurator
337 | descriptorBuilder.setScmId(serverId);
338 | descriptorBuilder.setWorkingDirectory(basedir.getAbsolutePath());
339 | descriptorBuilder.setLocalCheckout(localCheckout);
340 | descriptorBuilder.setScmSourceUrl(pubScmUrl);
341 | descriptorBuilder.setPushChanges(pushChanges);
342 | if (providerImplementations != null) {
343 | for (Map.Entry providerEntry : providerImplementations.entrySet()) {
344 | logInfo(
345 | "Changing the default '%s' provider implementation to '%s'.",
346 | providerEntry.getKey(), providerEntry.getValue());
347 | scmManager.setScmProviderImplementation(providerEntry.getKey(), providerEntry.getValue());
348 | }
349 | }
350 |
351 | ReleaseDescriptor releaseDescriptor = descriptorBuilder.build();
352 | scmRepository = scmRepositoryConfigurator.getConfiguredRepository(releaseDescriptor, settings);
353 | // set pushChanges afterwards due to https://issues.apache.org/jira/browse/MRELEASE-1160
354 | scmRepository.getProviderRepository().setPushChanges(pushChanges);
355 | scmProvider = scmRepositoryConfigurator.getRepositoryProvider(scmRepository);
356 | }
357 |
358 | protected void checkoutExisting() throws MojoExecutionException {
359 |
360 | if (scmProvider instanceof AbstractSvnScmProvider) {
361 | checkCreateRemoteSvnPath();
362 | }
363 |
364 | logInfo(
365 | MessageUtils.buffer().strong("%s") + " the pub tree from "
366 | + MessageUtils.buffer().strong("%s") + " into %s",
367 | (tryUpdate ? "Updating" : "Checking out"),
368 | pubScmUrl,
369 | checkoutDirectory);
370 |
371 | if (checkoutDirectory.exists() && !tryUpdate) {
372 |
373 | try {
374 | FileUtils.deleteDirectory(checkoutDirectory);
375 | } catch (IOException e) {
376 | logError(e.getMessage());
377 |
378 | throw new MojoExecutionException("Unable to remove old checkout directory: " + e.getMessage(), e);
379 | }
380 | }
381 |
382 | boolean forceCheckout = false;
383 |
384 | if (!checkoutDirectory.exists()) {
385 |
386 | if (tryUpdate) {
387 | logInfo("TryUpdate is configured but no local copy currently available: forcing checkout.");
388 | }
389 | checkoutDirectory.mkdirs();
390 | forceCheckout = true;
391 | }
392 |
393 | try {
394 | // only the baseDir is evaluated during update/checkout
395 | ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, null, null);
396 |
397 | ScmBranch branch = (scmBranch == null) ? null : new ScmBranch(scmBranch);
398 |
399 | ScmResult scmResult = null;
400 | if (tryUpdate && !forceCheckout) {
401 | scmResult = scmProvider.update(scmRepository, fileSet, branch);
402 | } else {
403 | int attempt = 0;
404 | while (scmResult == null) {
405 | try {
406 | scmResult = scmProvider.checkOut(scmRepository, fileSet, branch);
407 | } catch (ScmException e) {
408 | // give it max 2 times to retry
409 | if (attempt++ < 2) {
410 | try {
411 | // wait 3 seconds
412 | Thread.sleep(3 * 1000);
413 | } catch (InterruptedException ie) {
414 | // noop
415 | }
416 | } else {
417 | throw e;
418 | }
419 | }
420 | }
421 | }
422 | checkScmResult(scmResult, "check out from SCM");
423 | } catch (ScmException | IOException e) {
424 | logError(e.getMessage());
425 |
426 | throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
427 | }
428 | }
429 |
430 | private void checkCreateRemoteSvnPath() throws MojoExecutionException {
431 | getLog().debug("AbstractSvnScmProvider used, so we can check if remote url exists and eventually create it.");
432 | AbstractSvnScmProvider svnScmProvider = (AbstractSvnScmProvider) scmProvider;
433 |
434 | try {
435 | boolean remoteExists = svnScmProvider.remoteUrlExist(scmRepository.getProviderRepository(), null);
436 |
437 | if (remoteExists) {
438 | return;
439 | }
440 | } catch (ScmException e) {
441 | throw new MojoExecutionException(e.getMessage(), e);
442 | }
443 |
444 | String remoteUrl = ((SvnScmProviderRepository) scmRepository.getProviderRepository()).getUrl();
445 |
446 | if (!automaticRemotePathCreation) {
447 | // olamy: return ?? that will fail during checkout IMHO :-)
448 | logWarn("Remote svn url %s does not exist and automatic remote path creation disabled.", remoteUrl);
449 | return;
450 | }
451 |
452 | logInfo("Remote svn url %s does not exist: creating.", remoteUrl);
453 |
454 | File baseDir = null;
455 | try {
456 |
457 | // create a temporary directory for svnexec
458 | baseDir = Files.createTempDirectory("scm").toFile();
459 |
460 | // to prevent fileSet cannot be empty
461 | ScmFileSet scmFileSet = new ScmFileSet(baseDir, new File(""));
462 |
463 | CommandParameters commandParameters = new CommandParameters();
464 | commandParameters.setString(CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL, Boolean.FALSE.toString());
465 | commandParameters.setString(CommandParameter.MESSAGE, "Automatic svn path creation: " + remoteUrl);
466 | svnScmProvider.mkdir(scmRepository.getProviderRepository(), scmFileSet, commandParameters);
467 |
468 | // new remote url so force checkout!
469 | if (checkoutDirectory.exists()) {
470 | FileUtils.deleteDirectory(checkoutDirectory);
471 | }
472 | } catch (IOException | ScmException e) {
473 | throw new MojoExecutionException(e.getMessage(), e);
474 | } finally {
475 | if (baseDir != null) {
476 | try {
477 | FileUtils.forceDeleteOnExit(baseDir);
478 | } catch (IOException e) {
479 | throw new MojoExecutionException(e.getMessage(), e);
480 | }
481 | }
482 | }
483 | }
484 |
485 | public void execute() throws MojoExecutionException, MojoFailureException {
486 | if (skipDeployment || skipDeployement) {
487 | getLog().info("scmpublish.skipDeploy = true: Skipping site deployment");
488 | return;
489 | }
490 |
491 | // setup the scm plugin with help from release plugin utilities
492 | try {
493 | setupScm();
494 | } catch (ScmRepositoryException | NoSuchScmProviderException e) {
495 | throw new MojoExecutionException(e.getMessage(), e);
496 | }
497 |
498 | boolean tmpCheckout = false;
499 |
500 | if (checkoutDirectory.getPath().contains("${project.")) {
501 | try {
502 | tmpCheckout = true;
503 | checkoutDirectory = Files.createTempDirectory("maven-scm-publish" + ".checkout")
504 | .toFile();
505 | } catch (IOException ioe) {
506 | throw new MojoExecutionException(ioe.getMessage(), ioe);
507 | }
508 | }
509 |
510 | try {
511 | scmPublishExecute();
512 | } finally {
513 | if (tmpCheckout) {
514 | FileUtils.deleteQuietly(checkoutDirectory);
515 | }
516 | }
517 | }
518 |
519 | /**
520 | * Check-in content from scm checkout.
521 | *
522 | * @throws MojoExecutionException in case of issue
523 | */
524 | protected void checkinFiles() throws MojoExecutionException {
525 | if (skipCheckin) {
526 | return;
527 | }
528 |
529 | ScmFileSet updatedFileSet = new ScmFileSet(checkoutDirectory);
530 | try {
531 | long start = System.currentTimeMillis();
532 |
533 | CheckInScmResult checkinResult = checkScmResult(
534 | scmProvider.checkIn(scmRepository, updatedFileSet, new ScmBranch(scmBranch), checkinComment),
535 | "check-in files to SCM");
536 |
537 | logInfo(
538 | "Checked in %d file(s) to revision %s in %s",
539 | checkinResult.getCheckedInFiles().size(),
540 | checkinResult.getScmRevision(),
541 | DurationFormatUtils.formatPeriod(start, System.currentTimeMillis(), "H' h 'm' m 's' s'"));
542 | } catch (ScmException e) {
543 | throw new MojoExecutionException("Failed to perform SCM checkin", e);
544 | }
545 | }
546 |
547 | protected void deleteFiles(Collection deleted) throws MojoExecutionException {
548 | if (skipDeletedFiles) {
549 | logInfo("Deleting files is skipped.");
550 | return;
551 | }
552 | List deletedList = new ArrayList<>();
553 | for (File f : deleted) {
554 | deletedList.add(relativize(checkoutDirectory, f));
555 | }
556 | ScmFileSet deletedFileSet = new ScmFileSet(checkoutDirectory, deletedList);
557 | try {
558 | getLog().info("Deleting files: " + deletedList);
559 |
560 | checkScmResult(
561 | scmProvider.remove(scmRepository, deletedFileSet, "Deleting obsolete site files."),
562 | "delete files from SCM");
563 | } catch (ScmException e) {
564 | throw new MojoExecutionException("Failed to delete removed files to SCM", e);
565 | }
566 | }
567 |
568 | /**
569 | * Add files to scm.
570 | *
571 | * @param added files to be added
572 | * @throws MojoFailureException in case of issue
573 | * @throws MojoExecutionException in case of issue
574 | */
575 | protected void addFiles(Collection added) throws MojoFailureException, MojoExecutionException {
576 | List addedList = new ArrayList<>();
577 | Set createdDirs = new HashSet<>();
578 | Set dirsToAdd = new TreeSet<>();
579 |
580 | createdDirs.add(relativize(checkoutDirectory, checkoutDirectory));
581 |
582 | for (File f : added) {
583 | for (File dir = f.getParentFile(); !dir.equals(checkoutDirectory); dir = dir.getParentFile()) {
584 | File relativized = relativize(checkoutDirectory, dir);
585 | // we do the best we can with the directories
586 | if (createdDirs.add(relativized)) {
587 | dirsToAdd.add(relativized);
588 | } else {
589 | break;
590 | }
591 | }
592 | addedList.add(relativize(checkoutDirectory, f));
593 | }
594 |
595 | if (addUniqueDirectory) { // add one directory at a time
596 | for (File relativized : dirsToAdd) {
597 | try {
598 | ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, relativized);
599 | getLog().info("scm add directory: " + relativized);
600 | AddScmResult addDirResult = scmProvider.add(scmRepository, fileSet, "Adding directory");
601 | if (!addDirResult.isSuccess()) {
602 | getLog().warn(" Error adding directory " + relativized + ": "
603 | + addDirResult.getCommandOutput());
604 | }
605 | } catch (ScmException e) {
606 | //
607 | }
608 | }
609 | } else { // add all directories in one command
610 | try {
611 | List dirs = new ArrayList<>(dirsToAdd);
612 | ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, dirs);
613 | getLog().info("scm add directories: " + dirs);
614 | AddScmResult addDirResult = scmProvider.add(scmRepository, fileSet, "Adding directories");
615 | if (!addDirResult.isSuccess()) {
616 | getLog().warn(" Error adding directories " + dirs + ": " + addDirResult.getCommandOutput());
617 | }
618 | } catch (ScmException e) {
619 | //
620 | }
621 | }
622 |
623 | // remove directories already added !
624 | addedList.removeAll(dirsToAdd);
625 |
626 | ScmFileSet addedFileSet = new ScmFileSet(checkoutDirectory, addedList);
627 | getLog().info("scm add files: " + addedList);
628 | try {
629 | CommandParameters commandParameters = new CommandParameters();
630 | commandParameters.setString(CommandParameter.MESSAGE, "Adding new site files.");
631 | commandParameters.setString(CommandParameter.FORCE_ADD, Boolean.TRUE.toString());
632 | checkScmResult(scmProvider.add(scmRepository, addedFileSet, commandParameters), "add new files to SCM");
633 | } catch (ScmException e) {
634 | throw new MojoExecutionException("Failed to add new files to SCM", e);
635 | }
636 | }
637 |
638 | private T checkScmResult(T result, String failure) throws MojoExecutionException {
639 | if (!result.isSuccess()) {
640 | String msg = "Failed to " + failure + ": " + result.getProviderMessage() + " " + result.getCommandOutput();
641 | logError(msg);
642 | throw new MojoExecutionException(msg);
643 | }
644 | return result;
645 | }
646 |
647 | public boolean isDryRun() {
648 | return dryRun;
649 | }
650 |
651 | public abstract void scmPublishExecute() throws MojoExecutionException, MojoFailureException;
652 |
653 | public void setPubScmUrl(String pubScmUrl) {
654 | // Fix required for Windows, which fit other OS as well
655 | if (pubScmUrl.startsWith("scm:svn:")) {
656 | pubScmUrl = pubScmUrl.replaceFirst("file:/[/]*", "file:///");
657 | }
658 |
659 | this.pubScmUrl = pubScmUrl;
660 | }
661 | }
662 |
--------------------------------------------------------------------------------
/src/main/java/org/apache/maven/plugins/scmpublish/ScmPublishPublishScmMojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.apache.maven.plugins.scmpublish;
20 |
21 | import javax.inject.Inject;
22 |
23 | import java.io.BufferedReader;
24 | import java.io.File;
25 | import java.io.IOException;
26 | import java.io.InputStreamReader;
27 | import java.io.OutputStreamWriter;
28 | import java.io.PrintWriter;
29 | import java.nio.file.Files;
30 | import java.nio.file.LinkOption;
31 | import java.nio.file.StandardCopyOption;
32 | import java.util.ArrayList;
33 | import java.util.Arrays;
34 | import java.util.Collections;
35 | import java.util.Date;
36 | import java.util.HashSet;
37 | import java.util.List;
38 | import java.util.Set;
39 |
40 | import org.apache.commons.io.FileUtils;
41 | import org.apache.commons.io.filefilter.NameFileFilter;
42 | import org.apache.commons.io.filefilter.NotFileFilter;
43 | import org.apache.maven.plugin.MojoExecutionException;
44 | import org.apache.maven.plugin.MojoFailureException;
45 | import org.apache.maven.plugins.annotations.Mojo;
46 | import org.apache.maven.plugins.annotations.Parameter;
47 | import org.apache.maven.project.MavenProject;
48 | import org.apache.maven.scm.manager.ScmManager;
49 | import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
50 | import org.apache.maven.shared.utils.logging.MessageUtils;
51 | import org.codehaus.plexus.util.MatchPatterns;
52 |
53 | /**
54 | * Publish content to an SCM (source code management) repository (like Git). By default, content is taken from default site staging directory
55 | * ${project.build.directory}/staging
.
56 | * Can also be used without a Maven project, so usable to update any SCM with any content.
57 | * @see Maven SCM
58 | */
59 | @Mojo(name = "publish-scm", aggregator = true, requiresProject = false)
60 | public class ScmPublishPublishScmMojo extends AbstractScmPublishMojo {
61 | /**
62 | * The path of the directory containing the content to be published.
63 | * The is published recursively (i.e. including subdirectories).
64 | */
65 | @Parameter(property = "scmpublish.content", defaultValue = "${project.build.directory}/staging")
66 | private File content;
67 |
68 | @Parameter(defaultValue = "${project}", readonly = true, required = true)
69 | protected MavenProject project;
70 |
71 | private List deleted = new ArrayList<>();
72 |
73 | private List added = new ArrayList<>();
74 |
75 | private List updated = new ArrayList<>();
76 |
77 | private int directories = 0;
78 | private int files = 0;
79 | private long size = 0;
80 |
81 | @Inject
82 | public ScmPublishPublishScmMojo(ScmManager scmManager, ScmRepositoryConfigurator scmRepositoryConfigurator) {
83 | super(scmManager, scmRepositoryConfigurator);
84 | }
85 |
86 | /**
87 | * Update SCM checkout directory with content.
88 | *
89 | * @param checkout the scm checkout directory
90 | * @param dir the content to put in scm (can be null
)
91 | * @param doNotDeleteDirs directory names that should not be deleted from scm even if not in new content:
92 | * used for modules, which content is available only when staging
93 | * @throws IOException
94 | */
95 | private void update(File checkout, File dir, List doNotDeleteDirs) throws IOException {
96 | String scmSpecificFilename = scmProvider.getScmSpecificFilename();
97 | String[] files = scmSpecificFilename != null
98 | ? checkout.list(new NotFileFilter(new NameFileFilter(scmSpecificFilename)))
99 | : checkout.list();
100 |
101 | Set checkoutContent = new HashSet<>(Arrays.asList(files));
102 | List dirContent = (dir != null) ? Arrays.asList(dir.list()) : Collections.emptyList();
103 |
104 | Set deleted = new HashSet<>(checkoutContent);
105 | deleted.removeAll(dirContent);
106 |
107 | MatchPatterns ignoreDeleteMatchPatterns = null;
108 | List pathsAsList = new ArrayList<>(0);
109 | if (ignorePathsToDelete != null && ignorePathsToDelete.length > 0) {
110 | ignoreDeleteMatchPatterns = MatchPatterns.from(ignorePathsToDelete);
111 | pathsAsList = Arrays.asList(ignorePathsToDelete);
112 | }
113 |
114 | for (String name : deleted) {
115 | if (ignoreDeleteMatchPatterns != null && ignoreDeleteMatchPatterns.matches(name, true)) {
116 | getLog().debug(name + " match one of the patterns '" + pathsAsList + "': do not add to deleted files");
117 | continue;
118 | }
119 | getLog().debug("file marked for deletion: " + name);
120 | File file = new File(checkout, name);
121 |
122 | if ((doNotDeleteDirs != null) && file.isDirectory() && (doNotDeleteDirs.contains(name))) {
123 | // ignore directory not available
124 | continue;
125 | }
126 |
127 | if (file.isDirectory()) {
128 | update(file, null, null);
129 | }
130 | this.deleted.add(file);
131 | }
132 |
133 | for (String name : dirContent) {
134 | File file = new File(checkout, name);
135 | File source = new File(dir, name);
136 |
137 | if (Files.isSymbolicLink(source.toPath())) {
138 | if (!checkoutContent.contains(name)) {
139 | this.added.add(file);
140 | }
141 |
142 | // copy symbolic link (Java 7 only)
143 | copySymLink(source, file);
144 | } else if (source.isDirectory()) {
145 | directories++;
146 | if (!checkoutContent.contains(name)) {
147 | this.added.add(file);
148 | file.mkdir();
149 | }
150 |
151 | update(file, source, null);
152 | } else {
153 | if (checkoutContent.contains(name)) {
154 | this.updated.add(file);
155 | } else {
156 | this.added.add(file);
157 | }
158 |
159 | copyFile(source, file);
160 | }
161 | }
162 | }
163 |
164 | /**
165 | * Copy a symbolic link.
166 | *
167 | * @param srcFile the source file (expected to be a symbolic link)
168 | * @param destFile the destination file (which will be a symbolic link)
169 | * @throws IOException
170 | */
171 | private void copySymLink(File srcFile, File destFile) throws IOException {
172 | Files.copy(
173 | srcFile.toPath(),
174 | destFile.toPath(),
175 | StandardCopyOption.REPLACE_EXISTING,
176 | StandardCopyOption.COPY_ATTRIBUTES,
177 | LinkOption.NOFOLLOW_LINKS);
178 | }
179 |
180 | /**
181 | * Copy a file content, normalizing newlines when necessary.
182 | *
183 | * @param srcFile the source file
184 | * @param destFile the destination file
185 | * @throws IOException
186 | * @see #requireNormalizeNewlines(File)
187 | */
188 | private void copyFile(File srcFile, File destFile) throws IOException {
189 | if (requireNormalizeNewlines(srcFile)) {
190 | copyAndNormalizeNewlines(srcFile, destFile);
191 | } else {
192 | FileUtils.copyFile(srcFile, destFile);
193 | }
194 | files++;
195 | size += destFile.length();
196 | }
197 |
198 | /**
199 | * Copy and normalize newlines.
200 | *
201 | * @param srcFile the source file
202 | * @param destFile the destination file
203 | * @throws IOException
204 | */
205 | private void copyAndNormalizeNewlines(File srcFile, File destFile) throws IOException {
206 | try (BufferedReader in = new BufferedReader(
207 | new InputStreamReader(Files.newInputStream(srcFile.toPath()), siteOutputEncoding));
208 | PrintWriter out = new PrintWriter(
209 | new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), siteOutputEncoding))) {
210 | for (String line = in.readLine(); line != null; line = in.readLine()) {
211 | if (in.ready()) {
212 | out.println(line);
213 | } else {
214 | out.print(line);
215 | }
216 | }
217 | }
218 | }
219 |
220 | public void scmPublishExecute() throws MojoExecutionException, MojoFailureException {
221 | if (siteOutputEncoding == null) {
222 | getLog().warn("No output encoding, defaulting to UTF-8.");
223 | siteOutputEncoding = "utf-8";
224 | }
225 |
226 | if (!content.exists()) {
227 | throw new MojoExecutionException("Configured content directory does not exist: " + content);
228 | }
229 |
230 | if (!content.canRead()) {
231 | throw new MojoExecutionException("Can't read content directory: " + content);
232 | }
233 |
234 | checkoutExisting();
235 |
236 | final File updateDirectory;
237 | if (subDirectory == null) {
238 | updateDirectory = checkoutDirectory;
239 | } else {
240 | updateDirectory = new File(checkoutDirectory, subDirectory);
241 |
242 | // Security check for subDirectory with .. inside
243 | if (!updateDirectory
244 | .toPath()
245 | .normalize()
246 | .startsWith(checkoutDirectory.toPath().normalize())) {
247 | logError("Try to acces outside of the checkout directory with sub-directory: %s", subDirectory);
248 | return;
249 | }
250 |
251 | if (!updateDirectory.exists()) {
252 | updateDirectory.mkdirs();
253 | }
254 |
255 | logInfo("Will copy content in sub-directory: %s", subDirectory);
256 | }
257 |
258 | try {
259 | logInfo("Updating checkout directory with actual content in %s", content);
260 | update(
261 | updateDirectory,
262 | content,
263 | (project == null) ? null : project.getModel().getModules());
264 | String displaySize = FileUtils.byteCountToDisplaySize(size);
265 | logInfo(
266 | "Content consists of " + MessageUtils.buffer().strong("%d directories and %d files = %s"),
267 | directories,
268 | files,
269 | displaySize);
270 | } catch (IOException ioe) {
271 | throw new MojoExecutionException("Could not copy content to SCM checkout", ioe);
272 | }
273 |
274 | logInfo(
275 | "Publishing content to SCM will result in "
276 | + MessageUtils.buffer().strong("%d addition(s), %d update(s), %d delete(s)"),
277 | added.size(),
278 | updated.size(),
279 | deleted.size());
280 |
281 | if (isDryRun()) {
282 | int pos = checkoutDirectory.getAbsolutePath().length() + 1;
283 | for (File addedFile : added) {
284 | logInfo("- addition %s", addedFile.getAbsolutePath().substring(pos));
285 | }
286 | for (File updatedFile : updated) {
287 | logInfo("- update %s", updatedFile.getAbsolutePath().substring(pos));
288 | }
289 | for (File deletedFile : deleted) {
290 | logInfo("- delete %s", deletedFile.getAbsolutePath().substring(pos));
291 | }
292 | return;
293 | }
294 |
295 | if (!added.isEmpty()) {
296 | addFiles(added);
297 | }
298 |
299 | if (!deleted.isEmpty()) {
300 | deleteFiles(deleted);
301 | }
302 |
303 | logInfo("Checking in SCM, starting at " + new Date() + "...");
304 | checkinFiles();
305 | }
306 | }
307 |
--------------------------------------------------------------------------------
/src/site/apt/examples/importing-maven-site.apt:
--------------------------------------------------------------------------------
1 | ------
2 | Importing maven.apache.org Content to Svn
3 | ------
4 | Hervé Boutemy
5 | ------
6 | 2012-08-19
7 | ------
8 |
9 | ~~ Licensed to the Apache Software Foundation (ASF) under one
10 | ~~ or more contributor license agreements. See the NOTICE file
11 | ~~ distributed with this work for additional information
12 | ~~ regarding copyright ownership. The ASF licenses this file
13 | ~~ to you under the Apache License, Version 2.0 (the
14 | ~~ "License"); you may not use this file except in compliance
15 | ~~ with the License. You may obtain a copy of the License at
16 | ~~
17 | ~~ http://www.apache.org/licenses/LICENSE-2.0
18 | ~~
19 | ~~ Unless required by applicable law or agreed to in writing,
20 | ~~ software distributed under the License is distributed on an
21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 | ~~ KIND, either express or implied. See the License for the
23 | ~~ specific language governing permissions and limitations
24 | ~~ under the License.
25 |
26 | ~~ NOTE: For help with the syntax of this file, see:
27 | ~~ http://maven.apache.org/doxia/references/apt-format.html
28 |
29 | Importing maven.apache.org Content to Svn
30 |
31 | This plugin has been created to enable conversion of Maven components documentation
32 | to Apache CMS, based on svnpubsub: see {{{http://www.apache.org/dev/cms.html}documentation}}.
33 |
34 | Once new content can be published with the plugin, existing content needs to be imported.
35 |
36 | A little shell script has been used to import a component with all its versions independently of
37 | any site generation phase or components' pom.xml:
38 |
39 | +--------
40 | # configuration
41 | ORIG_PATH=/www/maven.apache.org
42 | DEST_SVN_BASE=https://svn.apache.org/repos/infra/websites/production/maven/content
43 |
44 | ARTIFACT=maven-clean-plugin
45 | DIR=plugins/${ARTIFACT}
46 | VERSIONS="2.3 2.4 2.4.1 2.5"
47 |
48 |
49 | # initialize ${DIR}-LATEST entry in svn
50 | svn -m "prepare ${ARTIFACT} documentation publication" mkdir ${DEST_SVN_BASE}/${DIR}-LATEST
51 |
52 | # publish existing content for each version in ${VERSIONS}
53 | for VERSION in ${VERSIONS}
54 | do
55 |
56 | echo " ========== ${ARTIFACT} ${VERSION} =========="
57 | mvn -e scm-publish:publish-scm \
58 | -Dscmpublish.content=${ORIG_PATH}/${DIR}-${VERSION} \
59 | -Dscmpublish.pubScmUrl=scm:svn:${DEST_SVN_BASE}/${DIR}-LATEST \
60 | -Dscmpublish.checkinComment="published documentation for ${ARTIFACT} version ${VERSION}" \
61 | && \
62 | svn cp ${DEST_SVN_BASE}/${DIR}-LATEST ${DEST_SVN_BASE}/${DIR}-${VERSION} -m "releasing ${ARTIFACT} ${VERSION} documentation"
63 |
64 | done
65 | +--------
66 |
--------------------------------------------------------------------------------
/src/site/apt/examples/multi-module-configuration.apt.vm:
--------------------------------------------------------------------------------
1 | ------
2 | Maven Multi Module Configuration
3 | ------
4 | Olivier Lamy
5 | Hervé Boutemy
6 | ------
7 | 2012-12-06
8 | ------
9 |
10 | ~~ Licensed to the Apache Software Foundation (ASF) under one
11 | ~~ or more contributor license agreements. See the NOTICE file
12 | ~~ distributed with this work for additional information
13 | ~~ regarding copyright ownership. The ASF licenses this file
14 | ~~ to you under the Apache License, Version 2.0 (the
15 | ~~ "License"); you may not use this file except in compliance
16 | ~~ with the License. You may obtain a copy of the License at
17 | ~~
18 | ~~ http://www.apache.org/licenses/LICENSE-2.0
19 | ~~
20 | ~~ Unless required by applicable law or agreed to in writing,
21 | ~~ software distributed under the License is distributed on an
22 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 | ~~ KIND, either express or implied. See the License for the
24 | ~~ specific language governing permissions and limitations
25 | ~~ under the License.
26 |
27 | ~~ NOTE: For help with the syntax of this file, see:
28 | ~~ http://maven.apache.org/doxia/references/apt-format.html
29 |
30 | Maven Multi Module Configuration
31 |
32 | With a multi modules build, you cannot simply use <<>>: you must stage your site first.
33 |
34 | Cli commands to use:
35 |
36 | +------------+
37 | mvn -Preporting site site:stage
38 | mvn scm-publish:publish-scm
39 | +------------+
40 |
41 | These commands work well with mono-module too, even if mono-module could permit some optimizations (everything can be run
42 | in only one Maven invocation).
43 |
44 | * Avoiding Extra Path During Staging
45 |
46 | When staging the site, sometimes extra directories may appear between <<>> and the effective root of the site:
47 | this is caused by the auto-detection algorithm of site root, which cannot detect at which level to stop.
48 |
49 | This can be fixed by configuring the {{{/plugins/maven-site-plugin/stage-mojo.html#topSiteURL}site plugin's topSiteURL parameter}}
50 | (added in version 3.3) with top distribution management site url in a parent pom:
51 |
52 | +-----+
53 |
54 |
55 | site
56 | scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/bimargulies/site-test
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-site-plugin
65 |
66 | scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/bimargulies/site-test
67 |
68 |
69 |
70 |
71 |
72 | +-----+
73 |
--------------------------------------------------------------------------------
/src/site/apt/examples/one-module-configuration.apt.vm:
--------------------------------------------------------------------------------
1 | ------
2 | Maven Mono Module Configuration
3 | ------
4 | Olivier Lamy
5 | Hervé Boutemy
6 | ------
7 | 2012-12-05
8 | ------
9 |
10 | ~~ Licensed to the Apache Software Foundation (ASF) under one
11 | ~~ or more contributor license agreements. See the NOTICE file
12 | ~~ distributed with this work for additional information
13 | ~~ regarding copyright ownership. The ASF licenses this file
14 | ~~ to you under the Apache License, Version 2.0 (the
15 | ~~ "License"); you may not use this file except in compliance
16 | ~~ with the License. You may obtain a copy of the License at
17 | ~~
18 | ~~ http://www.apache.org/licenses/LICENSE-2.0
19 | ~~
20 | ~~ Unless required by applicable law or agreed to in writing,
21 | ~~ software distributed under the License is distributed on an
22 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23 | ~~ KIND, either express or implied. See the License for the
24 | ~~ specific language governing permissions and limitations
25 | ~~ under the License.
26 |
27 | ~~ NOTE: For help with the syntax of this file, see:
28 | ~~ http://maven.apache.org/doxia/references/apt-format.html
29 |
30 | Maven Mono Module Configuration
31 |
32 | <>
33 |
34 | With following configuration you can simply run: <<>>
35 |
36 | +-----------------------
37 |
38 | org.apache.maven.plugins
39 | maven-site-plugin
40 |
41 | true
42 |
43 |
44 |
45 | org.apache.maven.plugins
46 | maven-scm-publish-plugin
47 | ${project.version}
48 |
49 | \${project.reporting.outputDirectory}
50 |
51 |
52 |
53 | scm-publish
54 | site-deploy
55 |
56 | publish-scm
57 |
58 |
59 |
60 |
61 | +-----------------------
62 |
--------------------------------------------------------------------------------
/src/site/apt/index.apt.vm:
--------------------------------------------------------------------------------
1 | ------
2 | Introduction
3 | ------
4 | Benson Margulies
5 | ------
6 | 2013-07-22
7 | ------
8 |
9 | ~~ Licensed to the Apache Software Foundation (ASF) under one
10 | ~~ or more contributor license agreements. See the NOTICE file
11 | ~~ distributed with this work for additional information
12 | ~~ regarding copyright ownership. The ASF licenses this file
13 | ~~ to you under the Apache License, Version 2.0 (the
14 | ~~ "License"); you may not use this file except in compliance
15 | ~~ with the License. You may obtain a copy of the License at
16 | ~~
17 | ~~ http://www.apache.org/licenses/LICENSE-2.0
18 | ~~
19 | ~~ Unless required by applicable law or agreed to in writing,
20 | ~~ software distributed under the License is distributed on an
21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 | ~~ KIND, either express or implied. See the License for the
23 | ~~ specific language governing permissions and limitations
24 | ~~ under the License.
25 |
26 | ~~ NOTE: For help with the syntax of this file, see:
27 | ~~ http://maven.apache.org/doxia/references/apt-format.html
28 |
29 | ${project.name}
30 |
31 | The maven-scm-publish-plugin is a utility plugin to allow publishing Maven
32 | website to any supported SCM (Source Code Management) repository (like Git).
33 | The primary goal was to have an utility plugin to allow Apache projects
34 | to publish Maven websites via the {{{https://infra.apache.org/project-site.html#tools}ASF svnpubsub system}}.
35 |
36 | In addition to SCM operations, it takes care to fix newline inconsistencies
37 | generated by <<>> (see {{{https://issues.apache.org/jira/browse/MSITE-121}MSITE-121}}),
38 | which prevents simple content import to SCM.
39 |
40 | The plugin has been tested with Git SCM too and by example can
41 | {{{./various-tips.html#Git_branch}push content for GitHub Pages}}.
42 |
43 |
44 | * Implementation
45 |
46 | The plugin works from <> by default (see {{{./publish-scm-mojo.html#content}<<>> parameter}}).
47 |
48 | It first checks out the contents of a directory from
49 | the SCM (see {{{./publish-scm-mojo.html#pubScmUrl}<<>> parameter}}) into
50 | <<>> by default (see {{{./publish-scm-mojo.html#checkoutDirectory}<<>> parameter}}).
51 |
52 | Then locally staged content is applied to the check-out, issuing
53 | appropriate SCM commands to add and delete entries, followed by a
54 | check-in.
55 |
56 | The <> parameter to the plugin avoids all
57 | SCM operations, and simply logs out the added, deleted,
58 | and changed files.
59 |
60 | The <> parameter omits the final checkin.
61 | This allows you to visit <<>>, and validate
62 | its contents before submitting to the SCM.
63 |
64 | * Publishing any content to SCM
65 |
66 | Even without any <<>>/Maven project, you can update SCM content with
67 | a local content:
68 |
69 | +-------+
70 | mvn scm-publish:publish-scm -Dscmpublish.pubScmUrl=scm:... -Dscmpublish.content=...path-to-content...
71 | +-------+
72 |
73 | SCM content will be checked-out to a temporary directory, then local content will
74 | be applied to the check-out, before it is checked-in back.
75 |
76 | See {{{./examples/importing-maven-site.html}maven.apache.org content import script}} for an
77 | example.
78 |
79 | <>
80 |
81 | * Known Limitations
82 |
83 | There are 2 known limitations:
84 |
85 | * for Subversion, the plugin can create the initial SCM directory if it does not exist. But for Git by example, if you use a branch,
86 | the branch won't be created: you have to {{{./various-tips.html#Git_branch}create it manually}},
87 |
88 | * the plugin works well for multi-module websites publishing to a complete directory:
89 | you just need to publish <<>> content. But if one module does not publish
90 | its content to the same directory (like Surefire or Enforcer, which have a
91 | base directory and one plugin in <<>>), this staging area can't be simply imported.
92 |
93 | []
94 |
95 | * Future Dreams
96 |
97 | Ideally, scm urls would be supported in <<<\>>> section of the POM, then
98 | publishing would simply be <<>>, without any problems for non-flat multi-modules
99 | sites.
100 |
101 | To reach such a dream, there are some steps:
102 |
103 | * fix inconsistent newlines generated by <<>> (caused by <<>> template and
104 | resources taken from skin jar without fixing newlines): {{{https://issues.apache.org/jira/browse/MSITE-121}MSITE-121}}
105 | is fixed in maven-site-plugin 3.4,
106 |
107 | * improve {{{/wagon/wagon-providers/wagon-scm/}<<>>}} to put a whole directory content
108 | in one commit, and not with one commit per file.
109 |
110 | []
111 |
112 | Then this plugin would be outdated, replaced by natural <<>> goal.
113 |
--------------------------------------------------------------------------------
/src/site/apt/usage.apt.vm:
--------------------------------------------------------------------------------
1 | ------
2 | Usage
3 | ------
4 | Benson Margulies
5 | ------
6 | 2012-02-25
7 | ------
8 |
9 | ~~ Licensed to the Apache Software Foundation (ASF) under one
10 | ~~ or more contributor license agreements. See the NOTICE file
11 | ~~ distributed with this work for additional information
12 | ~~ regarding copyright ownership. The ASF licenses this file
13 | ~~ to you under the Apache License, Version 2.0 (the
14 | ~~ "License"); you may not use this file except in compliance
15 | ~~ with the License. You may obtain a copy of the License at
16 | ~~
17 | ~~ http://www.apache.org/licenses/LICENSE-2.0
18 | ~~
19 | ~~ Unless required by applicable law or agreed to in writing,
20 | ~~ software distributed under the License is distributed on an
21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 | ~~ KIND, either express or implied. See the License for the
23 | ~~ specific language governing permissions and limitations
24 | ~~ under the License.
25 |
26 | ~~ NOTE: For help with the syntax of this file, see:
27 | ~~ http://maven.apache.org/doxia/references/apt-format.html
28 |
29 |
30 | Usage
31 |
32 | The maven-scm-publish-plugin submits modified content to SCM, sites being the most classical case.
33 |
34 | The standard use for sites is:
35 |
36 | +-----------+
37 | mvn -Preporting site site:stage
38 | mvn scm-publish:publish-scm
39 | +-----------+
40 |
41 | which will work both for multi-and mono-modules sites.
42 |
--------------------------------------------------------------------------------
/src/site/apt/various-tips.apt.vm:
--------------------------------------------------------------------------------
1 | ------
2 | Various Tips
3 | ------
4 | Olivier Lamy
5 | ------
6 | 2012-09-04
7 | ------
8 |
9 | ~~ Licensed to the Apache Software Foundation (ASF) under one
10 | ~~ or more contributor license agreements. See the NOTICE file
11 | ~~ distributed with this work for additional information
12 | ~~ regarding copyright ownership. The ASF licenses this file
13 | ~~ to you under the Apache License, Version 2.0 (the
14 | ~~ "License"); you may not use this file except in compliance
15 | ~~ with the License. You may obtain a copy of the License at
16 | ~~
17 | ~~ http://www.apache.org/licenses/LICENSE-2.0
18 | ~~
19 | ~~ Unless required by applicable law or agreed to in writing,
20 | ~~ software distributed under the License is distributed on an
21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 | ~~ KIND, either express or implied. See the License for the
23 | ~~ specific language governing permissions and limitations
24 | ~~ under the License.
25 |
26 | ~~ NOTE: For help with the syntax of this file, see:
27 | ~~ http://maven.apache.org/doxia/references/apt-format.html
28 |
29 | Various tips for using this plugin
30 |
31 | * URL format
32 |
33 | You must use a scm url format:
34 |
35 | +----------------+
36 | scm:
37 | +----------------+
38 |
39 | Example for svn: <<>>
40 |
41 | And configure is as it:
42 |
43 | +----------------+
44 |
45 |
46 | site_id
47 | scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/plugins/maven-scm-publish-plugin/
48 |
49 |
50 | +----------------+
51 |
52 | <>: with svn, if the remote url doesn't exist, it will be created.
53 |
54 | * Git branch
55 |
56 | To use Git branch (for example: {{{https://help.github.com/articles/user-organization-and-project-pages/}GitHub <<>>}})
57 |
58 | +----------------+
59 |
60 |
61 | site_id
62 | ${project.scm.developerConnection}
63 |
64 |
65 | ...
66 |
67 | org.apache.maven.plugins
68 | maven-scm-publish-plugin
69 | ${project.version}
70 |
71 | gh-pages
72 |
73 |
74 | +----------------+
75 |
76 | <>, as a Git orphan branch:
77 |
78 | 1. <<>> to create the branch locally,
79 |
80 | 2. <<>> to clean the branch content and let it empy,
81 |
82 | 3. copy an initial site content,
83 |
84 | 4. commit and push: <<>>, <<>>, <<>>
85 |
86 | []
87 |
88 | * Improving SCM Checkout Performance
89 |
90 | By default, a complete checkout is done. You can configure the plugin to try update rather than a full checkout/clone
91 |
92 | +----------------+
93 |
94 | org.apache.maven.plugins
95 | maven-scm-publish-plugin
96 | ${project.version}
97 |
98 | true
99 |
100 |
101 | +----------------+
102 |
103 | By default, the scm content is checked-out/cloned to <<<$\{project.build.directory}/scmpublish-checkout>>>, so when running <<>>,
104 | all the content is deleted. You can configure a path to your machine to avoid full checkout.
105 | A recommended way is to use a property with a default value that your colleague will be able to override in their settings.
106 |
107 | +----------------+
108 |
109 | ...
110 |
111 | ${user.home}
112 | \${siteMainDirectory}/my-site-content-scm
113 | ...
114 |
115 |
116 |
117 | org.apache.maven.plugins
118 | maven-scm-publish-plugin
119 | ${project.version}
120 |
121 | ${scmPubCheckoutDirectory}
122 | true
123 |
124 |
125 | +----------------+
126 |
--------------------------------------------------------------------------------
/src/site/resources/download.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | #
20 | # Just call the standard mirrors.cgi script. It will use download.html
21 | # as the input template.
22 | exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
--------------------------------------------------------------------------------
/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
23 | ${project.scm.url}
24 |
25 |
26 |
35 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/site/xdoc/download.xml.vm:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 |
24 | Download ${project.name} Source
25 |
26 |
27 |
28 |
29 | ${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build
30 | ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.
31 |
32 | You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24
33 | hours to reach all mirrors.
34 |
35 | In order to guard against corrupted downloads/installations, it is highly recommended to
36 | verify the signature
37 | of the release bundles against the public KEYS used by the Apache Maven
38 | developers.
39 |
40 | ${project.name} is distributed under the Apache License, version 2.0.
41 |
42 | We strongly encourage our users to configure a Maven repository mirror closer to their location, please read How to Use Mirrors for Repositories.
43 |
44 |
45 |
46 |
47 |
48 | [if-any logo]
49 |
50 |
52 |
53 | [end]
54 | The currently selected mirror is
55 | [preferred].
56 | If you encounter a problem with this mirror,
57 | please select another mirror.
58 | If all mirrors are failing, there are
59 | backup
60 | mirrors
61 | (at the end of the mirrors list) that should be available.
62 |
63 |
64 |
85 |
86 |
87 | You may also consult the
88 | complete list of
89 | mirrors.
90 |
91 |
92 |
93 |
94 |
95 |
96 | This is the current stable version of ${project.name}.
97 |
98 |
116 |
117 |
118 |
119 |
120 | Older non-recommended releases can be found on our archive site.
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------