Java Code Examples for org.apache.maven.model.Model#setGroupId()
The following examples show how to use
org.apache.maven.model.Model#setGroupId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateProjectTest.java From quarkus with Apache License 2.0 | 6 votes |
@Test public void createOnTopOfExisting() throws Exception { final File testDir = new File("target/existing"); delete(testDir); testDir.mkdirs(); Model model = new Model(); model.setModelVersion("4.0.0"); model.setGroupId("org.acme"); model.setArtifactId("foobar"); model.setVersion("10.1.2"); final File pom = new File(testDir, "pom.xml"); MojoUtils.write(model, pom); assertThatExceptionOfType(QuarkusCommandException.class).isThrownBy(() -> { new CreateProject(testDir.toPath(), getPlatformDescriptor()) .groupId("something.is") .artifactId("wrong") .version("1.0.0-SNAPSHOT") .className("org.foo.MyResource") .execute(); }).withRootCauseInstanceOf(IOException.class); }
Example 2
Source File: DistributionEnforcingManipulatorTest.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
@Test public void projectUnchangedWhenModeIsNone() throws Exception { final Plugin plugin = new Plugin(); plugin.setGroupId( MAVEN_PLUGIN_GROUPID ); plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID ); plugin.setConfiguration( simpleSkipConfig( true ) ); final Build build = new Build(); build.addPlugin( plugin ); final Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( "org.foo" ); model.setArtifactId( "bar" ); model.setVersion( "1" ); model.setBuild( build ); applyTest( none, model, null ); }
Example 3
Source File: DistributionEnforcingManipulatorTest.java From pom-manipulation-ext with Apache License 2.0 | 6 votes |
@Test public void projectDeploySkipTurnedOffWhenModeIsOff() throws Exception { final Plugin plugin = new Plugin(); plugin.setGroupId( MAVEN_PLUGIN_GROUPID ); plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID ); plugin.setConfiguration( simpleSkipConfig( true ) ); final Build build = new Build(); build.addPlugin( plugin ); final Model model = new Model(); model.setModelVersion( "4.0.0" ); model.setGroupId( "org.foo" ); model.setArtifactId( "bar" ); model.setVersion( "1" ); model.setBuild( build ); applyTest( off, model, model ); assertSkip( model, null ); }
Example 4
Source File: GAVTest.java From maven-git-versioning-extension with MIT License | 6 votes |
@Test void of_model_withParent_noInheritance() { // Given Model model = new Model(); model.setGroupId("group"); model.setArtifactId("artifact"); model.setVersion("version"); Parent parent = new Parent(); parent.setGroupId("parentGroup"); parent.setArtifactId("parentArtifact"); parent.setVersion("parentVersion"); model.setParent(parent); // When GAV gav = GAV.of(model); // Then assertThat(gav).isNotNull(); assertThat(gav.getGroupId()).isEqualTo("group"); assertThat(gav.getArtifactId()).isEqualTo("artifact"); assertThat(gav.getVersion()).isEqualTo("version"); }
Example 5
Source File: MavenUploadHandlerTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testValidatPom() { Model model = new Model(); model.setGroupId("testGroup"); model.setArtifactId("testArtifact"); model.setVersion("1.0"); underTest.validatePom(model); }
Example 6
Source File: ProjectVersionManipulatorTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void updateEffectiveAndOriginalModelMainVersions() throws Exception { final Model orig = new Model(); orig.setGroupId( "org.foo" ); orig.setArtifactId( "bar" ); orig.setVersion( "1.0" ); final Model eff = orig.clone(); final String suff = AddSuffixJettyHandler.DEFAULT_SUFFIX; final String mv = orig.getVersion() + "." + suff; final Map<ProjectVersionRef, String> versionsByGAV = new HashMap<>(); versionsByGAV.put( new SimpleProjectVersionRef( orig.getGroupId(), orig.getArtifactId(), orig.getVersion() ), mv ); final MavenProject project = new MavenProject( eff ); project.setOriginalModel( orig ); final Set<MavenProject> changes = newVersioningModifier().applyVersioningChanges( Collections.singletonList( project ), versionsByGAV ); assertThat( changes.size(), equalTo( 1 ) ); assertThat( orig.getVersion(), equalTo( mv ) ); assertThat( eff.getVersion(), equalTo( mv ) ); }
Example 7
Source File: VersioningCalculatorTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_DifferentAvailableIncrements() throws Exception { final String v = "1.2.0.GA"; final String os = "-foo-1"; final String ns = "foo-10"; final Model m1 = new Model(); m1.setGroupId( GROUP_ID ); m1.setArtifactId( ARTIFACT_ID ); m1.setVersion( v + os ); final Project p1 = new Project( m1 ); final String a2 = ARTIFACT_ID + "-dep"; final Model m2 = new Model(); m2.setGroupId( GROUP_ID ); m2.setArtifactId( a2 ); m2.setVersion( v + os ); final Project p2 = new Project( m2 ); final Properties props = new Properties(); props.setProperty( VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP, "foo-0" ); final Map<ProjectRef, String[]> versionMap = new HashMap<>(); versionMap.put( new SimpleProjectRef( p1.getGroupId(), p1.getArtifactId() ), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2", "1.2.0.GA-foo-9" } ); versionMap.put( new SimpleProjectRef( p2.getGroupId(), p2.getArtifactId() ), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2" } ); setupSession( props, versionMap ); final Map<ProjectVersionRef, String> result = modder.calculateVersioningChanges( Arrays.asList( p1, p2 ), session ); assertThat( result.get( new SimpleProjectVersionRef( GROUP_ID, ARTIFACT_ID, v + os ) ), equalTo( v + "-" + ns ) ); assertThat( result.get( new SimpleProjectVersionRef( GROUP_ID, a2, v + os ) ), equalTo( v + "-" + ns ) ); }
Example 8
Source File: Pom.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
public void writePom ( final Writer writer ) throws IOException { final Model model = new Model (); model.setGroupId ( this.groupId ); model.setArtifactId ( this.artifactId ); model.setVersion ( this.version ); new MavenXpp3Writer ().write ( writer, model ); }
Example 9
Source File: MavenUploadHandlerTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test(expected = ValidationErrorsException.class) public void testValidatePom_versionWithProperty() { Model model = new Model(); model.setArtifactId("testArtifact"); model.setGroupId("testGroup"); model.setVersion("${aProperty}"); underTest.validatePom(model); }
Example 10
Source File: VersioningCalculatorTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_AvailableOnlyForOne_Padding() throws Exception { final String v = "1.2.0.GA"; final String os = "-foo-001"; final String ns = "foo-010"; final Model m1 = new Model(); m1.setGroupId( GROUP_ID ); m1.setArtifactId( ARTIFACT_ID ); m1.setVersion( v + os ); final Project p1 = new Project( m1 ); final String a2 = ARTIFACT_ID + "-dep"; final Model m2 = new Model(); m2.setGroupId( GROUP_ID ); m2.setArtifactId( a2 ); m2.setVersion( v + os ); final Project p2 = new Project( m2 ); final Properties props = new Properties(); props.setProperty( VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP, "foo" ); setupSession( props, "1.2.0.GA-foo-003", "1.2.0.GA-foo-002", "1.2.0.GA-foo-009" ); System.out.println ("### Calculating versioning changes for projects " + p1 + " and " + p2); final Map<ProjectVersionRef, String> result = modder.calculateVersioningChanges( Arrays.asList( p1, p2 ), session ); assertThat( result.get( new SimpleProjectVersionRef( GROUP_ID, ARTIFACT_ID, v + os ) ), equalTo( v + "-" + ns ) ); assertThat( result.get( new SimpleProjectVersionRef( GROUP_ID, a2, v + os ) ), equalTo( v + "-" + ns ) ); }
Example 11
Source File: TestUtils.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
public static Model getDummyModel () { Model result = new Model(); result.setGroupId( "org.commonjava.maven.ext" ); result.setArtifactId( "dummy-model" ); result.setVersion( "1.0.0-SNAPSHOT" ); return result; }
Example 12
Source File: MavenUploadHandlerTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testValidatPom_parentVersion() { Model model = new Model(); model.setParent(new Parent()); model.getParent().setVersion("2.0"); model.setGroupId("testGroup"); model.setArtifactId("testArtifact"); underTest.validatePom(model); }
Example 13
Source File: MavenPomFileGenerator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPomFileGenerator(MavenProjectIdentity identity) { mavenProject.setModelVersion(POM_VERSION); Model model = getModel(); model.setGroupId(identity.getGroupId()); model.setArtifactId(identity.getArtifactId()); model.setVersion(identity.getVersion()); }
Example 14
Source File: MavenUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static MavenProject createMavenProject(String groupId, String artifactId, String version, String packagingType) { Model model = new Model(); model.setGroupId(groupId); model.setArtifactId(artifactId); model.setVersion(version); model.setModelVersion("4.0.0"); model.setName(artifactId); model.setDescription(artifactId); if (packagingType!=null){ model.setPackaging(packagingType); } return new MavenProject(model); }
Example 15
Source File: PomIOTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void testRewritePOMs() throws Exception { URL resource = PomIOTest.class.getResource( filename ); assertNotNull( resource ); File pom = new File( resource.getFile() ); assertTrue( pom.exists() ); File targetFile = folder.newFile( "target.xml" ); FileUtils.writeStringToFile( targetFile, FileUtils.readFileToString( pom, StandardCharsets.UTF_8 ) .replaceAll( "dospom", "newdospom" ), StandardCharsets.UTF_8 ); FileUtils.copyFile( pom, targetFile ); List<Project> projects = pomIO.parseProject( targetFile ); Model model = projects.get( 0 ).getModel(); model.setGroupId( "org.commonjava.maven.ext.versioning.test" ); model.setArtifactId( "dospom" ); model.setVersion( "1.0" ); model.setPackaging( "pom" ); model.setModelVersion( "4.0.0" ); Project p = new Project( targetFile, model ); HashSet<Project> changed = new HashSet<>(); changed.add( p ); pomIO.rewritePOMs( changed ); assertTrue( FileUtils.contentEqualsIgnoreEOL( pom, targetFile, StandardCharsets.UTF_8.toString() ) ); assertTrue( FileUtils.contentEquals( targetFile, pom ) ); }
Example 16
Source File: PomIOTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test public void testGAVReturnPOMs() throws Exception { URL resource = PomIOTest.class.getResource( filename ); assertNotNull( resource ); File pom = new File( resource.getFile() ); assertTrue( pom.exists() ); File targetFile = folder.newFile( "target.xml" ); FileUtils.copyFile( pom, targetFile ); Model model = new Model(); model.setGroupId( "org.commonjava.maven.ext.versioning.test" ); model.setArtifactId( "dospom" ); model.setVersion( "1.0" ); model.setPackaging( "pom" ); model.setModelVersion( "4.0.0" ); Project p = new Project( targetFile, model ); p.setExecutionRoot(); HashSet<Project> changed = new HashSet<>(); changed.add( p ); ProjectVersionRef gav = pomIO.rewritePOMs( changed ); assertEquals( "1.0", gav.getVersionString() ); assertEquals( "org.commonjava.maven.ext.versioning.test", gav.getGroupId() ); assertEquals( "dospom", gav.getArtifactId() ); }
Example 17
Source File: ProjectTest.java From pom-manipulation-ext with Apache License 2.0 | 5 votes |
@Test (expected = ManipulationException.class ) public void verifyProjectValidation() throws ManipulationException { final Model m = new Model(); m.setGroupId( "org.foo" ); m.setArtifactId( "bar" ); new Project( m ); }
Example 18
Source File: PomGenerator.java From raptor with Apache License 2.0 | 5 votes |
public Model buildModel() { Model model = readExamplePom(); model.setArtifactId(pomModel.getArtifactId()); model.setGroupId(pomModel.getGroupId()); model.setVersion(pomModel.getVersion()); return model; }
Example 19
Source File: MavenPomFileGenerator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPomFileGenerator(MavenProjectIdentity identity) { mavenProject.setModelVersion(POM_VERSION); Model model = getModel(); model.setGroupId(identity.getGroupId()); model.setArtifactId(identity.getArtifactId()); model.setVersion(identity.getVersion()); }
Example 20
Source File: PomUpdaterTests.java From spring-cloud-release-tools with Apache License 2.0 | 4 votes |
private ModelWrapper model(String projectName, String groupId) { Model parent = new Model(); parent.setArtifactId(projectName); parent.setGroupId(groupId); return new ModelWrapper(parent); }