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

fix: android config returns incorrect paths #1080

Merged
merged 2 commits into from
Mar 29, 2020
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
4 changes: 4 additions & 0 deletions docs/platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ type ProjectConfigAndroidT = {
assetsPath: string;
mainFilePath: string;
packageName: string;
packageFolder: string;
appName: string;
};
```

Expand Down Expand Up @@ -133,6 +135,8 @@ type DependencyConfigAndroidT = {
folder: string;
packageImportPath: string;
packageInstance: string;
manifestPath: string;
packageName: string;
};
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,14 @@ describe('android::getProjectConfig', () => {

expect(getProjectConfig(folder, userConfig)).toBeNull();
});

it('should correctly resolve mainFilePath', () => {
const userConfig = {};
const folder = '/nested';

const config = getProjectConfig(folder, userConfig);
expect(config.mainFilePath).toEqual(
'/nested/android/app/src/main/java/com/some/example/MainApplication.java',
);
});
});
12 changes: 6 additions & 6 deletions packages/platform-android/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ export function projectConfig(
const mainFilePath = path.join(
sourceDir,
userConfig.mainFilePath ||
`src/main/java/${packageFolder}/MainApplication.java`,
path.join(appName, `src/main/java/${packageFolder}/MainApplication.java`),
);

const stringsPath = path.join(
sourceDir,
userConfig.stringsPath || 'src/main/res/values/strings.xml',
userConfig.stringsPath ||
path.join(appName, '/src/main/res/values/strings.xml'),
);

const settingsGradlePath = path.join(
root,
'android',
sourceDir,
userConfig.settingsGradlePath || 'settings.gradle',
);

const assetsPath = path.join(
sourceDir,
userConfig.assetsPath || 'src/main/assets',
userConfig.assetsPath || path.join(appName, '/src/main/assets'),
);

const buildGradlePath = path.join(
Expand All @@ -95,7 +95,7 @@ export function projectConfig(
assetsPath,
mainFilePath,
packageName,
packageFolder: '',
packageFolder,
appName,
};
}
Expand Down