Skip to content

Commit

Permalink
fix: Unable to generate files in different directories smotastic#54
Browse files Browse the repository at this point in the history
  • Loading branch information
skykaka committed Aug 23, 2022
1 parent 29c1c31 commit 2890860
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
18 changes: 18 additions & 0 deletions example/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Use the different 'build_extensions' on the folder 'otherlib'. So that the code generated by
# smartstruct will be writed to the customized folder ('otherlib/gen').

targets:
$default:
sources:
exclude:
- otherlib/**

$my-target:
sources:
- otherlib/**

builders:
smartstruct_generator|mapper:

options:
build_extensions: {"^otherlib/{{}}.dart": "otherlib/gen/{{}}.mapper.g.dart"}
19 changes: 19 additions & 0 deletions example/otherlib/example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:smartstruct/smartstruct.dart';
part '../gen/example/example.mapper.g.dart';

class Source {
final String userName;

Source(this.userName);
}

class Target {
final String username;

Target({required this.username});
}

@Mapper()
abstract class ExampleMapper {
Target fromSource(Source source);
}
2 changes: 1 addition & 1 deletion generator/lib/integrations/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import '../generators/mapper_generator.dart';

/// Main Builder for the [Mapping] Annotation
Builder smartstructBuilder(BuilderOptions options) =>
PartBuilder([MapperGenerator()], '.mapper.g.dart');
PartBuilder([MapperGenerator()], '.mapper.g.dart', options: options);

0 comments on commit 2890860

Please sign in to comment.