Skip to content

Commit 7a49631

Browse files
authored
159 fail build tool on err (#160)
* Propagate error to build tools
1 parent ac6372e commit 7a49631

File tree

16 files changed

+30
-21
lines changed

16 files changed

+30
-21
lines changed

annotation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>online.sharedtype</groupId>
66
<artifactId>sharedtype-parent</artifactId>
7-
<version>0.14.0-SNAPSHOT</version>
7+
<version>0.13.2-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010

build-tool-plugins/exec/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>online.sharedtype</groupId>
77
<artifactId>sharedtype-parent</artifactId>
8-
<version>0.14.0-SNAPSHOT</version>
8+
<version>0.13.2-SNAPSHOT</version>
99
<relativePath>../../pom.xml</relativePath>
1010
</parent>
1111

1212
<artifactId>sharedtype-ap-exec</artifactId>
13-
<version>0.14.0-SNAPSHOT</version>
13+
<version>0.13.2-SNAPSHOT</version>
1414
<name>SharedType Annotation Processor Executor</name>
1515
<description>Call javac to execute annotation processing.</description>
1616

build-tool-plugins/exec/src/main/java/online/sharedtype/exec/common/AnnotationProcessorExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public AnnotationProcessorExecutor(Processor processor, Logger log, DependencyRe
3333
this.dependencyResolver = dependencyResolver;
3434
}
3535

36-
public void execute(Path projectBaseDir,
36+
/** @return true if successful; false otherwise. */
37+
public boolean execute(Path projectBaseDir,
3738
Path outputDir,
3839
Iterable<Path> compileSourceRoots,
3940
String sourceEncoding,
@@ -52,7 +53,7 @@ public void execute(Path projectBaseDir,
5253

5354
JavaCompiler.CompilationTask task = compiler.getTask(logger, fileManager, diagnosticListener, compilerOptions, null, sources);
5455
task.setProcessors(Collections.singleton(processor));
55-
task.call();
56+
return task.call();
5657
}
5758
}
5859

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=0.14.0-SNAPSHOT
1+
version=0.13.2-SNAPSHOT
22
mavenCentralPublishing=true
33
signAllPublications=true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
projectVersion=0.14.0-SNAPSHOT
1+
projectVersion=0.13.2-SNAPSHOT

build-tool-plugins/gradle-plugin/src/main/java/online/sharedtype/gradle/SharedtypeGenTask.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ void setExtension(SharedtypeConfigExtension extension) {
3636

3737
@TaskAction
3838
void action() {
39+
boolean success;
3940
try {
40-
execute();
41+
success = execute();
4142
} catch (Exception e) {
4243
throw new SharedTypeException(String.format("Failed to execute task '%s'", TASK_NAME), e);
4344
}
45+
if (!success) {
46+
throw new SharedTypeException(String.format("Failed to execute task '%s'", TASK_NAME));
47+
}
4448
}
4549

46-
private void execute() throws Exception {
50+
private boolean execute() throws Exception {
4751
JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
4852
if (javaPluginExtension == null) {
4953
throw new UnsupportedOperationException("Could not find JavaPluginExtension, only Java projects are supported.");
@@ -67,7 +71,7 @@ private void execute() throws Exception {
6771
() -> classpathDependencies
6872
);
6973

70-
executor.execute(
74+
return executor.execute(
7175
project.getProjectDir().toPath(),
7276
resolveOutputDirectory().toPath(),
7377
sourceDirs,

build-tool-plugins/maven-plugin/it/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>online.sharedtype</groupId>
77
<artifactId>sharedtype-parent</artifactId>
8-
<version>0.14.0-SNAPSHOT</version>
8+
<version>0.13.2-SNAPSHOT</version>
99
<relativePath>../../../pom.xml</relativePath>
1010
</parent>
1111

build-tool-plugins/maven-plugin/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>online.sharedtype</groupId>
77
<artifactId>sharedtype-parent</artifactId>
8-
<version>0.14.0-SNAPSHOT</version>
8+
<version>0.13.2-SNAPSHOT</version>
99
<relativePath>../../pom.xml</relativePath>
1010
</parent>
1111

1212
<artifactId>sharedtype-maven-plugin</artifactId>
13-
<version>0.14.0-SNAPSHOT</version>
13+
<version>0.13.2-SNAPSHOT</version>
1414
<packaging>maven-plugin</packaging>
1515
<name>SharedType Maven Plugin</name>
1616

build-tool-plugins/maven-plugin/src/main/java/online/sharedtype/maven/SharedTypeGenMojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import online.sharedtype.exec.common.SharedTypeApCompilerOptions;
66
import online.sharedtype.processor.SharedTypeAnnotationProcessor;
77
import online.sharedtype.processor.support.annotation.Nullable;
8+
import online.sharedtype.processor.support.exception.SharedTypeException;
89
import org.apache.maven.execution.MavenSession;
910
import org.apache.maven.plugin.AbstractMojo;
1011
import org.apache.maven.plugin.MojoExecutionException;
@@ -64,13 +65,16 @@ public void execute() throws MojoExecutionException {
6465
new MavenDependencyResolver(repositorySystem, session, project)
6566
);
6667
try {
67-
apExecutor.execute(
68+
boolean success = apExecutor.execute(
6869
project.getBasedir().toPath(),
6970
Paths.get(outputDirectory),
7071
project.getCompileSourceRoots().stream().map(Paths::get).collect(Collectors.toList()),
7172
project.getProperties().getProperty(PROP_PROJECT_SOURCE_ENCODING),
7273
new SharedTypeApCompilerOptions(propertyFile).toList()
7374
);
75+
if (!success) {
76+
throw new SharedTypeException("Some error during annotation processing.");
77+
}
7478
} catch (Exception e) {
7579
throw new MojoExecutionException(e);
7680
}

doc/Development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ To Test Javadoc locally:
111111
```
112112
Then open `annotation/target/reports/apidocs/index.html`.
113113

114-
To test deployment, see [release](../misc/release.sh).
114+
To test deployment, see scripts: [release](../misc/release.sh), [setversion](../misc/setversion.sh).

0 commit comments

Comments
 (0)