def _copy_src_dir_to(self, todir): ''' Copy source files in another directory to avoid modifications in original source files. ''' if os.path.exists(todir): log.info('removing existing folder', todir) targetDirectory = os.path.join(todir, 'target') if os.path.exists(targetDirectory): log.debug('target directory was generated, so we keep it as it is in directory {}'.format(targetDirectory)) tmpDir = os.path.join(tempfile.mkdtemp(), 'target') shutil.copytree(targetDirectory, tmpDir) OS_Utils.rm_dir(todir) os.mkdir(todir) shutil.copytree(tmpDir, targetDirectory) shutil.rmtree(tmpDir) else: OS_Utils.rm_dir(todir) os.mkdir(todir) else: os.mkdir(todir) log.info('copying files from', self.build_cfg.component_dir(), 'to', todir) for directory in os.listdir(self.build_cfg.component_dir()): if directory not in ['.xmake.cfg', 'gen', 'import', 'cfg', '.git', '.gitignore', 'target']: pathToCopy = os.path.join(self.build_cfg.component_dir(), directory) if os.path.isdir(pathToCopy): shutil.copytree(pathToCopy, os.path.join(todir, directory)) else: shutil.copyfile(pathToCopy, os.path.join(todir, directory))
def prepare_sources(self): log.info('copying module sources...') if os.path.exists(self.module_dir): OS_Utils.rm_dir(self.module_dir) os.mkdir(self.module_dir) for directory in os.listdir(self._root): if directory not in [ '.xmake.cfg', '.xmake', 'gen', 'import', 'cfg', '.git', 'node_modules' ]: pathToCopy = os.path.join(self._root, directory) if os.path.isdir(pathToCopy): copytree(pathToCopy, os.path.join(self.module_dir, directory)) else: copyfile(pathToCopy, os.path.join(self.module_dir, directory)) os.mkdir(join(self.module_dir, 'node_modules')) self.check_tool([])
def rm_if_target_exists(): if os.path.exists(buildtools_target_dir): OS_Utils.rm_dir(buildtools_target_dir)
def prepare_sources(self): log.info('copying context sources...') if os.path.exists(self.context_dir): OS_Utils.rm_dir(self.context_dir) ign = ignore_patterns('gen*', 'import', 'cfg', '.git', 'node_modules') if self.is_plain() else None copytree(self.build_cfg.src_dir(), self.context_dir, ignore=ign)
def _build(self): ''' Build source files ''' # Maven phases: # validate - validate the project is correct and all necessary information is available # compile - compile the source code of the project # test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed # package - take the compiled code and package it in its distributable format, such as a JAR. # integration-test - process and deploy the package if necessary into an environment where integration tests can be run # verify - run any checks to verify the package is valid and meets quality criteria # install - install the package into the local repository, for use as a dependency in other projects locally # deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. # Metadata quality check only for release or milestone build # See details of checks in https://wiki.wdf.sap.corp/wiki/display/LeanDI/Release+Build+Details#ReleaseBuildDetails-VersionUpdates if self.build_cfg.is_release() == 'direct-shipment' or self.build_cfg.is_release() == 'indirect-shipment': # For a customer release build use quality-check-config-customer.xml self._run_metadata_quality_check('-Dmetadata-quality-report.configuration=quality-check-config-customer.xml', '-Dcodesign.sap.realcodesigning=true') elif self.build_cfg.is_release() == 'milestone': # For a milestone build use quality-check-config-milestone.xml self._set_version_in_pom(self.build_cfg.base_version()) self._run_metadata_quality_check('-Dmetadata-quality-report.configuration=quality-check-config-milestone.xml') # Compile sources and install binaries in local repository maven_args = [] # Manage clean phase if self.build_cfg.do_clean(): maven_args.append('clean') # prepare filesystem for local deployment if os.path.exists(self._localDeploymentPath): OS_Utils.rm_dir(self._localDeploymentPath) localDeploymentUrl = urlparse.urljoin('file:', urllib.pathname2url(self._localDeploymentPath)) # Go until install phase to install package locally and # to be able to use it as dependency in other local projects maven_args.append('deploy') maven_args.append('-DaltDeploymentRepository=local::default::{}'.format(localDeploymentUrl)) maven_args.append('-DuniqueVersion=false') # add options for signing ''' History: 1- _maven_jarsigner_plugin_options() was initially called with is_release_build() as parameter 2- is_release() was introduced for leandi 3- is_release_build() was reneamed into is_milestone() for xmake-dev (in xmake-dev we talk about "milestone release" builds) 4- Certainly instead of renaming is_release_build() to is_milestone() in the _maven_jarsigner_plugin_options() call, it was renamed into is_release(), by the way signing worked only for leandi and not anymore for xmake-dev 5- to work under both systems the call must be done with this value as parameter: self._maven_jarsigner_plugin_options(self.build_cfg.is_release() or self.build_cfg.is_milestone()) Comment: Signing env vars are checked in the _maven_jarsigner_plugin_options() method. SNAPSHOT suffixs are checked in is_milestone() which also ensure that it does not run in is_release() mode +-----------+---------------+--------------+------------+------------------+-------------------+ | System | Build type | is_milestone | is_release | Signing env vars | Signing activated | +-----------+---------------+--------------+------------+------------------+-------------------+ | xMake-Dev | | | | | | | | CI/Voter/PR | No | No | No | No | | | OD Milestones | Yes | No | No | No | | | OD Releases | Yes | No | Yes | Yes | | xMake-Ldi | | | | | | | | OD Release | No | Yes | Yes | Yes | +-----------+---------------+--------------+------------+------------------+-------------------+ ASCII Table was generated with: https://ozh.github.io/ascii-tables/ ''' maven_args.extend(self._maven_jarsigner_plugin_options(self.build_cfg.is_release() or self.build_cfg.is_milestone())) if self.build_cfg.skip_test(): maven_args.append('-Dmaven.test.skip=true') # add user options maven_args.extend(shlex.split(' '.join(self._maven_user_options))) # call mvn command self._mvn(maven_args) # Store build dependencies, should be done before _store_build_dependencies to ensure that the leandi plugin used for # generating metadata are also stored in the dependencies for reproducing the build with the exact leandi plugin versions for metadata generation # Generate release metadata data only in customer or in milestone if self.build_cfg.is_release(): if self._ldi_metadata: log.info('building leandi metadata') self._store_ldi_metadata() else: log.info('leandi metadata generation disabled') # Store build dependencies log.info('building dependencies') self._store_build_dependencies()