Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Run spotless on all files in pbj-core #368

Merged
merged 1 commit into from
Jan 18, 2025
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
17 changes: 8 additions & 9 deletions .github/workflows/zxc-compile-pbj-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,14 @@ jobs:
build-root-directory: ${{ env.PBJ_CORE }}
arguments: assemble

# Removed for now until pbj-core can be made compatible with spotless
# - name: Gradle Check (PBJ Core)
# uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
# if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }}
# with:
# gradle-version: ${{ inputs.gradle-version }}
# build-root-directory: ${{ env.PBJ_CORE }}
# arguments: check
#
- name: Gradle Check (PBJ Core)
uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
build-root-directory: ${{ env.PBJ_CORE }}
arguments: check

- name: Publish JUnit Test Report (PBJ Core)
uses: step-security/publish-unit-test-result-action@4519d7c9f71dd765f8bbb98626268780f23bab28 # v2.17.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && always() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import org.gradle.api.internal.tasks.TaskDependencyFactory;

/** Source directory set for PBJ, a directory full of .proto source files */
public abstract class DefaultPbjSourceDirectorySet extends DefaultSourceDirectorySet
implements PbjSourceDirectorySet {
public abstract class DefaultPbjSourceDirectorySet extends DefaultSourceDirectorySet implements PbjSourceDirectorySet {

@Inject
public DefaultPbjSourceDirectorySet(
SourceDirectorySet sourceSet, TaskDependencyFactory taskDependencyFactory) {
public DefaultPbjSourceDirectorySet(SourceDirectorySet sourceSet, TaskDependencyFactory taskDependencyFactory) {
super(sourceSet, taskDependencyFactory);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
* Copyright (C) 2023-2025 Hedera Hashgraph, 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.
*/

// SPDX-License-Identifier: Apache-2.0
package com.hedera.pbj.compiler;

import com.hedera.pbj.compiler.impl.ContextualLookupHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ public void apply(Project project) {
// for the 'main' source set we:
// 1) Add a new 'pbj' virtual directory mapping
PbjSourceDirectorySet pbjSourceSet =
createPbjSourceDirectorySet(
((DefaultSourceSet) mainSrcSet).getDisplayName(), getObjectFactory());
mainSrcSet
.getExtensions()
.add(PbjSourceDirectorySet.class, PbjSourceDirectorySet.NAME, pbjSourceSet);
createPbjSourceDirectorySet(((DefaultSourceSet) mainSrcSet).getDisplayName(), getObjectFactory());
mainSrcSet.getExtensions().add(PbjSourceDirectorySet.class, PbjSourceDirectorySet.NAME, pbjSourceSet);
pbjSourceSet.getFilter().include("**/*.proto");
pbjSourceSet.srcDir("src/" + mainSrcSet.getName() + "/proto");
mainSrcSet.getAllSource().source(pbjSourceSet);
Expand All @@ -56,31 +53,20 @@ public void apply(Project project) {
// naming conventions via call to sourceSet.getTaskName()
final String taskName = mainSrcSet.getTaskName("generate", "PbjSource");

TaskProvider<PbjCompilerTask> pbjCompiler =
project.getTasks()
.register(
taskName,
PbjCompilerTask.class,
pbjTask -> {
pbjTask.setDescription(
"Processes the "
+ mainSrcSet.getName()
+ " Pbj grammars.");
// 4) set up convention mapping for default sources (allows user
// to not have to specify)
pbjTask.setSource(pbjSourceSet);
pbjTask.getJavaMainOutputDirectory().set(outputDirectoryMain);
pbjTask.getJavaTestOutputDirectory().set(outputDirectoryTest);
});
TaskProvider<PbjCompilerTask> pbjCompiler = project.getTasks()
.register(taskName, PbjCompilerTask.class, pbjTask -> {
pbjTask.setDescription("Processes the " + mainSrcSet.getName() + " Pbj grammars.");
// 4) set up convention mapping for default sources (allows user
// to not have to specify)
pbjTask.setSource(pbjSourceSet);
pbjTask.getJavaMainOutputDirectory().set(outputDirectoryMain);
pbjTask.getJavaTestOutputDirectory().set(outputDirectoryTest);
});

// 5) register fact that pbj should be run before compiling by informing the 'java' part
// of the source set that it contains code produced by the pbj compiler
mainSrcSet
.getJava()
.srcDir(pbjCompiler.flatMap(PbjCompilerTask::getJavaMainOutputDirectory));
testSrcSet
.getJava()
.srcDir(pbjCompiler.flatMap(PbjCompilerTask::getJavaTestOutputDirectory));
mainSrcSet.getJava().srcDir(pbjCompiler.flatMap(PbjCompilerTask::getJavaMainOutputDirectory));
testSrcSet.getJava().srcDir(pbjCompiler.flatMap(PbjCompilerTask::getJavaTestOutputDirectory));
}

/**
Expand All @@ -94,10 +80,8 @@ private static PbjSourceDirectorySet createPbjSourceDirectorySet(
String parentDisplayName, ObjectFactory objectFactory) {
String name = parentDisplayName + ".pbj";
String displayName = parentDisplayName + " Pbj source";
PbjSourceDirectorySet pbjSourceSet =
objectFactory.newInstance(
DefaultPbjSourceDirectorySet.class,
objectFactory.sourceDirectorySet(name, displayName));
PbjSourceDirectorySet pbjSourceSet = objectFactory.newInstance(
DefaultPbjSourceDirectorySet.class, objectFactory.sourceDirectorySet(name, displayName));
pbjSourceSet.getFilter().include("**/*.proto");
return pbjSourceSet;
}
Expand Down
Loading
Loading