Skip to content

Commit

Permalink
[4269] Just use ProfileActivation. There's only 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Cox committed Jul 31, 2024
1 parent 1db298d commit 2f598bc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,6 @@ public static class Profile implements WithProfiles.Profile {
@Nullable
RawRepositories repositories;

@Override
public boolean isActive() {
return activation != null && activation.isActive();
}

@Override
public boolean isActiveByDefault() {
return activation != null && Boolean.TRUE.equals(activation.getActiveByDefault());
}

/**
* Returns true if this profile was activated either by the supplied active profiles
* or by activation property, <i>but not solely by activeByDefault</i>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.openrewrite.maven;

import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.maven.tree.ProfileActivation;

import java.util.List;
import java.util.stream.Collectors;

public interface WithProfiles<P extends WithProfiles.Profile> {
interface Profile {
@Nullable
String getId();
boolean isActive();
boolean isActiveByDefault();

@Nullable
ProfileActivation getActivation();
}

List<P> listProfiles();
Expand All @@ -28,7 +33,7 @@ default List<P> activeProfiles(final Iterable<String> userSpecifiedProfiles) {
}

return profiles.stream()
.filter(p -> Boolean.TRUE.equals(p.isActiveByDefault()))
.filter(p -> p.getActivation() != null && Boolean.TRUE.equals(p.getActivation().getActiveByDefault()))
.collect(Collectors.toList());
}

Expand All @@ -40,7 +45,7 @@ default boolean isActivated(final P profile, final Iterable<String> userSpecifie
}
}
}
return profile.isActive();
return profile.getActivation() != null && profile.getActivation().isActive();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ public class Profile implements WithProfiles.Profile {
List<Plugin> plugins;
List<Plugin> pluginManagement;

@Override
public boolean isActive() {
return activation != null && activation.isActive();
}

@Override
public boolean isActiveByDefault() {
return activation != null && Boolean.TRUE.equals(activation.getActiveByDefault());
}

/**
* Returns true if this profile was activated either by the supplied active profiles
* or by activation property, <i>but not solely by activeByDefault</i>.
Expand Down

0 comments on commit 2f598bc

Please sign in to comment.