I have 3 flavours in android studio.
when I create any flavour apk then release folder with apk(+somefile) generated under respected flavour folder and this considers as an unversioned file for git.
because
I don't want in git so I added *release in .gitignore file
is it the wrong way to do?
will it create problem in future?
myApp
- .gradle
- .idea
- build
- app
- build
- flavour1
-release
-app-flavour1-release.apk
-output-metadata.json
- flavour2
-release
-app-flavour2-release.apk
-output-metadata.json
- libs
- src
- flavour1
- somefile
- flavour2
- somefile
- main
- test
- androidTest
- .gigignore
- build.gradle
- proguard-rules.pro
- releasekeystore.jks
- .gigignore
- build.gradle
- openCVLibrary3410
- build
- src
- .gigignore
- lint.xml
- scanlibrary
- build
- src
- .gigignore
- build.gradle
- .gigignore
- build.gradle
- somefile..
I wouldn't say it is wrong, but I would recommend you make sure the pattern in the gitignore file fits with your standard project layout as strictly as possible to avoid the case where someone makes a folder later and it is unexpectedly ignored.
\*release will ignore any file or folder ending in "release" within the same folder as the ignore file. In my projects I often hyphenate special folders like that such as "linux-release" so I would probably use"*-release" in that case to reduce the cases it would match as much as possible.
All this to say that what you have done shouldn't cause any problems but I would go the extra mile to make sure it is not unpredictable to the rest of your team by being more specific in the pattern now.
If you'd like, post a better example of your folder structure to offer more direct advice.
Example of a Different Practice:
In many projects i have worked on we put releases in build/release/android and build/release/ios folders. We have build/ in our .gitignore and use these subfolders of build specifically because every dev knows anything in that folder should be the result of a build or byproducts of it, which are not version conrtolled. So our devs know any folder named build, even in another non-src directory is not something probably shouldnt be used for storing files in git.
Related
Let’s say I have a directory structure like this in an Azure DevOps repo:
Main/
- A/
- *.csproj
- B/
- *.csproj
- C/
- *.csproj
Each subfolder has a .csproj file. I want to compile the Main/A/ folder and save the build results (artifacts?) somewhere, be it a folder or something else. How do I tell Azure to build that precise Main/A/*.csproj file and do I need to use /p:OutputPath inside the VSBuild#1 task, or do I need to use some other Azure task?
How do I tell Azure to build that precise Main/A/*.csproj file and do
I need to use /p:OutputPath inside the VSBuild#1 task
If you're using classic UI, you need to unlink the default solution:
And then choose the A project by the browse option:
If you're using Yaml format, you should use something like solution: A/A.csproj to specify which project to build.
Note:
Since now we're building single project instead of whole solution, we should use Project Configuration instead of Solution Configuration. any cpu is Solution Platform instead of Project Platform(AnyCPU). So we should make sure we're building single project with AnyCPU if we want to build one project with this setting.
If you got error The OutputPath property is not set for project 'A.csproj', that indicates you should use valid project configuration. In your case, if you're using any cpu, change it to AnyCPU.
In addition:
1.To publish the build results as build artifacts for further use. You can use Copy Files task and Publish Build Artifacts task like this:
Copy Files Task.
Publish Build Artifacts
Then you can download the Test.zip in Summary tab from build log page. Also, you can use this artifact in release pipeline by using download artifacts task.
Check this, if you're trying build code project instead of whole solution. You can consider MSBuild Task. They(Msbuild task,VS Build task) both calls msbuild.exe to do the build job.
Hope all above helps :)
Im setting up a unit test project and using SVN for source control. There are two nuget packages used. Im not sure if I need to exclude the files being generated or not.
MSTest.TestAdapter.1.2.0 and MSTest.TestFramework.1.2.0
When I go to commit the files within my branch, I see a lot of what look like new files being added in this folder MSTest.TestAdapter.1.2.0/build. eg.
MSTest.TestAdapter.1.2.0/build
MSTest.TestAdapter.1.2.0/build/_common/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Can I exclude everything from build/* ?
As a rule of thumb, you shouldn't keep Nuget packages in svn. In Visual Studio 2017 they are not event located in your project folder structure, but in %HOME%\.nuget\packages. Reference: Should we include Nuget PACKAGE folder in version control?
I would add whole packages folder to ignored if I were you.
I was using ANT before (Android Project) and i had "static" files in the same packages as my code
Here is an example
src/com/my/app/test/Parser.java
src/com/my/app/test/json_to_parse.json
When executing the unit tests, the json file was copied into the gen folder, therfor it was possible to access the json in the test with
getClass().getResourceAsStream(fileName)
I had to convert the project to gradle, but now the tests are failing.
After checking the "build" folder, i've realised, the .json files are not there, therefor the getResourceAsStream method returns null.
Any idea how to include these "static" files (json, xml, ...) into the build folder?
Moving the files into the resources folder did not work out of the box in Android Studio (even though is should have)
This should be fixed in Android Studio 1.2.
However, this is what i did:
Moved all static files into the resources folder.
In my unit-test module i've added this to the build.gradle file
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources
Now, all files located inside src/test/resources will be copied into /classes/test where i can access them with
getClass().getResourceAsStream(fileName)
If i keep the package structure inside the resources folder the same as it was in the java folder, i don't need to adjust any code.
To complete the story a bit more:
JUnit4 runner requires
getClass().getResourceAsStream(name)
while Robolectric requires
getClass().getClassLoader().getResourceAsStream(name)
The files you are asking about are called "resource files" in Maven/Gradle lingo.
Gradle assumes that you are using the Maven Standard Directory Layout.
So, either you move your files into src/test/resources (then Gradle will pick them up automatically), or you tell Gradle that it should look for resources in some other place.
In the latter case, you need to modify the processTestResources task. However, keeping resource files in the same directory as source code is a bad practice. So I advise the former option.
if your problem is happen when you create apk with AndroidStudio.
you can create a jar file that includes your resources with jar.exe
for example i put a.txt into resources directory
and run this code in cmd:
"C:\Program Files\Java\jdk1.7.0_79\bin\jar" cvfe res.jar -c resources
after that a jar file "res.jar" was created
then add that res.jar into libs folder in your project
when your apk is creating resources are added to your final apk and you can use this code to acsess a.txt:
someclass.class.getClassLoader().getResourceAsStream("resources/a.txt");
with this job no need to change Gradle setting.
I am trying to run a git bisect while using our automated tests to check the commit if it is the one causing the defect. The structure of our program is:
app
- cucumber_tests
- features/
- main_features/
- cucumber.yml
- src/
Obviously this is not the default/standard folder structure for running Cucumber tests as you would want the features folder to be at top-level of your app. This was not my choice and cannot be changed.
I can run the tests by cd into cucumber_test and then run. However, in order to run git bisect it must be done at same level as the .git folder.
My question is: is there a way to run the Cucumber tests from a parent directory of the features folder in Cucumber? Being able to read the cucumber.yml file would also be very beneficial.
Is there a way to tell Cucumber that you are not using the standard folder structure?
Edit: I have been able to get the tests started by using cucumber -r cucumber_tests/features cucumber_tests/features/main_features/first.feature. However, it is unable to find some of the step definitions part-way through the test.
It appears that cucumber is looking for files in app/features not app/cucumber_tests/features
You can still use the same folder structure. But you need to change the parameters in order to run your features. Otherwise this will not load step definitions. I hope you have step definitions inside the features folder. So now use this command to run the features: cucumber -r <absolute path of the features folder[C:\users\xyz\project\some_folder\features] absolute_path_feature_file[C:\users\xyz\project\some_folder\features\example.feature]
This way you cucumber will load your step definitions even if you have a different folder structure.
I'm trying to create a nuget package by using the convention as described here
I think my csproj's output folder looks correct:
[projectPath]/bin/Debug/
- myProject.dll
/build
- myProject.props
/content
- myRuleset.ruleset
- CustomDictionary.xml
The spec file is the default generated spec file with the redundant nodes removed (like update info etc)
I run nuget pack -build after which the following content is packed in a nupkg file (left out _rels and package as they aren't relevant to the problem):
myProject.1.0.1.0.nupkg
/content
/build
- myProject.props
/lib
- myProject.dll
Why is my build folder inside my content folder?
Where have my content folder's files gone to?
The default generated spec file just gives you a starting point. User need to modify the spec file for nuget pack to work correctly with your project structure.
Please refer to this link http://docs.nuget.org/docs/reference/nuspec-reference, for how to include files to the package.
There is a section named "Specifying Files to Include in the Package" should give more insights.