8000 Modify getJavaSDK return type in JavaCompilerTaskFrontendOutput · sakerbuild/saker.java.compiler@ccdb2fc · GitHub
[go: up one dir, main page]

Skip to content

Commit ccdb2fc

Browse files
committed
Modify getJavaSDK return type in JavaCompilerTaskFrontendOutput
1 parent dc4e15f commit ccdb2fc

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

api/src/main/saker/java/compiler/api/compile/JavaCompilerTaskFrontendOutput.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ public interface JavaCompilerTaskFrontendOutput {
4141
*/
4242
public JavaCompilationWorkerTaskIdentifier getTaskIdentifier();
4343

44+
//SDKDescription
4445
/**
45-
* Gets the SDK description that is used to perform the compilation.
46+
* Gets the structured task result for SDK description that is used to perform the compilation.
47+
* <p>
48+
* The result will be a {@link SDKDescription}.
4649
* <p>
4750
* This is the {@link SDKDescription} that is associated with the <code>Java</code> name.
51+
* <p>
52+
* <b>Note:</b> This function was modified in an ABI breaking way in version 0.8.4. It directly returned
53+
* {@link SDKDescription} in previous releases.
4854
*
49-
* @return The SDK description.
55+
* @return The SDK description task result.
5056
*/
51-
public SDKDescription getJavaSDK();
57+
public StructuredTaskResult getJavaSDK();
5258

5359
//SakerPath
5460
/**

impl/src/main/saker/java/compiler/impl/JavaTaskUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public static boolean isModuleInfoSource(String filename) {
9595
return true;
9696
}
9797

98-
//TODO we might not need this at all, since dependency handles were introduced to TaskResultResolver
98+
@Deprecated
99+
//TODO this should be changed to be started before the compilation, and contain configuration related
100+
// information of the compilation execution. E.g. SDK, source and target versions, etc...
99101
public static TaskIdentifier createJavaCompilationConfigurationOutputTaskIdentifier(
100102
JavaCompilationWorkerTaskIdentifier workertaskid) {
101103
return new JavaCompilationConfigurationOutputTaskIdentifier(workertaskid);

main/src/main/saker/java/compiler/main/compile/JavaCompilerTaskFrontendOutputImpl.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import saker.java.compiler.api.compile.JavaCompilationConfigurationOutput;
3232
import saker.java.compiler.api.compile.JavaCompilationWorkerTaskIdentifier;
3333
import saker.java.compiler.api.compile.JavaCompilerTaskFrontendOutput;
34-
import saker.java.compiler.impl.JavaTaskUtils;
3534
import saker.sdk.support.api.SDKDescription;
3635

3736
public class JavaCompilerTaskFrontendOutputImpl extends SimpleStructuredObjectTaskResult
@@ -58,43 +57,41 @@ public JavaCompilationWorkerTaskIdentifier getTaskIdentifier() {
5857
}
5958

6059
@Override
61-
public SDKDescription getJavaSDK() {
62-
//TODO this method should return structured task result as well and the pinned value of the SDK description
63-
return javaSDK;
60+
public StructuredTaskResult getJavaSDK() {
61+
//TODO the SDK result should be retrieved from a setup task that is started by the compiler worker before compilation
62+
// we don't actually need to wait for the compilation to complete before retrieving the SDK description
63+
// we can also use the SDK description if the compilation fails.
64+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
65+
new JavaSDKConfigResolverTaskResult());
6466
}
6567

6668
@Override
6769
public StructuredTaskResult getClassDirectory() {
68-
return new ConfigFieldResolverStructuredTaskResult(
69-
JavaTaskUtils.createJavaCompilationConfigurationOutputTaskIdentifier(getTaskIdentifier()),
70+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
7071
new ClassDirectoryConfigResolverTaskResult());
7172
}
7273

7374
@Override
7475
public StructuredTaskResult getHeaderDirectory() {
75-
return new ConfigFieldResolverStructuredTaskResult(
76-
JavaTaskUtils.createJavaCompilationConfigurationOutputTaskIdentifier(getTaskIdentifier()),
76+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
7777
new HeaderDirectoryConfigResolverTaskResult());
7878
}
7979

8080
@Override
8181
public StructuredTaskResult getResourceDirectory() {
82-
return new ConfigFieldResolverStructuredTaskResult(
83-
JavaTaskUtils.createJavaCompilationConfigurationOutputTaskIdentifier(getTaskIdentifier()),
82+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
8483
new ResourceDirectoryConfigResolverTaskResult());
8584
}
8685

8786
@Override
8887
public StructuredTaskResult getSourceGenDirectory() {
89-
return new ConfigFieldResolverStructuredTaskResult(
90-
JavaTaskUtils.createJavaCompilationConfigurationOutputTaskIdentifier(getTaskIdentifier()),
88+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
9189
new SourceGenDirectoryConfigResolverTaskResult());
9290
}
9391

9492
@Override
9593
public StructuredTaskResult getModuleName() {
96-
return new ConfigFieldResolverStructuredTaskResult(
97-
JavaTaskUtils.createJavaCompilationConfigurationOutputTaskIdentifier(getTaskIdentifier()),
94+
return new ConfigFieldResolverStructuredTaskResult(getTaskIdentifier(),
9895
new ModuleNameConfigResolverTaskResult());
9996
}
10097

@@ -150,6 +147,21 @@ public Object resolveField(JavaCompilationConfigurationOutput config) {
150147
}
151148
}
152149

150+
public static final class JavaSDKConfigResolverTaskResult extends CompilationTaskFieldResolver {
151+
private static final long serialVersionUID = 1L;
152+
153+
/**
154+
* For {@link Externalizable}.
155+
*/
156+
public JavaSDKConfigResolverTaskResult() {
157+
}
158+
159+
@Override
160+
public Object resolveField(JavaCompilationConfigurationOutput config) {
161+
return config.getJavaSDK();
162+
}
163+
}
164+
153165
public static final class HeaderDirectoryConfigResolverTaskResult extends CompilationTaskFieldResolver {
154166
private static final long serialVersionUID = 1L;
155167

0 commit comments

Comments
 (0)
0