public Scm getScm() { return getModel().getScm(); }
public Scm getScm() { return getModel().getScm(); }
protected void mergeModel_Scm( Model target, Model source, boolean sourceDominant, Map<Object, Object> context ) { Scm src = source.getScm(); if ( src != null ) { Scm tgt = target.getScm(); if ( tgt == null ) { tgt = new Scm(); tgt.setTag( null ); target.setScm( tgt ); } mergeScm( tgt, src, sourceDominant, context ); } }
private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getScm() != null ) { Scm parentScm = parent.getScm(); Scm childScm = child.getScm(); if ( childScm == null ) { childScm = new Scm(); child.setScm( childScm ); } if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) { childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) { childScm .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) { childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } }
private void assembleScmInheritance( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) { if ( parent.getScm() != null ) { Scm parentScm = parent.getScm(); Scm childScm = child.getScm(); if ( childScm == null ) { childScm = new Scm(); child.setScm( childScm ); } if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) { childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) { childScm .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) { childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); } } }
@Override public void normalize( Model model, ModelBuildingRequest request ) { if ( model == null ) { return; } model.setUrl( normalize( model.getUrl() ) ); Scm scm = model.getScm(); if ( scm != null ) { scm.setUrl( normalize( scm.getUrl() ) ); scm.setConnection( normalize( scm.getConnection() ) ); scm.setDeveloperConnection( normalize( scm.getDeveloperConnection() ) ); } DistributionManagement dist = model.getDistributionManagement(); if ( dist != null ) { Site site = dist.getSite(); if ( site != null ) { site.setUrl( normalize( site.getUrl() ) ); } } }
result.setProfiles( cloneList( src.getProfiles(), PROFILE_CLONER ) ); result.setScm( cloneScm( src.getScm() ) ); result.setUrl( src.getUrl() ); result.setVersion( src.getVersion() );
@Override public Scm get( Model model ) { return model.getScm(); }
@Override public Scm getScm() { return delegate.getScm(); }
/** * get github repository URL from pom.xml */ private String getRemoteRepoUrlFromPom(String path) throws MojoExecutionException { Model model = null; try { File pomFile = new File(path); if(pomFile.isDirectory()){ pomFile = new File(pomFile, "pom.xml"); } model = new MavenXpp3Reader().read(new FileInputStream(pomFile)); } catch (IOException e) { throw new MojoExecutionException("Failed to access file "+path,e); } catch (XmlPullParserException e) { throw new MojoExecutionException("Failed to parse pom.xml",e); } String url = model.getScm().getUrl(); if (url.startsWith(SCM_GIT_URL)) { url = url.replace(SCM_GIT_URL, HTTPS_GIT_URL); } else { url = StringUtils.removeEnd(url, "/") + ".git"; } return url; }
protected void mergeModel_Scm( Model target, Model source, boolean sourceDominant, Map<Object, Object> context ) { Scm src = source.getScm(); if ( src != null ) { Scm tgt = target.getScm(); if ( tgt == null ) { tgt = new Scm(); tgt.setTag( null ); target.setScm( tgt ); } mergeScm( tgt, src, sourceDominant, context ); } }
private String extractGitHubHttpKeyFromModulePom(String artifactId, String version, String groupId) throws MojoExecutionException, IOException { downloadModulePom(new Artifact(artifactId, version, groupId, "pom")); String pomFileName = this.artifactId+"-"+version+".pom"; File pomDir = new File("pom/"); File pom = new File("pom/", pomFileName); Model pomProperties = Project.loadProject(pomDir, pomFileName).getModel(); String url = pomProperties.getScm().getUrl(); pom.delete(); pomDir.delete(); return extractUniversalRepoUrl(url); }
@Override protected void update(ModifiedPomXMLEventReader pom) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { try { Model model = PomHelper.getRawModel( pom ); Scm scm = model.getScm(); if (scm == null) { throw new MojoFailureException( "No <scm> was present" ); } getLog().info( "Updating from tag " + scm.getTag() + " > " + newTag ); boolean success = PomHelper.setProjectValue(pom, "/project/scm/tag", newTag ); if ( !success ) { throw new MojoFailureException( "Could not update the SCM tag" ); } } catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } } }
@Override public boolean canGenerateReport() { boolean result = super.canGenerateReport(); if ( result && skipEmptyReport ) { Scm scm = getProject().getModel().getScm(); result = scm != null; if ( result && StringUtils.isEmpty( anonymousConnection ) && StringUtils.isEmpty( developerConnection ) && StringUtils.isEmpty( scm.getUrl() ) ) { result = false; } } return result; }
/** * * @param model */ private static void setScmDevUrl(Model model){ model.setScm(new Scm()); model.getScm().setConnection(Constants.OPEN_LIBERTY_SCM_CONNECTION); model.getScm().setDeveloperConnection(Constants.OPEN_LIBERTY_SCM_CONNECTION); model.getScm().setUrl(Constants.OPEN_LIBRETY_SCM_URL); model.getScm().setTag(Constants.OPEN_LIBERTY_SCM_TAG); model.setUrl(Constants.OPEN_LIBERTY_URL); Developer dev = new Developer(); dev.setId(Constants.DEV_ID); dev.setName(Constants.DEV_NAME); dev.setEmail(Constants.DEV_EMAIL); List<Developer> developers = new ArrayList<Developer>(); developers.add(dev); model.setDevelopers(developers); }
protected Scm buildScm( MavenProject project ) { Scm scm; if ( project.getOriginalModel().getScm() == null ) { scm = null; } else { scm = new Scm(); scm.setConnection( project.getOriginalModel().getScm().getConnection() ); scm.setDeveloperConnection( project.getOriginalModel().getScm().getDeveloperConnection() ); scm.setTag( project.getOriginalModel().getScm().getTag() ); scm.setUrl( project.getOriginalModel().getScm().getUrl() ); } return scm; } }
@PostConstruct public void init() { // setting the artifact version to a release version temporarily since the dist repository checks for a snapshot // version of the artifact. Maybe this can be implemented in a different manner but then we would have to setup the // repository manually org.apache.maven.artifact.Artifact projectArtifact = this.project.getArtifact(); String oldVersion = projectArtifact.getVersion(); projectArtifact.setVersion("1"); // replace properties in remote repository URL and getting the remote repo ArtifactRepository artifactRepository = this.project.getDistributionManagementArtifactRepository(); if (artifactRepository != null) { PomPropertyResolver propertyResolver = new PomPropertyResolver(this.project, this.settings, this.profiles, this.releaseArgs); artifactRepository.setUrl(propertyResolver.expandPropertyReferences(artifactRepository.getUrl())); this.deploymentRepository = RepositoryUtils.toRepo(artifactRepository); } // resetting the artifact version projectArtifact.setVersion(oldVersion); for (MavenProject p : this.reactorProjects) { // puts the initial module artifact coordinates into the cache addArtifactCoordinates(ProjectToCoordinates.POM.apply(p), ReleasePhase.PRE_RELEASE); // caching of SCM settings of every POM in order to go back to it before setting next dev version this.cachedScmSettings.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), p.getModel().getScm()); Optional<Document> parsedPOM = PomUtil.parsePOM(p); if (parsedPOM.isPresent()) { this.originalPOMs.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), parsedPOM.get()); } } }
void project(Model model) { String name = model.getName(); if (name == null) { name = model.getArtifactId(); } p.printStartBlock( "project", name, model.getUrl() ); p.println(); p.println( "model_version", model.getModelVersion() ); p.println( "inception_year", model.getInceptionYear() ); id(model); parent(model.getParent()); p.println("packaging", model.getPackaging()); p.println(); description(model.getDescription()); developers( model.getDevelopers() ); issueManagement( model.getIssueManagement() ); mailingLists( model.getMailingLists() ); repositories( toRepositoryArray( model.getRepositories() ) ); pluginRepositories( toRepositoryArray( model.getPluginRepositories() ) ); sourceControl( model.getScm() ); distribution( model.getDistributionManagement() ); properties( model.getProperties() ); dependencies( model.getDependencies() ); modules( model.getModules() ); managements( model.getDependencyManagement(), model.getBuild() ); build( model.getBuild(), model.getBuild() ); profiles( model.getProfiles() ); reporting( model.getReporting() ); p.printEndBlock(); }