Skip to content

Commit 6147ba7

Browse files
some of the worst code in the repo but i can still clean it up
1 parent 7de7f5d commit 6147ba7

File tree

5 files changed

+736
-1
lines changed

5 files changed

+736
-1
lines changed

gradle/buildPlugins/src/main/groovy/info.ankin.projects.library-conventions.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
java {
8-
withJavadocJar()
8+
// withJavadocJar()
99
withSourcesJar()
1010
}
1111

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
plugins {
2+
id 'info.ankin.projects.conventions'
23
id 'java-gradle-plugin'
34
id 'com.gradle.plugin-publish' version '1.2.1'
45
}
6+
7+
version '0.1.0'
8+
9+
tasks.named('javadoc') { enabled false }
10+
11+
dependencies {
12+
implementation(gradleApi())
13+
}
14+
15+
gradlePlugin {
16+
plugins {
17+
codeArtifactCredentials {
18+
// noinspection GroovyAssignabilityCheck
19+
id = 'info.ankin.projects.code-artifact-credentials'
20+
// noinspection GroovyAssignabilityCheck
21+
implementationClass = 'info.ankin.projects.gradle.plugins.cac.CodeArtifactCredsPlugin'
22+
}
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package info.ankin.projects.gradle.plugins.cac;
2+
3+
import lombok.Getter;
4+
import org.gradle.api.Action;
5+
import org.gradle.api.provider.Property;
6+
import org.gradle.api.tasks.Nested;
7+
8+
import javax.inject.Inject;
9+
import java.nio.file.Path;
10+
11+
@SuppressWarnings("CommentedOutCode")
12+
public abstract class CodeArtifactCredsExtension {
13+
private final CodeArtifactCredsPlugin plugin;
14+
15+
@Getter
16+
private String awsCliPath;
17+
18+
@Inject
19+
public CodeArtifactCredsExtension(CodeArtifactCredsPlugin plugin) {
20+
this.plugin = plugin;
21+
}
22+
23+
public void setAwsCliPath(String awsCliPath) {
24+
plugin.awsCliPath = Path.of(awsCliPath);
25+
this.awsCliPath = awsCliPath;
26+
}
27+
28+
public void awsCliPath(String awsCliPath) {
29+
setAwsCliPath(awsCliPath);
30+
}
31+
32+
public String awsAccount() {
33+
return plugin.accountCache.valueFor(getAuth());
34+
}
35+
36+
// /**
37+
// * the plugin will apply credentials for any repo matching the pattern
38+
// *
39+
// * @return if this is enabled
40+
// */
41+
// abstract public Property<Boolean> getAutoDetect();
42+
//
43+
// public void autoDetect(Boolean autoDetect) {
44+
// getAutoDetect().set(autoDetect);
45+
// }
46+
47+
// import groovy.lang.Closure;
48+
// import org.gradle.api.Named;
49+
// import org.gradle.api.NamedDomainObjectContainer;
50+
// @Nested
51+
// abstract public Repositories getCodeRepositories();
52+
//
53+
// public void codeRepositories(Action<Repositories> action) {
54+
// action.execute(getCodeRepositories());
55+
// }
56+
57+
/**
58+
* we are using the aws sdk/cli so this just sets env vars (for calling aws cli)
59+
*/
60+
@Nested
61+
abstract public Auth getAuth();
62+
63+
public void auth(Action<Auth> action) {
64+
action.execute(getAuth());
65+
}
66+
67+
public abstract static class Auth {
68+
/**
69+
* sets {@code AWS_PROFILE} when calling aws cli
70+
*/
71+
abstract public Property<String> getAwsProfile();
72+
}
73+
//
74+
// public abstract static class Repositories {
75+
// @Nested
76+
// abstract public Repository getDefaultRepository();
77+
//
78+
// public void defaultRepository(Action<Repository> action) {
79+
// action.execute(getDefaultRepository());
80+
// }
81+
//
82+
// @Nested
83+
// abstract public NamedDomainObjectContainer<NamedRepository> getAliases();
84+
//
85+
// public void aliases(Closure<?> action) {
86+
// getAliases().configure(action);
87+
// }
88+
//
89+
// public void aliases(Action<NamedDomainObjectContainer<NamedRepository>> action) {
90+
// action.execute(getAliases());
91+
// }
92+
// }
93+
//
94+
// public static abstract class Repository {
95+
// /**
96+
// * takes priority over config
97+
// */
98+
// abstract public Property<String> getUrl();
99+
//
100+
// /**
101+
// * build up the url with these inputs if you don't provide the url
102+
// */
103+
// @Nested
104+
// abstract public Config getConfig();
105+
//
106+
// public void url(String value) {
107+
// getUrl().set(value);
108+
// }
109+
//
110+
// public void config(Action<Config> config) {
111+
// config.execute(getConfig());
112+
// }
113+
//
114+
// public static abstract class Config {
115+
// abstract public Property<String> getAwsCodeAccount();
116+
//
117+
// abstract public Property<String> getAwsCodeRegion();
118+
//
119+
// abstract public Property<String> getAwsCodeDomain();
120+
//
121+
// abstract public Property<String> getAwsCodeRepository();
122+
// }
123+
// }
124+
//
125+
// /**
126+
// * @see <a href=https://docs.gradle.org/current/userguide/custom_gradle_types.html#ex-managing-a-collection-of-objects>custom_gradle_types.html: "Type must have a read-only 'name' property"</a>
127+
// */
128+
// public abstract static class NamedRepository extends Repository implements Named {
129+
// }
130+
}

0 commit comments

Comments
 (0)