Browse Source

Switch to use object attributes for consumer

Use object attribute for consumer
dimdim11 1 year ago
parent
commit
d1374eadc8

+ 1 - 4
build/conf/java.conf

@@ -503,8 +503,7 @@ macro LOCAL_SOURCES_JAR(File) {
 
 
 JAVA_CONTRIB_SEM= \
 JAVA_CONTRIB_SEM= \
     ${hide:TARGET} ${hide:AUTO_INPUT} \
     ${hide:TARGET} ${hide:AUTO_INPUT} \
-    consumer_classpath $EXPORT_GRADLE_CLASSPATH \
-    && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
+    consumer-classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-type contrib \
     && consumer-type contrib \
     && peers_closure $MANAGED_PEERS_CLOSURE \
     && peers_closure $MANAGED_PEERS_CLOSURE \
@@ -866,7 +865,6 @@ _DO_GRADLE_EXPORT_PUBLISHING_SEM= \
 BUILD_JAR_SEM= \
 BUILD_JAR_SEM= \
     ${hide:TARGET} ${hide:AUTO_INPUT} ${hide:APPLIED_EXCLUDES} \
     ${hide:TARGET} ${hide:AUTO_INPUT} ${hide:APPLIED_EXCLUDES} \
     jar $MODDIR $REALPRJNAME \
     jar $MODDIR $REALPRJNAME \
-    && consumer_classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-type library \
     && consumer-type library \
@@ -880,7 +878,6 @@ BUILD_PROTO_JAR_SEM= \
     ${hide:target} ${hide:AUTO_INPUT} \
     ${hide:target} ${hide:AUTO_INPUT} \
     jar_proto $MODDIR $REALPRJNAME \
     jar_proto $MODDIR $REALPRJNAME \
     $_JAVA_PROTO_SEM \
     $_JAVA_PROTO_SEM \
-    && consumer_classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-classpath $EXPORT_GRADLE_CLASSPATH \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-jar ${MODDIR}/${REALPRJNAME}.jar \
     && consumer-type library \
     && consumer-type library \

+ 18 - 17
build/export_generators/gradle/build.gradle.kts.jinja

@@ -34,30 +34,31 @@ java {
 
 
 dependencies {
 dependencies {
 {% for target in targets -%}
 {% for target in targets -%}
-{% if target.junit5_test -%}
+{%     if target.junit5_test -%}
     testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
     testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
 
 
     api("org.apache.commons:commons-math3:3.6.1")
     api("org.apache.commons:commons-math3:3.6.1")
 
 
     api("com.google.guava:guava:31.0.1-jre")
     api("com.google.guava:guava:31.0.1-jre")
-{% endif -%}
-{% for library in target.consumer_classpath -%}
-{% if targets|selectattr("app_main_class") -%}
-{% if target.lib_excludes is defined and target.lib_excludes[library]|length > 0 -%}
-    implementation({{ library }}) {
-{% for exclude in target.lib_excludes[library] -%}
+{%     endif -%}
+{%     for library in target.consumer -%}
+{%         set classpath = library.classpath -%}
+{%         if targets|selectattr("app_main_class") -%}
+{%             if target.lib_excludes is defined and target.lib_excludes[classpath]|length > 0 -%}
+    implementation({{ classpath }}) {
+{%                 for exclude in target.lib_excludes[classpath] -%}
         exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
         exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
-{% endfor -%}
+{%                 endfor -%}
     }
     }
-{% else -%}
-    implementation({{ library }})
-{% endif -%}
-{% elif target.isTest -%}
-    testImplementation({{ library }})
-{% else -%}
-    api({{ library }})
-{% endif -%}
-{% endfor -%}
+{%             else -%}
+    implementation({{ classpath }})
+{%             endif -%}
+{%         elif target.isTest -%}
+    testImplementation({{ classpath }})
+{%         else -%}
+    api({{ classpath }})
+{%         endif -%}
+{%     endfor -%}
 {% endfor -%}
 {% endfor -%}
 }
 }
 
 

+ 5 - 3
build/export_generators/gradle/build.gradle.kts.proto.jinja

@@ -26,9 +26,11 @@ java {
 }
 }
 
 
 dependencies {
 dependencies {
-{% for library in targets[0].consumer_classpath -%}
-    api({{ library }})
-{% endfor -%}
+{%  if targets[0].consumer is defined -%}
+{%-    for library in targets[0].consumer -%}
+    api({{ library.classpath }})
+{%     endfor -%}
+{%- endif -%}
 
 
 {% if targets[0].proto_namespace is defined -%}
 {% if targets[0].proto_namespace is defined -%}
     protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}")))
     protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}")))

+ 0 - 1
build/export_generators/gradle/generator.toml

@@ -49,7 +49,6 @@ with_kotlinc_plugin_serialization="bool"
 [attrs.dir]
 [attrs.dir]
 
 
 [attrs.induced]
 [attrs.induced]
-consumer_classpath="list"
 consumer-classpath="str"
 consumer-classpath="str"
 consumer-jar="str"
 consumer-jar="str"
 consumer-type="str"
 consumer-type="str"

+ 18 - 17
build/export_generators/ide-gradle/build.gradle.kts.jinja

@@ -58,30 +58,31 @@ sourceSets.main.java.srcDirs += '{{ srcdir }}'
 
 
 dependencies {
 dependencies {
 {% for target in targets -%}
 {% for target in targets -%}
-{% if target.junit5_test -%}
+{%     if target.junit5_test -%}
     testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
     testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
 
 
     api("org.apache.commons:commons-math3:3.6.1")
     api("org.apache.commons:commons-math3:3.6.1")
 
 
     api("com.google.guava:guava:31.0.1-jre")
     api("com.google.guava:guava:31.0.1-jre")
-{% endif -%}
-{% for library in target.consumer_classpath -%}
-{% if targets|selectattr("app_main_class") -%}
-{% if target.lib_excludes is defined and target.lib_excludes[library]|length > 0 -%}
-    implementation({{ library }}) {
-{% for exclude in target.lib_excludes[library] -%}
+{%     endif -%}
+{%     for library in target.consumer -%}
+{%         set classpath = library.classpath -%}
+{%         if targets|selectattr("app_main_class") -%}
+{%             if target.lib_excludes is defined and target.lib_excludes[classpath]|length > 0 -%}
+    implementation({{ classpath }}) {
+{%                 for exclude in target.lib_excludes[classpath] -%}
         exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
         exclude group: '{{ exclude[0] }}', module: '{{ exclude[1] }}'
-{% endfor -%}
+{%                 endfor -%}
     }
     }
-{% else -%}
-    implementation({{ library }})
-{% endif -%}
-{% elif target.isTest -%}
-    testImplementation({{ library }})
-{% else -%}
-    api({{ library }})
-{% endif -%}
-{% endfor -%}
+{%             else -%}
+    implementation({{ classpath }})
+{%             endif -%}
+{%         elif target.isTest -%}
+    testImplementation({{ classpath }})
+{%         else -%}
+    api({{ classpath }})
+{%         endif -%}
+{%     endfor -%}
 {% endfor -%}
 {% endfor -%}
 }
 }
 
 

+ 5 - 3
build/export_generators/ide-gradle/build.gradle.kts.proto.jinja

@@ -26,9 +26,11 @@ java {
 }
 }
 
 
 dependencies {
 dependencies {
-{% for library in targets[0].consumer_classpath -%}
-    api({{ library }})
-{% endfor -%}
+{%  if targets[0].consumer is defined -%}
+{%-    for library in targets[0].consumer -%}
+    api({{ library.classpath }})
+{%     endfor -%}
+{%- endif -%}
 
 
 {% if targets[0].proto_namespace is defined -%}
 {% if targets[0].proto_namespace is defined -%}
     protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}")))
     protobuf(files(File(buildProtoDir, "{{ targets[0].proto_namespace }}")))

+ 0 - 1
build/export_generators/ide-gradle/generator.toml

@@ -49,7 +49,6 @@ with_kotlinc_plugin_serialization="bool"
 [attrs.dir]
 [attrs.dir]
 
 
 [attrs.induced]
 [attrs.induced]
-consumer_classpath="list"
 consumer-classpath="str"
 consumer-classpath="str"
 consumer-jar="str"
 consumer-jar="str"
 consumer-type="str"
 consumer-type="str"