Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ jobs:
run: mvn -B dependency:go-offline test clean -U --quiet --fail-never -DskipTests=true -f build-pom.xml
- name: 'Test'
shell: bash
run: mvn -B verify -U --fail-at-end -Dsource.skip=true -Dmaven.javadoc.skip=true -f build-pom.xml
# One of the auto-service-ksp test deps was built targeting JDK 11, so we skip its tests
# here and only run them on JDK 11+ in the next step.
run: mvn -B verify -U --fail-at-end -Dsource.skip=true -Dmaven.javadoc.skip=true -pl '!service/processor_ksp' -f build-pom.xml
- name: 'Test auto-service-ksp'
if: ${{ matrix.java >= 11 }}
shell: bash
run: mvn -B verify -U --fail-at-end -Dsource.skip=true -Dmaven.javadoc.skip=true -f service/pom.xml

publish_snapshot:
name: 'Publish snapshot'
Expand Down
8 changes: 1 addition & 7 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,19 @@
<modules>
<module>annotations</module>
<module>processor</module>
<module>processor_ksp</module>
</modules>

<dependencyManagement>
<dependencies>
<!-- main dependencies -->

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>${guava.version}</version>
</dependency>

<!-- test dependencies -->

<dependency>
<groupId>com.google.testing.compile</groupId>
<artifactId>compile-testing</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
import static com.google.auto.common.MoreElements.getAnnotationMirror;
import static com.google.common.base.Throwables.getStackTraceAsString;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.auto.common.MoreElements;
import com.google.auto.common.MoreTypes;
import com.google.auto.service.AutoService;

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 26 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

cannot find symbol
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.SortedSetMultimap;
import com.google.common.collect.TreeMultimap;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -85,7 +88,7 @@

@Override
public ImmutableSet<String> getSupportedAnnotationTypes() {
return ImmutableSet.of(AutoService.class.getName());

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 91 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

cannot find symbol
}

@Override
Expand All @@ -94,8 +97,6 @@
}

/**
*
*
* <ol>
* <li>For each class annotated with {@link AutoService}
* <ul>
Expand Down Expand Up @@ -140,7 +141,7 @@
private void processAnnotations(
Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(AutoService.class);

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 144 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

cannot find symbol

log(annotations.toString());
log(elements.toString());
Expand All @@ -148,7 +149,7 @@
for (Element e : elements) {
// TODO(gak): check for error trees?
TypeElement providerImplementer = MoreElements.asType(e);
AnnotationMirror annotationMirror = getAnnotationMirror(e, AutoService.class).get();

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 8

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 17

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / JDK 11

cannot find symbol

Check failure on line 152 in service/processor/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

cannot find symbol
ImmutableSet<DeclaredType> providerInterfaces = getValueFieldOfClasses(annotationMirror);
if (providerInterfaces.isEmpty()) {
error(MISSING_SERVICES_ERROR, e, annotationMirror);
Expand Down Expand Up @@ -186,8 +187,13 @@
log("New service file contents: " + newServices);
FileObject fileObject =
filer.createResource(StandardLocation.CLASS_OUTPUT, "", resourceFile);
try (OutputStream out = fileObject.openOutputStream()) {
ServicesFiles.writeServiceFile(newServices, out);
try (OutputStream out = fileObject.openOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(out, UTF_8);
BufferedWriter buffered = new BufferedWriter(writer)) {
for (String service : newServices) {
buffered.write(service);
buffered.write('\n');
}
}
log("Wrote to: " + resourceFile);
} catch (IOException e) {
Expand Down

This file was deleted.

128 changes: 128 additions & 0 deletions service/processor_ksp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-aggregator</artifactId>
<version>HEAD-SNAPSHOT</version>
</parent>

<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-ksp</artifactId>
<version>HEAD-SNAPSHOT</version>
<name>AutoService KSP Processor</name>
<description>
KSP processor for generating ServiceLoader provider configuration files.
</description>
<url>https://github.com/google/auto/tree/main/service</url>

<scm>
<url>http://github.com/google/auto</url>
<connection>scm:git:git://github.com/google/auto.git</connection>
<developerConnection>scm:git:ssh://git@github.com/google/auto.git</developerConnection>
<tag>HEAD</tag>
</scm>

<properties>
<maven.compiler.release>${java.version}</maven.compiler.release>
<kotlin.version>2.4.10</kotlin.version>
<kotlin.compiler.languageVersion>2.0</kotlin.compiler.languageVersion>
<kotlin.compiler.apiVersion>2.0</kotlin.compiler.apiVersion>
<kotlin.compiler.jdkRelease>${java.version}</kotlin.compiler.jdkRelease>
</properties>

<repositories>
<!-- needed for room3-compiler-processing-testing -->
<repository>
<id>google</id>
<url>https://maven.google.com/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.devtools.ksp</groupId>
<artifactId>symbol-processing-api</artifactId>
<version>2.3.11</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>androidx.room3</groupId>
<artifactId>room3-compiler-processing-testing</artifactId>
<version>3.0.1</version>
<scope>test</scope>
<exclusions>
<!--
room3-compiler-processing-testing declares a dependency on symbol-processing:jar, but the
symbol-processing artifact is (now, at any rate) just a pom with no jar. Simply excluding
the dep seems to make everything work fine.
-->
<exclusion>
<groupId>com.google.devtools.ksp</groupId>
<artifactId>symbol-processing</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<!-- the KSP test actually tests the JAPT processor as well -->
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- setting these explicitly just prevents warnings about no src/(main|test)/java dirs -->
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Loading
Loading