Artifact is overwritten if there are two contracts with the same name #1087
Description
- I've asked for help in the Truffle Gitter before filing this issue.
Issue
If there are multiple sol files with the same name but under different folders in contracts, for example if there's 3 sol files in contracts
- contracts/Game.sol
- contracts/Game1/Game.sol
- contracts/Game2/Game.sol
Only one artifact will be generated when running truffle compile
, because it's overwritten by the last contract compiled, typically by the one with greatest lexicographic order in full path
Steps to Reproduce
Make 3 contracts in contracts folder, with any code, as long as the 3 contracts are different
- contracts/Game.sol
- contracts/Game1/Game.sol
- contracts/Game2/Game.sol
Run truffle compile
, only 1 artifact is created in build/contracts
Expected Behavior
The artifacts should be placed in folders too and not just overwritten. So there should be
- build/contracts/Game.json
- build/contracts/Game1/Game.json
- build/contracts/Game2/Game.json
Which can be required by artifacts.require("./Game1/Game.json")
and such
Actual Results
Only one artifact is generated, build/contracts/Game.json
, which is the artifact of the last contract compiled, in this case contracts/Game2/Game.sol
Environment
- Operating System: Linux 4.17.3-1-ARCH
- Ethereum client:Ganache CLI v6.1.4 (ganache-core: 2.1.3)
- Truffle version (
truffle version
): Truffle v4.1.13 (core: 4.1.13) - node version (
node --version
): v8.11.3 - npm version (
npm --version
): 6.1.0