// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
// 
//     boolean apply(RuleEvaluationContext evaluationContext);
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
// 
//     @Nonnull
//     SemVersion evaluate(Project project, GitRepository gitRepository);
// 
//     @Nonnull
//     static VersioningRulesBuilder builder() {
//         return new DefaultVersioningRulesBuilder();
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
// 
//     @Nonnull
//     VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
// 
//     @Nonnull
//     VersioningRulesBuilder addBeforeRule(Rule rule);
// 
//     @Nonnull
//     VersioningRulesBuilder addRule(Rule rule);
// 
//     @Nonnull
//     VersioningRulesBuilder addAfterRule(Rule rule);
// 
//     @Nonnull
//     VersioningRules build();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
// 
//     private final Logger logger = Logging.getLogger(getClass());
// 
//     private final SemVersion baseVersion;
//     private final List<Rule> rules;
// 
// 
//     DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
//         this.baseVersion = baseVersion;
//         this.rules = ImmutableList.copyOf(rules);
//     }
// 
// 
//     @Override
//     @Nonnull
//     public SemVersion evaluate(Project project, GitRepository gitRepository) {
// 
//         logger.info("Starting rule evaluation");
// 
//         logger.info("Starting with base version: {}", baseVersion);
//         MutableSemVersion version = baseVersion.cloneAsMutable();
//         RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
// 
//         for (Rule rule : rules) {
// 
//             SemVersion versionBefore = version.toImmutable();
// 
//             logger.info("Applying rule: [{}]", rule);
//             boolean shouldContinue = rule.apply(evaluationContext);
// 
//             if (logger.isDebugEnabled()) {
//                 SemVersion versionAfter = version.toImmutable();
//                 if (!versionBefore.equals(versionAfter)) {
//                     logger.debug("Version was modified by rule; is now {}", versionAfter);
//                 } else {
//                     logger.debug("Version was not modified by rule");
//                 }
//             }
// 
//             if (!shouldContinue) {
//                 logger.info("Skipping evaluation of other rules");
//                 break;
//             }
//         }
// 
//         SemVersion finalVersion = version.toImmutable();
// 
//         logger.info("Finished rule evaluation; final version is: {}", finalVersion);
// 
//         return finalVersion;
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
// 
//     int getMajor();
// 
//     int getMinor();
// 
//     int getPatch();
// 
//     @Nullable
//     String getPrereleaseTag();
// 
//     @Nullable
//     String getBuildMetadata();
// 
// 
//     @Nonnull
//     default MutableSemVersion cloneAsMutable() {
//         return new MutableSemVersionImpl()
//                 .setFrom(this);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch,
//                              @Nullable String prereleaseTag,
//                              @Nullable String buildMetadata) {
//         return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
//         return create(major, minor, patch, prereleaseTag, null);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch) {
//         return create(major, minor, patch, null, null);
//     }
// 
// 
//     @Nonnull
//     static SemVersion immutableCopyOf(SemVersion version) {
//         if (version instanceof ImmutableSemVersionImpl) {
//             return version;
// 
//         } else {
//             return create(version.getMajor(), version.getMinor(), version.getPatch(),
//                     version.getPrereleaseTag(), version.getBuildMetadata());
//         }
//     }
// 
// 
//     @Nonnull
//     static SemVersion parse(String input) {
//         return SemVersionParser.parse(input);
//     }
// }


import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;





public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {

    private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);

    private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
// 
//     boolean apply(RuleEvaluationContext evaluationContext);
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
// 
//     @Nonnull
//     SemVersion evaluate(Project project, GitRepository gitRepository);
// 
//     @Nonnull
//     static VersioningRulesBuilder builder() {
//         return new DefaultVersioningRulesBuilder();
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
// 
//     @Nonnull
//     VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
// 
//     @Nonnull
//     VersioningRulesBuilder addBeforeRule(Rule rule);
// 
//     @Nonnull
//     VersioningRulesBuilder addRule(Rule rule);
// 
//     @Nonnull
//     VersioningRulesBuilder addAfterRule(Rule rule);
// 
//     @Nonnull
//     VersioningRules build();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
// 
//     private final Logger logger = Logging.getLogger(getClass());
// 
//     private final SemVersion baseVersion;
//     private final List<Rule> rules;
// 
// 
//     DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
//         this.baseVersion = baseVersion;
//         this.rules = ImmutableList.copyOf(rules);
//     }
// 
// 
//     @Override
//     @Nonnull
//     public SemVersion evaluate(Project project, GitRepository gitRepository) {
// 
//         logger.info("Starting rule evaluation");
// 
//         logger.info("Starting with base version: {}", baseVersion);
//         MutableSemVersion version = baseVersion.cloneAsMutable();
//         RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
// 
//         for (Rule rule : rules) {
// 
//             SemVersion versionBefore = version.toImmutable();
// 
//             logger.info("Applying rule: [{}]", rule);
//             boolean shouldContinue = rule.apply(evaluationContext);
// 
//             if (logger.isDebugEnabled()) {
//                 SemVersion versionAfter = version.toImmutable();
//                 if (!versionBefore.equals(versionAfter)) {
//                     logger.debug("Version was modified by rule; is now {}", versionAfter);
//                 } else {
//                     logger.debug("Version was not modified by rule");
//                 }
//             }
// 
//             if (!shouldContinue) {
//                 logger.info("Skipping evaluation of other rules");
//                 break;
//             }
//         }
// 
//         SemVersion finalVersion = version.toImmutable();
// 
//         logger.info("Finished rule evaluation; final version is: {}", finalVersion);
// 
//         return finalVersion;
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
// 
//     int getMajor();
// 
//     int getMinor();
// 
//     int getPatch();
// 
//     @Nullable
//     String getPrereleaseTag();
// 
//     @Nullable
//     String getBuildMetadata();
// 
// 
//     @Nonnull
//     default MutableSemVersion cloneAsMutable() {
//         return new MutableSemVersionImpl()
//                 .setFrom(this);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch,
//                              @Nullable String prereleaseTag,
//                              @Nullable String buildMetadata) {
//         return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
//         return create(major, minor, patch, prereleaseTag, null);
//     }
// 
// 
//     @Nonnull
//     static SemVersion create(int major, int minor, int patch) {
//         return create(major, minor, patch, null, null);
//     }
// 
// 
//     @Nonnull
//     static SemVersion immutableCopyOf(SemVersion version) {
//         if (version instanceof ImmutableSemVersionImpl) {
//             return version;
// 
//         } else {
//             return create(version.getMajor(), version.getMinor(), version.getPatch(),
//                     version.getPrereleaseTag(), version.getBuildMetadata());
//         }
//     }
// 
// 
//     @Nonnull
//     static SemVersion parse(String input) {
//         return SemVersionParser.parse(input);
//     }
// }


// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;

package org.unbrokendome.gradle.plugins.gitversion.internal;





public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {

    private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);

    private SemVersion baseVersion = DEFAULT_BASE_VERSION;
    private List<Rule> beforeRules = new ArrayList<>(1);