Skip to content

Commit fedc1c9

Browse files
committed
Make project friendlier for Eclipse IDE development
- use maven-resources-plugin/copy-resources instead of referencing resources outside of module project directories - provide generic argument type hints in several locations in the topic operator's `TypeHandler` Signed-off-by: Michael Edgar <[email protected]>
1 parent f800ed3 commit fedc1c9

File tree

4 files changed

+66
-37
lines changed

4 files changed

+66
-37
lines changed

cluster-operator/pom.xml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,26 @@
283283
<groupId>org.apache.maven.plugins</groupId>
284284
<artifactId>maven-resources-plugin</artifactId>
285285
<version>${maven.resources.version}</version>
286+
<executions>
287+
<execution>
288+
<id>copy-kafka-versions</id>
289+
<phase>generate-resources</phase>
290+
<goals>
291+
<goal>copy-resources</goal>
292+
</goals>
293+
<configuration>
294+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
295+
<resources>
296+
<resource>
297+
<directory>${strimziRootDirectory}</directory>
298+
<includes>
299+
<include>kafka-versions.yaml</include>
300+
</includes>
301+
</resource>
302+
</resources>
303+
</configuration>
304+
</execution>
305+
</executions>
286306
</plugin>
287307
<plugin>
288308
<groupId>org.apache.maven.plugins</groupId>
@@ -301,7 +321,6 @@
301321
<plugin>
302322
<groupId>org.apache.maven.plugins</groupId>
303323
<artifactId>maven-dependency-plugin</artifactId>
304-
<version>${maven.dependency.version}</version>
305324
<executions>
306325
<execution>
307326
<id>copy-dependencies</id>
@@ -365,12 +384,6 @@
365384
<directory>src/main/resources-filtered</directory>
366385
<filtering>true</filtering>
367386
</resource>
368-
<resource>
369-
<directory>..</directory>
370-
<includes>
371-
<include>kafka-versions.yaml</include>
372-
</includes>
373-
</resource>
374387
</resources>
375388
</build>
376389
</project>

