Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
146 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
local-build-plugins/src/main/java/org/hibernate/orm/docs/PublishMigrationGuide.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.hibernate.orm.docs; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.file.DirectoryProperty; | ||
import org.gradle.api.provider.Provider; | ||
import org.gradle.api.tasks.Input; | ||
import org.gradle.api.tasks.InputDirectory; | ||
import org.gradle.api.tasks.PathSensitive; | ||
import org.gradle.api.tasks.PathSensitivity; | ||
import org.gradle.api.tasks.TaskAction; | ||
|
||
import org.hibernate.orm.ReleaseFamilyIdentifier; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
public abstract class PublishMigrationGuide extends DefaultTask { | ||
public static final String NAME = "publishMigrationGuide"; | ||
|
||
private final Provider<String> docServerUrl; | ||
|
||
private final ReleaseFamilyIdentifier currentlyBuildingFamily; | ||
private final DirectoryProperty migrationGuideDirectory; | ||
|
||
@Inject | ||
public PublishMigrationGuide(DocumentationPublishing config) { | ||
setGroup( "Release" ); | ||
setDescription( "Publishes the migration-guide associated with the current branch. " + | ||
"Intended for incremental publishing of the guide for corrections, etc. without doing a full release. " + | ||
"Note that this is not needed when doing a release as the migration-guide is published as part of that workflow." ); | ||
|
||
getInputs().property( "hibernate-version", getProject().getVersion() ); | ||
|
||
docServerUrl = config.getDocServerUrl(); | ||
currentlyBuildingFamily = config.getReleaseFamilyIdentifier(); | ||
migrationGuideDirectory = getProject().getObjects().directoryProperty(); | ||
} | ||
|
||
@InputDirectory | ||
@PathSensitive(PathSensitivity.RELATIVE) | ||
public DirectoryProperty getMigrationGuideDirectory() { | ||
return migrationGuideDirectory; | ||
} | ||
|
||
@Input | ||
public Provider<String> getDocServerUrl() { | ||
return docServerUrl; | ||
} | ||
|
||
@TaskAction | ||
public void uploadMigrationGuide() { | ||
final String base = docServerUrl.get(); | ||
final String normalizedBase = base.endsWith( "/" ) ? base : base + "/"; | ||
final String url = normalizedBase + currentlyBuildingFamily.toExternalForm() + "/migration-guide/"; | ||
|
||
RsyncHelper.rsync( migrationGuideDirectory.get(), url, getProject() ); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
local-build-plugins/src/main/java/org/hibernate/orm/docs/RsyncHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.hibernate.orm.docs; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.file.FileSystemLocation; | ||
|
||
/** | ||
* Helper for performing rsync system commands, mainly used to centralize | ||
* the command options | ||
* | ||
* @author Steve Ebersole | ||
*/ | ||
public class RsyncHelper { | ||
public static void rsync( | ||
FileSystemLocation source, | ||
String targetUrl, | ||
Project project) { | ||
project.exec( (exec) -> { | ||
exec.executable( "rsync" ); | ||
exec.args( "--port=2222", "-avz", source.getAsFile().getAbsolutePath(), targetUrl ); | ||
} ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters