Skip to content

Commit

Permalink
Add documentation and set under include parameter to match existing…
Browse files Browse the repository at this point in the history
… `exclude` parameter
  • Loading branch information
shashken committed Sep 20, 2023
1 parent 495031b commit 9ff7f87
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
22 changes: 22 additions & 0 deletions docs/configuration/basic_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ scmVersion {
}
```

Use the `include` configuration parameter within a `monorepos` block to identify dependencies
directories that should be added to consideration when calculating whether to increment
the version of the parent project. For example if we have 2 modules `A` & `B` in our repository,
and we have a composite build of `A` that has a dependency on `B` we can set on `A` a dependency on `B` and get
increment to the version of `A` even if its code did not change, but we only had changes in `B`

Note: these values need to be relative to project root


```
scmVersion {
monorepos {
include([
"common/sdkA",
"common/sdkB"
])
}
}
```

Version calculation rules:
1. Changes to files within a submodule increment that submodule's version only.
2. Changes to a submodule do not cause a change to the parent project's version if
Expand All @@ -138,6 +158,8 @@ the parent is set to ignore that submodule, via `exclude()`.
`exclude()` will cause the parent project's version to increment but not the
versions of any submodules. If this is desired then consider wiring the `createRelease` or
`release` tasks of the submodules to be dependencies of the tasks of the same name in the parent.
4. Changes to directories provided with `include` configuration will also cause an
incrementation of version (even if the main module did not have any changes)

## Releasing

Expand Down
3 changes: 2 additions & 1 deletion docs/examples/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ with these key configuration objects available for reference:

* [RepositoryConfig](https://github.com/allegro/axion-release-plugin/blob/main/src/main/groovy/pl/allegro/tech/build/axion/release/domain/RepositoryConfig.groovy)

* [MonorepoConfig](https://github.com/allegro/axion-release-plugin/blob/main/src/main/java/pl/allegro/tech/build/axion/release/domain/MonorepoConfig.java)
* [
* MonorepoConfig](https://github.com/allegro/axion-release-plugin/blob/main/src/main/java/pl/allegro/tech/build/axion/release/domain/MonorepoConfig.java)

* [NextVersionConfig](https://github.com/allegro/axion-release-plugin/blob/main/src/main/java/pl/allegro/tech/build/axion/release/domain/NextVersionConfig.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;

import java.util.LinkedList;
import java.util.List;

public abstract class MonorepoConfig extends BaseExtension {
@Input
public abstract ListProperty<String> getProjectDirs();
@Input
public abstract SetProperty<String> getDependenciesFolders();
public abstract SetProperty<String> getDependenciesDirs();

@Internal
public ListProperty<String> getExcludeDirs() { return getProjectDirs(); }
Expand All @@ -24,4 +23,8 @@ public void exclude(String dir) {
public void exclude(List<String> dirs) {
getProjectDirs().addAll(dirs);
}

public void include(List<String> dirs) {
getDependenciesDirs().addAll(dirs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public VersionResolver(ScmRepository repository, String projectRootRelativePath)

public VersionContext resolveVersion(VersionProperties versionProperties, TagProperties tagProperties, NextVersionProperties nextVersionProperties) {
ScmPosition latestChangePosition = repository.positionOfLastChangeIn(
projectRootRelativePath, versionProperties.getMonorepoConfig().getProjectDirs().get(), versionProperties.getMonorepoConfig().getDependenciesFolders().get()
projectRootRelativePath, versionProperties.getMonorepoConfig().getProjectDirs().get(), versionProperties.getMonorepoConfig().getDependenciesDirs().get()
);

VersionFactory versionFactory = new VersionFactory(versionProperties, tagProperties, nextVersionProperties, latestChangePosition, repository.isLegacyDefTagnameRepo());
Expand Down Expand Up @@ -102,7 +102,7 @@ private VersionInfo readVersions(
// Now if we test for anywhere from C to E we should get 1.3.0
String tagCommitRevision = currentVersionInfo.commit != null ? currentVersionInfo.commit : "";
onLatestVersion = repository.isIdenticalForPath(projectRootRelativePath, latestChangePosition.getRevision(),tagCommitRevision);
for (String dependency: versionProperties.getMonorepoConfig().getDependenciesFolders().get()) {
for (String dependency: versionProperties.getMonorepoConfig().getDependenciesDirs().get()) {
onLatestVersion = onLatestVersion && repository.isIdenticalForPath(dependency, latestChangePosition.getRevision(),tagCommitRevision);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public ScmPosition positionOfLastChangeIn(String path, List<String> excludeSubFo
assertPathExists(unixStylePath);
logCommand = jgitRepository.log().setMaxCount(1).addPath(unixStylePath);
for (String dep: dependenciesFolders) {
logCommand.addPath(dep);
logCommand.addPath(asUnixPath(dep));
}
}
lastCommit = logCommand.call().iterator().next();
Expand Down

0 comments on commit 9ff7f87

Please sign in to comment.