development-docs/DEV_GUIDE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This document gives a detailed breakdown of the various build processes and opti
88
- [Build Pre-Requisites](#build-pre-requisites)
99
- [Using an IDE](#using-an-ide)
1010
- [IntelliJ IDEA](#intellij-idea)
11+
- [Eclipse](#eclipse)
1112
- [IDE build problems](#ide-build-problems)
1213
- [Build and deploy Strimzi from source](#build-and-deploy-from-source)
1314
- [Build details](#build-details)
@@ -21,7 +22,7 @@ This document gives a detailed breakdown of the various build processes and opti
2122
- [Helm Chart](#helm-chart)
2223
- [Running system tests](#running-system-tests)
2324
- [DCO Signoff](#dco-signoff)
24-
- [Building container images for other platforms with Docker `buildx`](#building-container-images-for-other-platforms-with-docker-buildx)
25+
- [Building container images for other platforms](#building-container-images-for-other-platforms)
2526

2627
<!-- /TOC -->
2728

@@ -110,16 +111,17 @@ Afterwards IntelliJ should no longer have any `Cannot resolve symbol` errors.
110111

111112
Note: After running the Maven build in the terminal you might need to [reload the project](https://www.jetbrains.com/help/idea/delegate-build-and-run-actions-to-maven.html#maven_reimport) from the Maven tool window.
112113

114+
### Eclipse
115+
* Eclipse users may find the [m2e-apt plugin](https://marketplace.eclipse.org/content/m2e-apt) useful for the automatic
116+
configuration of Eclipse projects for annotation processing.
117+
113118
### IDE build problems
114119

115120
The build also uses a Java annotation processor. Some IDEs (such as IntelliJ's IDEA) by default don't run the annotation
116121
processor in their build process. You can run `mvn clean install -DskipTests` to run the annotation processor
117122
as part of the `maven` build, and the IDE should then be able to use the generated classes. It is also possible to
118123
configure the IDE to run the annotation processor directly.
119124

120-
Eclipse users may find the [m2e-apt plugin](https://marketplace.eclipse.org/content/m2e-apt) useful for the automatic
121-
configuration of Eclipse projects for annotation processing.
122-
123125
## Build and deploy from source
124126

125127
To build Strimzi from a source the operator and Kafka code needs to be compiled into container images and placed

systemtest/pom.xml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,32 @@
293293

294294
<build>
295295
<plugins>
296+
<plugin>
297+
<groupId>org.apache.maven.plugins</groupId>
298+
<artifactId>maven-resources-plugin</artifactId>
299+
<version>${maven.resources.version}</version>
300+
<executions>
301+
<execution>
302+
<id>copy-kafka-versions</id>
303+
<phase>generate-resources</phase>
304+
<goals>
305+
<goal>copy-resources</goal>
306+
</goals>
307+
<configuration>
308+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
309+
<resources>
310+
<resource>
311+
<directory>${strimziRootDirectory}</directory>
312+
<includes>
313+
<include>kafka-versions.yaml</include>
314+
<include>bridge.version</include>
315+
</includes>
316+
</resource>
317+
</resources>
318+
</configuration>
319+
</execution>
320+
</executions>
321+
</plugin>
296322
<plugin>
297323
<groupId>org.apache.maven.plugins</groupId>
298324
<artifactId>maven-javadoc-plugin</artifactId>
@@ -304,7 +330,6 @@
304330
<plugin>
305331
<groupId>org.apache.maven.plugins</groupId>
306332
<artifactId>maven-dependency-plugin</artifactId>
307-
<version>${maven.dependency.version}</version>
308333
<executions>
309334
<execution>
310335
<id>analyze</id>
@@ -331,7 +356,8 @@
331356
</configuration>
332357
</execution>
333358
<execution>
334-
<phase>generate-sources</phase>
359+
<!-- Dependencies jars are needed for the test-docs-generator-maven-plugin -->
360+
<phase>package</phase>
335361
<goals>
336362
<goal>copy-dependencies</goal>
337363
</goals>
@@ -361,18 +387,6 @@
361387
</configuration>
362388
</plugin>
363389
</plugins>
364-
<resources>
365-
<resource>
366-
<directory>src/main/resources</directory>
367-
</resource>
368-
<resource>
369-
<directory>..</directory>
370-
<includes>
371-
<include>kafka-versions.yaml</include>
372-
<include>bridge.version</include>
373-
</includes>
374-
</resource>
375-
</resources>
376390
</build>
377391

378392
<profiles>

topic-operator/src/main/java/io/strimzi/operator/topic/KafkaHandler.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,20 @@ public PartitionedByError<ReconcilableTopic, TopicState> createTopics(List<Recon
142142
var values = ctr.values();
143143
return TopicOperatorUtil.partitionedByError(reconcilableTopics.stream().map(reconcilableTopic -> {
144144
if (newTopicsErrors.containsKey(reconcilableTopic)) {
145-
return new Pair<>(reconcilableTopic, Either.ofLeft(newTopicsErrors.get(reconcilableTopic)));
145+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofLeft(newTopicsErrors.get(reconcilableTopic)));
146146
}
147147
try {
148148
values.get(reconcilableTopic.topicName()).get();
149-
return new Pair<>(reconcilableTopic, Either.ofRight(
150-
new TopicState(new TopicDescription(reconcilableTopic.topicName(),
149+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofRight(
150+
new TopicState(new TopicDescription(reconcilableTopic.topicName(),
151151
false, List.of(), Set.of(), ctr.topicId(reconcilableTopic.topicName()).get()), null)
152152
));
153153
} catch (ExecutionException e) {
154154
if (e.getCause() != null && e.getCause() instanceof TopicExistsException) {
155155
// we treat this as a success, the next reconciliation checks the configuration
156-
return new Pair<>(reconcilableTopic, Either.ofRight(null));
156+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofRight(null));
157157
} else {
158-
return new Pair<>(reconcilableTopic, Either.ofLeft(handleAdminException(e)));
158+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofLeft(handleAdminException(e)));
159159
}
160160
} catch (InterruptedException e) {
161161
throw new UncheckedInterruptedException(e);
@@ -247,9 +247,9 @@ public PartitionedByError<ReconcilableTopic, Void> alterConfigs(List<Pair<Reconc
247247
var alterConfigsResult = acr.values();
248248
Stream<Pair<ReconcilableTopic, Either<TopicOperatorException, Void>>> entryStream = someAlterConfigs.stream().map(entry -> {
249249
try {
250-
return new Pair<>(entry.getKey(), Either.ofRight(alterConfigsResult.get(buildTopicConfigResource(entry.getKey().topicName())).get()));
250+
return new Pair<>(entry.getKey(), Either.<TopicOperatorException, Void>ofRight(alterConfigsResult.get(buildTopicConfigResource(entry.getKey().topicName())).get()));
251251
} catch (ExecutionException e) {
252-
return new Pair<>(entry.getKey(), Either.ofLeft(handleAdminException(e)));
252+
return new Pair<>(entry.getKey(), Either.<TopicOperatorException, Void>ofLeft(handleAdminException(e)));
253253
} catch (InterruptedException e) {
254254
throw new UncheckedInterruptedException(e);
255255
}
@@ -359,9 +359,9 @@ public PartitionedByError<ReconcilableTopic, TopicState> describeTopics(List<Rec
359359
throw new UncheckedInterruptedException(e);
360360
}
361361
if (exception != null) {
362-
return new Pair<>(reconcilableTopic, Either.ofLeft(handleAdminException(exception)));
362+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofLeft(handleAdminException(exception)));
363363
} else {
364-
return new Pair<>(reconcilableTopic, Either.ofRight(new TopicState(description, configs)));
364+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, TopicState>ofRight(new TopicState(description, configs)));
365365
}
366366
}));
367367
}
@@ -398,12 +398,12 @@ public PartitionedByError<ReconcilableTopic, Object> deleteTopics(List<Reconcila
398398
.map(reconcilableTopic -> {
399399
try {
400400
futuresMap.get(reconcilableTopic.topicName()).get();
401-
return new Pair<>(reconcilableTopic, Either.ofRight(null));
401+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, Object>ofRight(null));
402402
} catch (ExecutionException e) {
403403
if (e.getCause() instanceof UnknownTopicOrPartitionException) {
404-
return new Pair<>(reconcilableTopic, Either.ofRight(null));
404+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, Object>ofRight(null));
405405
} else {
406-
return new Pair<>(reconcilableTopic, Either.ofLeft(handleAdminException(e)));
406+
return new Pair<>(reconcilableTopic, Either.<TopicOperatorException, Object>ofLeft(handleAdminException(e)));
407407
}
408408
} catch (InterruptedException e) {
409409
throw new UncheckedInterruptedException(e);

0 commit comments

Comments
 (0)