-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task to update plugin and dependencies #193
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
96a19a8
autodiscover usecases
santitigaga d82d21a
update plugin and begining updating dependencies
santitigaga e679d63
update the dependencies with the plugin
santitigaga 99cd5a6
increase tests
santitigaga 6ee3008
increase tests
santitigaga 6589aa5
increase tests
santitigaga 235de43
refactor
santitigaga 496abbc
refactor
santitigaga 967784c
refactor
santitigaga 2b50267
refactor
santitigaga 0c54ec5
Merge branch 'master' into updateTask
santitigaga c3f414f
refactor
santitigaga 06134ee
fix conflicts in tests
santitigaga cf31a1c
fix conflicts in tests
santitigaga f13932e
validate the plugin version in all tasks
santitigaga e0341c6
refactor
santitigaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
49 changes: 49 additions & 0 deletions
49
src/main/java/co/com/bancolombia/adapters/RestService.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,49 @@ | ||
package co.com.bancolombia.adapters; | ||
|
||
import co.com.bancolombia.models.DependencyRelease; | ||
import co.com.bancolombia.models.Release; | ||
import co.com.bancolombia.utils.RestConsumer; | ||
import java.util.Optional; | ||
import org.gradle.api.logging.Logger; | ||
import org.gradle.api.logging.Logging; | ||
|
||
public class RestService { | ||
public static final String PLUGIN_RELEASES = | ||
"http://api.github.com/repos/bancolombia/scaffold-clean-architecture/releases"; | ||
public static final String DEPENDENCY_RELEASES = | ||
"https://search.maven.org/solrsearch/select?q=g:%22%s%22+AND+a:%22%s%22&core=gav&rows=1&wt=json"; | ||
private final Logger logger = Logging.getLogger(RestService.class); | ||
|
||
public Release getLatestPluginVersion() { | ||
try { | ||
return RestConsumer.callRequest(PLUGIN_RELEASES, Release[].class)[0]; | ||
} catch (Exception e) { | ||
logger.lifecycle( | ||
"\tx Can't check the latest version of the plugin, reason: {}", e.getMessage()); | ||
return null; | ||
} | ||
} | ||
|
||
public Optional<DependencyRelease> getTheLastDependencyRelease(String dependency) { | ||
try { | ||
return Optional.of( | ||
RestConsumer.callRequest(getDependencyEndpoint(dependency), DependencyRelease.class)); | ||
} catch (Exception e) { | ||
logger.lifecycle( | ||
"\tx Can't update this dependency {}, reason: {}", dependency, e.getMessage()); | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
private String getDependencyEndpoint(String dependency) { | ||
String[] id = dependency.split(":"); | ||
if (id.length >= 2) { | ||
return DEPENDENCY_RELEASES.replaceFirst("%s", id[0]).replace("%s", id[1]); | ||
} | ||
throw new IllegalArgumentException( | ||
dependency | ||
+ " is not a valid dependency usage: gradle u " | ||
+ "--dependency " | ||
+ "dependency.group:artifact"); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/co/com/bancolombia/models/DependencyRelease.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,25 @@ | ||
package co.com.bancolombia.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
@Getter | ||
@JsonDeserialize(using = DependencyReleasesDeserializer.class) | ||
public class DependencyRelease { | ||
@JsonProperty("v") | ||
private String version; | ||
|
||
@JsonProperty("g") | ||
private String group; | ||
|
||
@JsonProperty("a") | ||
private String artifact; | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s:%s:%s", this.getGroup(), this.getArtifact(), this.getVersion()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/co/com/bancolombia/models/DependencyReleasesDeserializer.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,32 @@ | ||
package co.com.bancolombia.models; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import java.io.IOException; | ||
|
||
public class DependencyReleasesDeserializer extends StdDeserializer<DependencyRelease> { | ||
|
||
public DependencyReleasesDeserializer() { | ||
this(null); | ||
} | ||
|
||
public DependencyReleasesDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public DependencyRelease deserialize(JsonParser jp, DeserializationContext ctxt) | ||
throws IOException { | ||
|
||
JsonNode productNode = jp.getCodec().readTree(jp); | ||
DependencyRelease dependencyRelease = new DependencyRelease(); | ||
dependencyRelease.setGroup(productNode.get("response").get("docs").get(0).get("g").textValue()); | ||
dependencyRelease.setArtifact( | ||
productNode.get("response").get("docs").get(0).get("a").textValue()); | ||
dependencyRelease.setVersion( | ||
productNode.get("response").get("docs").get(0).get("v").textValue()); | ||
return dependencyRelease; | ||
} | ||
} |
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,16 @@ | ||
package co.com.bancolombia.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.time.OffsetDateTime; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
@Getter | ||
public class Release { | ||
@JsonProperty("tag_name") | ||
private String tagName; | ||
|
||
@JsonProperty("published_at") | ||
private OffsetDateTime publishedAt; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (latestRelease != null && !latestRelease.getTagName().equals(Utils.getVersionPlugin()))
in a if the evaluation is left to right