|
9 | 9 | import java.util.regex.Pattern; |
10 | 10 |
|
11 | 11 | import org.apache.maven.execution.MavenSession; |
| 12 | +import org.apache.maven.model.Profile; |
12 | 13 | import org.hibernate.infra.develocity.GoalMetadataProvider; |
13 | 14 | import org.hibernate.infra.develocity.Log; |
14 | 15 | import org.hibernate.infra.develocity.util.JavaVersions; |
@@ -69,54 +70,80 @@ public static void addFailsafeMetadata(GoalMetadataProvider.Context context) { |
69 | 70 | var buildScanApi = context.buildScan(); |
70 | 71 |
|
71 | 72 | var project = context.metadata().getProject(); |
72 | | - boolean dependsOnOrm = false; |
73 | | - boolean dependsOnLucene = false; |
74 | | - boolean dependsOnElasticsearch = false; |
75 | | - var artifactFilter = context.configuration().getFailsafeClasspathFilter(); |
76 | | - for ( var dependency : project.getArtifacts() ) { |
77 | | - if ( !artifactFilter.include( dependency ) ) { |
78 | | - continue; |
| 73 | + if ("org.hibernate.search".equals(project.getGroupId())) { |
| 74 | + boolean dependsOnOrm = false; |
| 75 | + boolean dependsOnLucene = false; |
| 76 | + boolean dependsOnElasticsearch = false; |
| 77 | + var artifactFilter = context.configuration().getFailsafeClasspathFilter(); |
| 78 | + for (var dependency : project.getArtifacts()) { |
| 79 | + if (!artifactFilter.include(dependency)) { |
| 80 | + continue; |
| 81 | + } |
| 82 | + var artifactId = dependency.getArtifactId(); |
| 83 | + dependsOnOrm = dependsOnOrm || artifactId.contains("mapper-orm"); |
| 84 | + dependsOnLucene = dependsOnLucene || artifactId.contains("backend-lucene"); |
| 85 | + dependsOnElasticsearch = dependsOnElasticsearch || artifactId.contains("backend-elasticsearch"); |
79 | 86 | } |
80 | | - var artifactId = dependency.getArtifactId(); |
81 | | - dependsOnOrm = dependsOnOrm || artifactId.contains( "mapper-orm" ); |
82 | | - dependsOnLucene = dependsOnLucene || artifactId.contains( "backend-lucene" ); |
83 | | - dependsOnElasticsearch = dependsOnElasticsearch || artifactId.contains( "backend-elasticsearch" ); |
84 | | - } |
85 | 87 |
|
86 | | - if ( dependsOnOrm ) { |
87 | | - var dbKind = context.properties().getString( "test.database.run.kind" ); |
88 | | - if ( !Strings.isBlank( dbKind ) ) { |
89 | | - if ( dbKind.equals( "h2" ) ) { |
90 | | - // H2 doesn't use containers |
91 | | - buildScanApi.tag( "h2" ); |
92 | | - } |
93 | | - else { |
94 | | - addDockerfileMetadata( context, |
95 | | - "database/%s.Dockerfile".formatted( dbKind ), dbKind, null, false ); |
| 88 | + if (dependsOnOrm) { |
| 89 | + var dbKind = context.properties().getString("test.database.run.kind"); |
| 90 | + if (!Strings.isBlank(dbKind)) { |
| 91 | + if (dbKind.equals("h2")) { |
| 92 | + // H2 doesn't use containers |
| 93 | + buildScanApi.tag("h2"); |
| 94 | + } else { |
| 95 | + addDockerfileMetadata(context, |
| 96 | + "database/%s.Dockerfile".formatted(dbKind), dbKind, null, false); |
| 97 | + } |
96 | 98 | } |
97 | 99 | } |
98 | | - } |
99 | 100 |
|
100 | | - String explicitBackend = context.configuration() |
101 | | - .getFailsafeSystemProperty( "org.hibernate.search.integrationtest.backend.type" ); |
102 | | - if ( Strings.isBlank( explicitBackend ) ) { |
103 | | - explicitBackend = null; |
104 | | - } |
| 101 | + String explicitBackend = context.configuration() |
| 102 | + .getFailsafeSystemProperty("org.hibernate.search.integrationtest.backend.type"); |
| 103 | + if (Strings.isBlank(explicitBackend)) { |
| 104 | + explicitBackend = null; |
| 105 | + } |
105 | 106 |
|
106 | | - if ( dependsOnLucene |
107 | | - && ( explicitBackend == null || "lucene".equals( explicitBackend ) ) |
108 | | - && !context.properties().getBoolean( "test.lucene.skip" ) ) { |
109 | | - buildScanApi.tag( "lucene" ); |
| 107 | + if (dependsOnLucene |
| 108 | + && (explicitBackend == null || "lucene".equals(explicitBackend)) |
| 109 | + && !context.properties().getBoolean("test.lucene.skip")) { |
| 110 | + buildScanApi.tag("lucene"); |
| 111 | + } |
| 112 | + |
| 113 | + if (dependsOnElasticsearch |
| 114 | + && (explicitBackend == null || "elasticsearch".equals(explicitBackend)) |
| 115 | + && !context.properties().getBoolean("test.elasticsearch.skip")) { |
| 116 | + var distribution = context.properties().getString("test.elasticsearch.distribution"); |
| 117 | + addDockerfileMetadata(context, |
| 118 | + "search-backend/%s.Dockerfile".formatted(distribution), |
| 119 | + "elastic".equals(distribution) ? "elasticsearch" : distribution, |
| 120 | + context.properties().getString("test.elasticsearch.version"), true); |
| 121 | + } |
| 122 | + } else if (!"org.hibernate.validator".equals(project.getGroupId())) { |
| 123 | + Log.warn("Project %s:%s is unknown, no specific Failsafe metadata added.".formatted(project.getGroupId(), project.getArtifactId())); |
110 | 124 | } |
| 125 | + } |
111 | 126 |
|
112 | | - if ( dependsOnElasticsearch |
113 | | - && ( explicitBackend == null || "elasticsearch".equals( explicitBackend ) ) |
114 | | - && !context.properties().getBoolean( "test.elasticsearch.skip" ) ) { |
115 | | - var distribution = context.properties().getString( "test.elasticsearch.distribution" ); |
116 | | - addDockerfileMetadata( context, |
117 | | - "search-backend/%s.Dockerfile".formatted( distribution ), |
118 | | - "elastic".equals( distribution ) ? "elasticsearch" : distribution, |
119 | | - context.properties().getString( "test.elasticsearch.version" ), true ); |
| 127 | + public static void addSurefireMetadata(GoalMetadataProvider.Context context) { |
| 128 | + var buildScanApi = context.buildScan(); |
| 129 | + var project = context.metadata().getProject(); |
| 130 | + if ("org.hibernate.validator".equals(project.getGroupId())) { |
| 131 | + if ("hibernate-validator-tck-runner".equals(project.getArtifactId())) { |
| 132 | + project.getActiveProfiles().stream().map(Profile::getId) |
| 133 | + .filter("local"::equals).findAny() |
| 134 | + .ifPresent(id -> buildScanApi.tag("Standalone-TCK")); |
| 135 | + |
| 136 | + project.getActiveProfiles().stream().map(Profile::getId) |
| 137 | + .filter(id -> id.startsWith("incontainer")).findAny() |
| 138 | + .ifPresent(id -> buildScanApi.tag("In-Container-TCK")); |
| 139 | + |
| 140 | + project.getArtifacts().stream() |
| 141 | + .filter(a -> "validation-tck-tests".equals(a.getArtifactId())) |
| 142 | + .findAny() |
| 143 | + .ifPresent(a -> buildScanApi.tag("Validation-TCK-%s".formatted(a.getVersion()))); |
| 144 | + } |
| 145 | + } else if (!"org.hibernate.search".equals(project.getGroupId())) { |
| 146 | + Log.warn("Project %s:%s is unknown, no specific Surefire metadata added.".formatted(project.getGroupId(), project.getArtifactId())); |
120 | 147 | } |
121 | 148 | } |
122 | 149 |
|
|
0 commit comments