Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Building with gradle - imports for customizations not found #13

Open
qux42 opened this issue Sep 28, 2016 · 1 comment
Open

Building with gradle - imports for customizations not found #13

qux42 opened this issue Sep 28, 2016 · 1 comment

Comments

@qux42
Copy link

qux42 commented Sep 28, 2016

Hi again,
I wanna use Primitive wrappers, but i can't get it working. Compiler says that the import was not found or had errors. I'm using gradle to build the protobuf-messages.

build.gradle:

apply plugin: 'scala'

// protoc
def protoDestDir = 'build/generated-sources/protobuf/'
// proto
def protoDir = new FileNameFinder().getFileNames('src/main/proto/', "*.proto")

configurations {
    scalapbc
}


dependencies {

    scalapbc "com.trueaccord.scalapb:scalapbc_${scalaVersion}:0.5.43"
    compile "com.trueaccord.scalapb:scalapb-runtime_${scalaVersion}:0.5.43"
}

task scalapbc << {
    mkdir(protoDestDir)

    javaexec {
        main = 'com.trueaccord.scalapb.ScalaPBC'
        classpath = configurations.scalapbc
        args = [ "--proto_path=${file('src/main/proto').absolutePath}", "--scala_out=single_line_to_string:${protoDestDir}"] +  protoDir
    }
}

sourceSets {
    main {
        scala {
            srcDirs = ['build/generated-sources/protobuf/', 'src/main/scala/', 'src/main/java']
        }
        java {
            srcDirs = []
        }
    }
    test {
        scala {
            srcDirs = ['build/generated-sources/protobuf/','src/main/scala/', 'src/test/java']
        }
        java {
            srcDirs = []
        }
    }
}
compileScala {
    dependsOn scalapbc
}
clean {
    delete protoDestDir
}

the message:

syntax = "proto3";

package com.miele.mcs.business.protobuf;

import "scalapb/scalapb.proto";
import "google/protobuf/wrappers.proto";

option (scalapb.options) = {
  primitive_wrappers: true
};



message ... {
    int64 ... = 1;
}

/**
 * Tell the actor to update the user agent of the host.
 */
message ... {
    int64 ... = 1;
    string ... = 2;
}

The compiler doesn't find both imports. Are there dependencies missing?

@thesamet
Copy link
Contributor

thesamet commented Sep 28, 2016

When using scalapbc it's up to you to provide scalapb.proto and wrappers.proto to protoc. You need to make those files available somewhere in the file system and pass that location via --proto_path.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants