Skip to content

Commit

Permalink
Push more documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Nov 24, 2024
1 parent b48c7ee commit 8b12836
Show file tree
Hide file tree
Showing 12 changed files with 1,302 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ public GitExtension(@NotNull Project project) {
final int lastSlash = it.lastIndexOf('/');
return it.substring(lastSlash + 1);
}));
this.getOrganizationName().set(this.getGithubUrl().map(it -> {
//Extract the organization name from the url.
final int lastSlash = it.lastIndexOf('/');
final int secondLastSlash = it.lastIndexOf('/', lastSlash - 1);
return it.substring(secondLastSlash + 1, lastSlash);
}));
this.getOrganizationUrl().set(this.getGithubUrl().map(it -> {
//Extract the organization url from the url.
final int lastSlash = it.lastIndexOf('/');
return it.substring(0, lastSlash);
}));
}

/**
Expand Down Expand Up @@ -106,6 +117,20 @@ public GitExtension(@NotNull Project project) {
*/
public abstract Property<String> getRepositoryName();

/**
* Gets the organization name property.
*
* @return The organization name property.
*/
public abstract Property<String> getOrganizationName();

/**
* Gets the organization url property.
*
* @return The organization url property.
*/
public abstract Property<String> getOrganizationUrl();

/**
* Lazy value source for the current branch.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import org.gradle.internal.instrumentation.api.annotations.ToBeReplacedByLazyProperty;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.*;

/**
* Extension that configures the Maven publishing plugin.
Expand All @@ -43,6 +40,7 @@ private enum PublishingMode {
UNKNOWN,
LDTTEAM,
GITHUB,
CUSTOM,
LOCAL;

public boolean includedInMaven() {
Expand Down Expand Up @@ -80,7 +78,7 @@ public void pom(Action<? super POM> configure) {
* <p>
* Also configures the POM to publish to the LDTTeam Maven repository.
*/
public void publishToLDTTeamMaven() {
public void publishToLDTTeam() {
//LDTTeam always overrides configured POM settings
pom(POM::distributeOnLDTTeamMaven);

Expand All @@ -102,6 +100,38 @@ public void publishToLDTTeamMaven() {
}
}

/**
* Configures the publishing system to publish the project to a custom Maven repository.
* <p>
* Also configures the POM to publish to the custom Maven repository.
*
* @param repositoryName the name of the repository
* @param repositoryUrl the URL of the repository
*/
public void publishTo(String repositoryName, String repositoryUrl) {
if (publishingMode.includedInMaven()) {
publishingMode = PublishingMode.CUSTOM;
pom(pom -> pom.distributeOnCustomRepo(repositoryUrl));
}

final PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
final Provider<String> username = project.getProviders().environmentVariable("%s_USERNAME".formatted(repositoryName.toUpperCase(Locale.ROOT)));
final Provider<String> password = project.getProviders().environmentVariable("%S_TOKEN".formatted(repositoryName.toUpperCase(Locale.ROOT)));

if (username.isPresent() && password.isPresent()) {
publishing.repositories(mavenRepositories -> {
mavenRepositories.maven(mavenRepository -> {
mavenRepository.setUrl(repositoryUrl);
mavenRepository.credentials(credentials -> {
credentials.setUsername(username.get());
credentials.setPassword(password.get());
});
mavenRepository.setName(repositoryName);
});
});
}
}

/**
* Configures the publishing system to publish the project to the local Maven repository.
* <p>
Expand Down Expand Up @@ -309,6 +339,15 @@ public void distributeOnGithubPackages() {
});
}

/**
* Configures distribution to happen via a custom repository.
*/
public void distributeOnCustomRepo(String repositoryUrl) {
distributionManagement(distributionManagement -> {
distributionManagement.getDownloadUrl().set(repositoryUrl);
});
}

/**
* Configures the POM using information stored in git.
*/
Expand All @@ -334,6 +373,8 @@ public void usingGit() {
contributors(contributors -> {
List<GitExtension.Developer> developerList = new ArrayList<>(git.getDevelopers().get());

developerList.sort(Comparator.comparing(GitExtension.Developer::count).reversed());

if (developerList.size() > 5) {
developerList = developerList.subList(0, 5);
}
Expand All @@ -357,6 +398,11 @@ public void usingGit() {
ciManagement.getSystem().set("GitHub Actions");
ciManagement.getUrl().set(git.getGithubUrl() + "/actions");
});

organization(organization -> {
organization.getName().set(git.getOrganizationName());
organization.getUrl().set(git.getOrganizationUrl());
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public NeoGradleExtension(final Project project) {
jar.getArchiveClassifier().set(getPrimaryJarClassifier());

jar.manifest(manifest -> {
manifest.attributes(Map.of("FMLModType", getIsFmlLibrary().map(isFmlLibrary -> isFmlLibrary ? "LIBRARY" : "MOD")));
manifest.attributes(Map.of("FMLModType", getIsLibrary().map(isFmlLibrary -> isFmlLibrary ? "LIBRARY" : "MOD")));
});
});

Expand Down Expand Up @@ -148,7 +148,7 @@ public void interfaceInjection(Object file) {
*
* @param mod the additional data gen mod
*/
public void dataGenMod(String mod) {
public void additionalDataGenMod(String mod) {
getAdditionalDataGenMods().add(mod);
}

Expand All @@ -157,5 +157,5 @@ public void dataGenMod(String mod) {
*
* @return Indicates whether the project is an FML library.
*/
public abstract Property<Boolean> getIsFmlLibrary();
public abstract Property<Boolean> getIsLibrary();
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ public void fromProject() {
*/
public abstract ListProperty<String> getMatching();

/**
* Adds a matching pattern.
*
* @param patterns The patterns to add.
*/
public void matching(String... patterns) {
getMatching().addAll(patterns);
}

/**
* Interpolates the mods.toml files.
* Regardless of whether this is neoforge or mcf.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public SourceSetExtension(final Project project) {
});

getUniversalJarSourceSets().addAll(
configuration.getIsPartOfUniversalJar()
configuration.getIsPartOfPrimaryJar()
.map(isPartOfUniversalJar -> isPartOfUniversalJar ? sourceSet : null)
.filter(Objects::nonNull)
.map(Collections::singletonList)
Expand Down Expand Up @@ -140,7 +140,7 @@ public NamedDomainObjectContainer<SourceSetConfiguration> getSourceSets() {
public void api(final Action<SourceSetConfiguration> action) {
create(JavaPlugin.API_CONFIGURATION_NAME, configuration -> {
action.execute(configuration);
configuration.getIsPartOfUniversalJar().set(true);
configuration.getIsPartOfPrimaryJar().set(true);
});
}

Expand Down Expand Up @@ -483,7 +483,7 @@ public SourceSetConfiguration(ObjectFactory objectFactory, String name, SourceSe

this.dependencies = objectFactory.newInstance(SourceSetDependencies.class);

getIsPartOfUniversalJar().convention(SourceSet.isMain(sourceSet));
getIsPartOfPrimaryJar().convention(SourceSet.isMain(sourceSet));
getIsPublished().convention(SourceSet.isMain(sourceSet));
}

Expand Down Expand Up @@ -511,7 +511,7 @@ public SourceSet getSourceSet() {
*
* @return The property.
*/
public abstract Property<Boolean> getIsPartOfUniversalJar();
public abstract Property<Boolean> getIsPartOfPrimaryJar();

/**
* Indicates whether the source set is published.
Expand Down
12 changes: 6 additions & 6 deletions website/docs/02-getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To apply the Tableau bootstrap plugin to your project, you can use the Gradle Pl
You need to apply the plugin to the `settings` of your project, which you can do as follows:
<Tabs groupId="gradle-code">
<TabItem value="groovy" label="Groovy">
```groovy settings.gradle
```groovy title="settings.gradle"
plugins {
// Replace the version with the latest version,
// which you can find here: https://github.com/ldtteam/Tableau/tags
Expand All @@ -37,7 +37,7 @@ plugins {
```
</TabItem>
<TabItem value="kotlin" label="Kotlin">
```kotlin settings.gradle.kts
```kotlin title="settings.gradle.kts"
plugins {
// Replace the version with the latest version,
// which you can find here: https://github.com/ldtteam/Tableau/tags
Expand All @@ -52,7 +52,7 @@ If you want to use the Tableau Maven repository, you need to add the repository
You can do this as follows:
<Tabs groupId="gradle-code">
<TabItem value="groovy" label="Groovy">
```groovy settings.gradle
```groovy title="settings.gradle"
pluginManagement {
repositories {
maven {
Expand All @@ -69,7 +69,7 @@ plugins {
```
</TabItem>
<TabItem value="kotlin" label="Kotlin">
```kotlin settings.gradle.kts
```kotlin title="settings.gradle.kts"
pluginManagement {
repositories {
maven {
Expand Down Expand Up @@ -98,7 +98,7 @@ To do this, you need to add the following to your `build` file:

<Tabs groupId="gradle-code">
<TabItem value="groovy" label="Groovy">
```groovy build.gradle
```groovy title="build.gradle"
tableau {
mod {
// Mod information
Expand All @@ -111,7 +111,7 @@ tableau {
```
</TabItem>
<TabItem value="kotlin" label="Kotlin">
```kotlin build.gradle.kts
```kotlin title="build.gradle.kts"
tableau {
mod {
// Mod information
Expand Down
Loading

0 comments on commit 8b12836

Please sign in to comment.